Skip to content

Commit

Permalink
Patch only if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
vasole committed Oct 11, 2023
1 parent 2ab843c commit 2eba0ff
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions PyMca5/tests/SpecfileTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,19 @@
other_locale = l
break

# cleanup python 3.12 issue on same machines
if isinstance(current_locale, tuple):
# if the returned tuple is (None, 'UTF-8') it cannot restore the locale
current_as_list = list(current_locale)
for i in range(len(current_as_list)):
if current_as_list[i] is None:
current_as_list[i] = ''
current_locale = tuple(current_as_list)

locale.setlocale(locale.LC_ALL, current_locale)
try:
locale.setlocale(locale.LC_ALL, current_locale)
except locale.Error:
# cleanup python 3.12 issue on same machines
if isinstance(current_locale, tuple):
# if the returned tuple is (None, 'UTF-8') it cannot restore the locale
current_as_list = list(current_locale)
for i in range(len(current_as_list)):
if current_as_list[i] is None:
current_as_list[i] = ''
current_locale = tuple(current_as_list)
print(f"Patched locale <{current_locale}>")
locale.setlocale(locale.LC_ALL, current_locale)

class testSpecfile(unittest.TestCase):
def setUp(self):
Expand Down Expand Up @@ -101,7 +104,7 @@ def tearDown(self):
gc.collect()
# restore saved locale
locale.setlocale(locale.LC_ALL, current_locale)

if self.specfileClass is not None:
if os.path.exists(self.fname):
os.remove(self.fname)
Expand Down

0 comments on commit 2eba0ff

Please sign in to comment.