[ python-Bugs-210698 ] strptime gives format mismatch when time zone present (PR#164)

SourceForge.net noreply at sourceforge.net
Fri Nov 14 19:17:54 EST 2003


Bugs item #210698, was opened at 2000-07-31 14:29
Message generated for change (Comment added) made by trewitt
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=210698&group_id=5470

Category: None
Group: Platform-specific
Status: Closed
Resolution: Invalid
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Tim Peters (tim_one)
Summary: strptime gives format mismatch when time zone present (PR#164)

Initial Comment:
Jitterbug-Id: 164
Submitted-By: python-bugreport at derf.net
Date: Tue, 21 Dec 1999 08:27:27 -0500 (EST)
Version: 1.5.2
OS: RedHat 5.2; Linux 2.2.12


time.strptime() seems to fail when the time zone ('%Z') appears in the format
string.  when it is omitted from the format string (and from the string being 
parsed), strptime() works fine.

here is a sample script which demonstrates the bug:

------
#!/usr/bin/python

import time

timetuple0 = time.localtime(time.time())
print timetuple0

format1 = '%a %b %d %H:%M:%S %Y'
timestring1 = time.strftime( format1 , timetuple0 )
print timestring1
timetuple1 = time.strptime( timestring1 , format1 )
print timetuple1

format2 = '%a %b %d %H:%M:%S %Z %Y'
timestring2 = time.strftime( format2 , timetuple0 )
print timestring2
timetuple2 = time.strptime( timestring2 , format2 )
print timetuple2
------

when i run the above, i get the following output:

------
(1999, 12, 21, 5, 25, 35, 1, 355, 0)
Tue Dec 21 05:25:35 1999
(1999, 12, 21, 5, 25, 35, 1, 355, 0)
Tue Dec 21 05:25:35 PST 1999
Traceback (innermost last):
  File "./test.py", line 17, in ?
    timetuple2 = time.strptime( timestring2 , format2 )
ValueError: format mismatch
------



====================================================================
Audit trail:
Tue Dec 21 11:47:04 1999	guido	changed notes
Tue Dec 21 11:47:05 1999	guido	moved from incoming to platformbug

----------------------------------------------------------------------

Comment By: Glenn Trewitt (trewitt)
Date: 2003-11-14 16:17

Message:
Logged In: YES 
user_id=230628

I get the same error *for some builds*.  I'm using Redhat 9,
and the bug shows up  in (I think) the stock Python 2.2.  If
I compile 2.3.2 from source, it works fine.

(2003, 11, 14, 16, 3, 22, 4, 318, 0)
Fri Nov 14 16:03:22 2003
(2003, 11, 14, 16, 3, 22, 4, 318, 0)
Fri Nov 14 16:03:22 PST 2003
Traceback (most recent call last):
  File "timep.py", line 17, in ?
    timetuple2 = time.strptime( timestring2 , format2 )
ValueError: format mismatch


----------------------------------------------------------------------

Comment By: Tim Peters (tim_one)
Date: 2000-09-08 09:13

Message:
Closed it, as it's not a Python bug but a bug in the platform libc (if a non-std fnc can be called "buggy" at all ...).

----------------------------------------------------------------------

Comment By: M.-A. Lemburg (lemburg)
Date: 2000-09-08 05:27

Message:
FYI, you could check out mxDateTime which provides a parser
for various date/time formats instead of waiting for your strptime()
C API to get fixed.

mxDateTime is available at http://starship.python.net/~lemburg/.

----------------------------------------------------------------------

Comment By: Jeremy Hylton (jhylton)
Date: 2000-09-07 15:06

Message:
Please do triage on this bug.

----------------------------------------------------------------------

Comment By: Nobody/Anonymous (nobody)
Date: 2000-08-01 14:03

Message:
The C library strptime() needs fixin'.

----------------------------------------------------------------------

Comment By: Nobody/Anonymous (nobody)
Date: 2000-08-01 14:03

Message:
From: Guido van Rossum <guido at CNRI.Reston.VA.US>
Subject: Re: [Python-bugs-list] strptime gives format mismatch when time zone present (PR#164)
Date: Tue, 21 Dec 1999 09:12:15 -0500

> time.strptime() seems to fail when the time zone ('%Z') appears in
> the format string.  when it is omitted from the format string (and
> from the string being parsed), strptime() works fine.

Reporting this as a Python bug is not going to fix it.  The
time.strptime() function in Python is a very thin wrapper around the
strptime() function in the C library.  We get a lot of complaints
about this, but there's no way that we're able to fix this -- it's the
C strptime() function that needs to be fixed.  Write to your friendly
Linux support people!

--Guido van Rossum (home page: http://www.python.org/~guido/)


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=210698&group_id=5470



More information about the Python-bugs-list mailing list