Skip to content

Commit

Permalink
Fix getdefaultlocale deprecation warning on python 3.11+
Browse files Browse the repository at this point in the history
  • Loading branch information
mjurbanski-reef committed Oct 10, 2024
1 parent 0c04c66 commit b5dc780
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion b2/_internal/arg_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@

from rst2ansi import rst2ansi

try:
getencoding = locale.getencoding
except AttributeError: # Python <=3.10

def getencoding():
return locale.getdefaultlocale()[1]


class B2RawTextHelpFormatter(argparse.RawTextHelpFormatter):
"""
Expand Down Expand Up @@ -142,7 +149,7 @@ def error(self, message):

@classmethod
def _get_encoding(cls):
_, locale_encoding = locale.getdefaultlocale()
locale_encoding = getencoding()

# Check if the stdout is properly set
if sys.stdout.encoding is not None:
Expand Down
1 change: 1 addition & 0 deletions changelog.d/+getdefaultlocale.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix `getdefaultlocale` deprecation warning on Python 3.11+.

0 comments on commit b5dc780

Please sign in to comment.