]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Restore the locale to "C" on exit.
authorJeremy Hylton <jeremy@alum.mit.edu>
Fri, 18 Jul 2003 03:19:20 +0000 (03:19 +0000)
committerJeremy Hylton <jeremy@alum.mit.edu>
Fri, 18 Jul 2003 03:19:20 +0000 (03:19 +0000)
If this doesn't happen, it leaves the locale in a state that can cause
other tests to fail.  For example, running test_strptime,
test_logging, and test_time in that order.

Lib/test/test_logging.py

index ecf0e68e6de815c8d73b554468f6632834a903c2..19322937a4c24d225bc1ff67deaa322afed15432 100644 (file)
@@ -30,11 +30,11 @@ import socket, threading, time, locale
 import logging, logging.handlers, logging.config
 
 try:
-    locale.setlocale(locale.LC_ALL, '')
+    cur_locale = locale.setlocale(locale.LC_ALL, '')
 except (ValueError, locale.Error):
     # this happens on a Solaris box which only supports "C" locale
     # or a Mac OS X box which supports very little locale stuff at all
-    pass
+    cur_locale = None
 
 BANNER = "-- %-10s %-6s ---------------------------------------------------\n"
 
@@ -474,6 +474,9 @@ def test_main():
         banner("logrecv output", "end")
         sys.stdout.flush()
 
+    if cur_locale:
+        locale.setlocale(locale.LC_ALL, "C")
+
 if __name__ == "__main__":
     sys.stdout.write("test_logging\n")
     test_main()