[Python-checkins] bpo-32139: test_strftime does not anymore modify the locale (GH-4569) (#4636)

xdegaye webhook-mailer at python.org
Wed Nov 29 10:29:57 EST 2017


https://github.com/python/cpython/commit/bc19cf57a8f061bbb1961aa069ed54e8361023ae
commit: bc19cf57a8f061bbb1961aa069ed54e8361023ae
branch: 2.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: xdegaye <xdegaye at gmail.com>
date: 2017-11-29T16:29:54+01:00
summary:

bpo-32139: test_strftime does not anymore modify the locale (GH-4569) (#4636)

(cherry picked from commit cc55e78acab93a495c974b9a2ea71c8bb9cc2f5d)

files:
M Lib/test/test_strftime.py

diff --git a/Lib/test/test_strftime.py b/Lib/test/test_strftime.py
index b26ebec93dc..325024ceaee 100644
--- a/Lib/test/test_strftime.py
+++ b/Lib/test/test_strftime.py
@@ -60,8 +60,10 @@ def setUp(self):
             import java
             java.util.Locale.setDefault(java.util.Locale.US)
         except ImportError:
-            import locale
-            locale.setlocale(locale.LC_TIME, 'C')
+            from locale import setlocale, LC_TIME
+            saved_locale = setlocale(LC_TIME)
+            setlocale(LC_TIME, 'C')
+            self.addCleanup(setlocale, LC_TIME, saved_locale)
 
     def test_strftime(self):
         now = time.time()



More information about the Python-checkins mailing list