[Python-Dev] test_strptime; test_logging; test_time failure (was: cygwin errors) (original) (raw)
Brett C. drifty@alum.berkeley.edu
Tue, 22 Jul 2003 15:52:54 -0700
- Previous message: [Python-Dev] cygwin errors
- Next message: [Python-Dev] RE: test_strptime; test_logging; test_time failure (was: cygwin errors)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Tim Peters wrote:
[Brett C.]
OK. This is where running:
>>> import time >>> time.strftime("%c") >>> import strptime >>> strptime.TimeRE()['c'] can help me try to diagnose this (I can't reproduce this under OS X). This will give me what strftime is spitting out and what regex strptime would be using to match against it. After reverting Jeremy's hack to testlogging, and hacking regrtest.py to stop doing sys.exit(): C:\Code\python\PCbuild>python -i ../lib/test/regrtest.py teststrptime testlogging testtime teststrptime testlogging testtime test testtime failed -- Traceback (most recent call last): File "C:\Code\python\lib\test\testtime.py", line 49, in teststrptime self.fail('conversion specifier: %r failed.' % format) File "C:\Code\python\lib\unittest.py", line 260, in fail raise self.failureException, msg AssertionError: conversion specifier: ' %c' failed. 2 tests OK. 1 test failed: testtime
import time time.strftime("%c") '07/22/2003 05:44:01 PM' import strptime _strptime.TimeRE()['c'] '(?P1[0-2]|0[1-9]|[1-9])/(?P3[0-1]|[1-2]\d|0[1-9]| [1-9]| [1-9])/(?P\d\d)\s*(?P2[0-3]|[0-1]\d|\d) :(?P[0-5]\d|\d):(?P
6[0-1]|[0-5]\d|\d)'Now the same thing with Jeremy's testlogging hack restored: C:\Code\python\PCbuild>python -i ../lib/test/regrtest.py teststrptime testlogging testtime teststrptime testlogging testtime All 3 tests OK. import time time.strftime("%c") '07/22/03 17:47:26' import strptime _strptime.TimeRE()['c'] '(?P1[0-2]|0[1-9]|[1-9])/(?P3[0-1]|[1-2]\d|0[1-9]| [1-9]| [1-9])/(?P\d\d)\s*(?P2[0-3]|[0-1]\d|\d) :(?P[0-5]\d|\d):(?P6[0-1]|[0-5]\d|\d)'The regexp appears to be the same, but strftime's result has switched from (apparently) 12-hour + AM/PM time to 24-hour time.
OK, the only thing I can think of is that the locale info has changed ever so subtly and the checking of locale.getlocale(locale.LC_TIME)[0] or locale.getdefaultlocale()[0] is not cutting it. Next thing to try is to see what values locale.getlocale(locale.LC_TIME) and locale.getdefaultlocale() have (notice I am asking for the full value and not just the 0 item) after each test is run. It is possible the cache in _strptime is not being cleared because it is not picking up the change in locale by only checking the 0 item.
If there is not some obvious difference in values then the cache will have to be deleted and strptime performance will drop but the problem will go away.
-Brett
- Previous message: [Python-Dev] cygwin errors
- Next message: [Python-Dev] RE: test_strptime; test_logging; test_time failure (was: cygwin errors)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]