bug report - time.strptime()

Thomas Wouters thomas at xs4all.net
Tue May 23 03:12:01 EDT 2000


On Tue, May 23, 2000 at 03:52:40AM -0000, Kevin Ng wrote:

> >>> s5='000201'
> >>> tup5 = time.strptime(s5, '%y%m%d')
> >>> tup5
> (1900, 1, 0, 0, 0, 0, 6, 1, 0)
> 
> >>> s6='00 02 01' 
> >>> tup6=time.strptime(s6, '%y %m %d')
> >>> tup6
> (1900, 2, 1, 0, 0, 0, 6, 1, 0)

> Note the pattern is whenever the format string has no separation,
> then strptime always return a date tuple of Jan 0 !?

> My python version and platform :
> Python 1.5.2 (#3, Jan 20 2000, 15:59:17)  [GCC egcs-2.90.29 980515
> (egcs-1.0.3 re on linux2

What linux distribution/libc are you using ? It seems to be a bug in the
provided strptime() library call, because i dont see it (standard python
1.5.2 on RedHat 6.2, and non-standard python 1.6 on RedHat 6.1:

>>> s6='00 02 01' 
>>> time.strptime(s6, '%y %m %d')
(2000, 2, 1, 0, 0, 0, 1, 32, 0)

The time.strptime() function is not much more than a wrapper around the libc
strptime(), so I'm afraid you'll have to trace it there ;) Upgrading is
fairly likely to fix the problem, as both my boxes are running glibc 2.1
(2.1.2 ad 2.1.3) and they are working fine.

PS: better to use python-list at python.org, instead of @cwi.nl

-- 
Thomas Wouters <thomas at xs4all.net>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!




More information about the Python-list mailing list