]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-104783: locale.getlocale() calls sys.getfilesystemencoding() (#105401)
authorVictor Stinner <vstinner@python.org>
Tue, 6 Jun 2023 18:19:40 +0000 (20:19 +0200)
committerGitHub <noreply@github.com>
Tue, 6 Jun 2023 18:19:40 +0000 (18:19 +0000)
locale.getlocale() always calls sys.getfilesystemencoding(), instead
of calling it only once.

Lib/locale.py

index cd52ecd28f438f7d23cf91df259c8a5f630d8b74..55c819ca80a1604d88f5a266751d82c555f3e964 100644 (file)
@@ -618,9 +618,8 @@ try:
 except ImportError:
     # When _locale.getencoding() is missing, locale.getencoding() uses the
     # Python filesystem encoding.
-    _encoding = sys.getfilesystemencoding()
     def getencoding():
-        return _encoding
+        return sys.getfilesystemencoding()
 
 
 try: