[Python-Dev] RE: test_strptime; test_logging; test_time failure (was: cygwin errors)
Tim Peters
tim.one@comcast.net
Tue, 22 Jul 2003 19:20:11 -0400
Note that I'm on Win98SE now (previous email today was on Win2K).
Under current CVS, but with regrtest hacked not to do sys.exit():
C:\Code\python\PCbuild>python -i ../lib/test/regrtest.py test_strptime
test_logging
test_time
test_strptime
test_logging
test_time
All 3 tests OK.
>>> import forbrett
time.strftime("%c")
'07/22/03 19:11:50'
_strptime.TimeRE()['c']
'(?P<m>1[0-2]|0[1-9]|[1-9])/(?P<d>3[0-1]|[1-2]\\d|0[1-9]|
[1-9]| [1-9])/(?P<y>\\d\\d)\\s*(?P<H>2[0-3]|[0-1]\\d|\\d)
:(?P<M>[0-5]\\d|\\d):(?P<S>6[0-1]|[0-5]\\d|\\d)'
locale.getdefaultlocale()
('en_US', 'cp1252')
locale.getlocale(locale.LC_TIME)
(None, None)
>>>
Again, but reverting Jeremy's test_logging locale fiddling:
C:\Code\python\PCbuild>python -i ../lib/test/regrtest.py test_strptime
test_logging
test_time
test_strptime
test_logging
test_time
test test_time failed -- Traceback (most recent call last):
File "C:\CODE\PYTHON\lib\test\test_time.py", line 49, in test_strptime
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:
test_time
>>> import forbrett
time.strftime("%c")
'07/22/2003 07:14:31 PM'
_strptime.TimeRE()['c']
'(?P<m>1[0-2]|0[1-9]|[1-9])/(?P<d>3[0-1]|[1-2]\\d|0[1-9]|
[1-9]| [1-9])/(?P<y>\\d\\d)\\s*(?P<H>2[0-3]|[0-1]\\d|\\d)
:(?P<M>[0-5]\\d|\\d):(?P<S>6[0-1]|[0-5]\\d|\\d)'
locale.getdefaultlocale()
('en_US', 'cp1252')
locale.getlocale(locale.LC_TIME)
['English_United States', '1252']
>>>
This is forbrett.py:
"""
def dump(tag, value):
import pprint
print tag
pprint.pprint(value)
print
import time
dump('time.strftime("%c")',
time.strftime("%c"))
import _strptime
dump("_strptime.TimeRE()['c']",
_strptime.TimeRE()['c'])
import locale
dump("locale.getdefaultlocale()",
locale.getdefaultlocale())
dump("locale.getlocale(locale.LC_TIME)",
locale.getlocale(locale.LC_TIME))
"""
[Brett C.]
> 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.
Barry agrees <wink>.