Skip to content

Commit 8afd433

Browse files
committed
Attempt to avoid crashing with python3.15
1 parent 6c1a513 commit 8afd433

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

Changelog.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ DEPENDENCY / BASELINE CHANGES:
1111
- Restore compatibility with pygame 1.9.4 that had a broken
1212
`blits` function. Thanks to onpon4 for reporting the issue
1313
(Closes: #293) (nthykier)
14+
- Add guard to prevent crashing when `locale.getdefaultencoding`
15+
is removed in python3.15.
1416

1517
USER-VISIBLE CHANGES:
1618
- New feature: Quicksaves - save on `F5` (replacing "reload theme")

singularity/code/i18n.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ def _get_main_localedir():
5757

5858
try:
5959
language = locale.getdefaultlocale()[0] or default_language
60-
except RuntimeError:
60+
except (RuntimeError, AttributeError):
61+
# locale.getdefaultlocale is slated for removal in 3.15.
62+
# With the attribute error, we should at least not crash when the time comes.
6163
language = default_language
6264

6365

@@ -73,7 +75,7 @@ def set_language(lang=None, force=False):
7375
if lang in langs:
7476
language = lang
7577
else:
76-
# Let's try to be smart: if base language exists for another for another
78+
# Let's try to be smart: if base language exists for another
7779
# country, use it. So es_ES => es_AR, pt_PT => pt_BR, etc
7880
code = lang.split("_")[0]
7981
languages = [l for l in langs if code == l.split("_")[0]]

0 commit comments

Comments
 (0)