[Python-bugs-list] [ python-Bugs-796149 ] _strptime mishandling
parentheses in format
SourceForge.net
noreply at sourceforge.net
Wed Aug 27 12:03:39 EDT 2003
Bugs item #796149, was opened at 2003-08-27 11:03
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=796149&group_id=5470
Category: Python Library
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Josh Hoyt (joshhoyt)
Assigned to: Nobody/Anonymous (nobody)
Summary: _strptime mishandling parentheses in format
Initial Comment:
If parentheses are included in a format string, the
format string will not match.
e.g.
>>> time.strptime('(5)', '(%d)')
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.3/_strptime.py", line 424, in
strptime
raise ValueError("time data did not match format:
data=%s fmt=%s" %
ValueError: time data did not match format: data=(5)
fmt=(%d)
Even worse:
>>> time.strptime('(5)', '(%d)')
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.3/_strptime.py", line 420, in
strptime
format_regex = _locale_cache.compile(format)
File "/usr/lib/python2.3/_strptime.py", line 398, in
compile
return re_compile(self.pattern(format), IGNORECASE)
File "/usr/lib/python2.3/sre.py", line 179, in compile
return _compile(pattern, flags)
File "/usr/lib/python2.3/sre.py", line 229, in _compile
raise error, v # invalid expression
sre_constants.error: unbalanced parenthesis
It looks like parentheses need to be escaped before the
format string is processed.
In Python 2.3.0 _strptime.py:
384c384
< regex_chars = re_compile(r"([\.^$*+?{}\[\]|])")
---
> regex_chars =
re_compile(r"([()\.^$*+?{}\[\]|])")
seemed to fix the problem.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=796149&group_id=5470
More information about the Python-bugs-list
mailing list