summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2007-04-01 18:47:27 (GMT)
committerBrett Cannon <bcannon@gmail.com>2007-04-01 18:47:27 (GMT)
commitc69066501bc2da4aa325833c76e6cf12b87aafa6 (patch)
treebb31b9ac1298aa9671f58e64336fc2f8fdbb8f9b /Lib/test
parent8f35f44af3aacf1802253dc33e26e64306e55756 (diff)
downloadcpython-c69066501bc2da4aa325833c76e6cf12b87aafa6.zip
cpython-c69066501bc2da4aa325833c76e6cf12b87aafa6.tar.gz
cpython-c69066501bc2da4aa325833c76e6cf12b87aafa6.tar.bz2
time.strptime's caching of its locale object was being recreated when the
locale changed but not used during the function call it was recreated during. The test in this checkin is untested (OS X does not have the proper locale support for me to test), although the fix for the bug this deals with was tested by the OP (#1290505). Once the buildbots verify the test at least doesn't fail it becomes a backport candidate.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_strptime.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_strptime.py b/Lib/test/test_strptime.py
index 56e1ab8..48e6b31 100644
--- a/Lib/test/test_strptime.py
+++ b/Lib/test/test_strptime.py
@@ -505,6 +505,23 @@ class CacheTests(unittest.TestCase):
self.failIfEqual(locale_time_id,
id(_strptime._TimeRE_cache.locale_time))
+ def test_TimeRE_recreation(self):
+ # The TimeRE instance should be recreated upon changing the locale.
+ locale_info = locale.getlocale(locale.LC_TIME)
+ try:
+ locale.setlocale(locale.LC_TIME, ('en_US', 'UTF8'))
+ except locale.Error:
+ return
+ try:
+ _strptime.strptime('10', '%d')
+ first_time_re_id = id(_strptime._TimeRE_cache)
+ locale.setlocale(locale.LC_TIME, ('de_DE', 'UTF8'))
+ _strptime.strptime('10', '%d')
+ second_time_re_id = id(_strptime._TimeRE_cache)
+ self.failIfEqual(first_time_re_id, second_time_re_id)
+ finally:
+ locale.setlocale(locale.LC_TIME, locale_info)
+
def test_main():
test_support.run_unittest(