8000 bpo-47000: Add `locale.getencoding()` by methane · Pull Request #32068 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-47000: Add locale.getencoding() #32068

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Apr 9, 2022
Prev Previous commit
Next Next commit
get_encoding -> getencoding
  • Loading branch information
methane committed Apr 4, 2022
commit 8b50eb10de0805d0eda6a3e9aeb8865d32c6f7b7
6 changes: 3 additions & 3 deletions Lib/locale.py
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ def getpreferredencoding(do_setlocale=True):
"""Return the charset that the user is likely using."""
if sys.flags.utf8_mode:
return 'UTF-8'
return get_encoding()
return getencoding()
else:
# On Unix, if CODESET is available, use that.
def getpreferredencoding(do_setlocale=True):
Expand All @@ -667,15 +667,15 @@ def getpreferredencoding(do_setlocale=True):
return 'UTF-8'

if not do_setlocale:
return get_encoding()
return getencoding()

old_loc = setlocale(LC_CTYPE)
try:
try:
setlocale(LC_CTYPE, "")
except Error:
pass
return get_encoding()
return getencoding()
finally:
setlocale(LC_CTYPE, old_loc)

Expand Down
0