Skip to content
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

BUG: fix an incoming incompatibility with Python 3.15 (locale.getdefaultlocale is deprecated in Python 3.12) #3070

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ Infrastructure, Utility and Other Changes and Additions

- Versions of PyVO <1.5 are no longer supported. [#3002]

- Fix an incoming incompatibility with Python 3.15 (`locale.getdefaultlocale`
is deprecated in Python 3.12) [#3070]

utils.tap
^^^^^^^^^

Expand Down
24 changes: 14 additions & 10 deletions ah_bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -838,16 +838,20 @@ def run_cmd(cmd):
'`{0}` command:\n{1}'.format(' '.join(cmd), str(e)))


# Can fail of the default locale is not configured properly. See
# https://github.com/astropy/astropy/issues/2749. For the purposes under
# consideration 'latin1' is an acceptable fallback.
try:
stdio_encoding = locale.getdefaultlocale()[1] or 'latin1'
except ValueError:
# Due to an OSX oddity locale.getdefaultlocale() can also crash
# depending on the user's locale/language settings. See:
# https://bugs.python.org/issue18378
stdio_encoding = 'latin1'
if sys.version_info >= (3, 11):
stdio_encoding = locale.getencoding()
else:
# Can fail of the default locale is not configured properly. See
# https://github.com/astropy/astropy/issues/2749. For the purposes under
# consideration 'latin1' is an acceptable fallback.
try:
stdio_encoding = locale.getdefaultlocale()[1] or 'latin1'
except ValueError:
# Due to an OSX oddity locale.getdefaultlocale() can also crash
# depending on the user's locale/language settings. See:
# https://bugs.python.org/issue18378
stdio_encoding = 'latin1'


# Unlikely to fail at this point but even then let's be flexible
if not isinstance(stdout, str):
Expand Down
Loading