]> git.phdru.name Git - m_lib.defenc.git/commitdiff
Fix(locale): Do not call `locale.getdefaultlocale()` under Python 3.11+
authorOleg Broytman <phd@phdru.name>
Thu, 10 Aug 2023 14:20:16 +0000 (17:20 +0300)
committerOleg Broytman <phd@phdru.name>
Thu, 10 Aug 2023 14:20:16 +0000 (17:20 +0300)
The call is deprecated.

m_lib/defenc.py

index 776b78dabb0eb428f51baaae01d4e58958cc8540..22cd21b364d3ca670236340ce90b8853df494aa1 100755 (executable)
@@ -15,7 +15,10 @@ __all__ = ['default_encoding']
 if use_locale:
    # Get the default charset.
    try:
-      lcAll = locale.getdefaultlocale()
+      if sys.version_info[:2] < (3, 11):
+         lcAll = locale.getdefaultlocale()
+      else:
+         lcAll = []
    except locale.Error as err:
       print("WARNING:", err, file=sys.stderr)
       lcAll = []