From 49a888155ede146389567600a2a91da1360c42e8 Mon Sep 17 00:00:00 2001 From: "V. Armando Sole" Date: Tue, 21 Jan 2025 18:51:13 +0100 Subject: [PATCH] Correct issue under windows and python 3.13 --- src/PyMca5/tests/SpecfileTest.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/PyMca5/tests/SpecfileTest.py b/src/PyMca5/tests/SpecfileTest.py index 925dac223..88a8b8f31 100644 --- a/src/PyMca5/tests/SpecfileTest.py +++ b/src/PyMca5/tests/SpecfileTest.py @@ -2,7 +2,7 @@ # # The PyMca X-Ray Fluorescence Toolkit # -# Copyright (c) 2004-2023 European Synchrotron Radiation Facility +# Copyright (c) 2004-2025 European Synchrotron Radiation Facility # # This file is part of the PyMca X-ray Fluorescence Toolkit developed at # the ESRF. @@ -46,18 +46,21 @@ other_locale = l break -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: - print(f"Returned locale <{current_locale}> reset to None") - current_locale = None +if other_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: + print(f"Returned locale <{current_locale}> reset to None") + current_locale = None + else: + current_locale = current_as_list[0] + locale.setlocale(locale.LC_ALL, current_locale) class testSpecfile(unittest.TestCase): def setUp(self):