]> granicus.if.org Git - python/commitdiff
Issue #18228: Fix locale test of test.regrtest.saved_test_environment
authorVictor Stinner <victor.stinner@gmail.com>
Mon, 17 Jun 2013 18:40:05 +0000 (20:40 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Mon, 17 Jun 2013 18:40:05 +0000 (20:40 +0200)
Skip LC_ALL becore getlocale(locale.LC_ALL) always fail, and catch also
ValueError.

Lib/test/regrtest.py

index e0ad0d3d3f2ef2b1563e5c94f59818911537590d..4170ad381b73fa02bcae175c9d63572146d2bbe9 100755 (executable)
@@ -1231,13 +1231,14 @@ class saved_test_environment:
             elif os.path.isdir(support.TESTFN):
                 shutil.rmtree(support.TESTFN)
 
-    _lc = [getattr(locale, lc) for lc in dir(locale) if lc.startswith('LC_')]
+    _lc = [getattr(locale, lc) for lc in dir(locale)
+           if lc.startswith('LC_') and lc != 'LC_ALL']
     def get_locale(self):
         pairings = []
         for lc in self._lc:
             try:
                 pairings.append((lc, locale.getlocale(lc)))
-            except TypeError:
+            except (TypeError, ValueError):
                 continue
         return pairings
     def restore_locale(self, saved):