[New-bugs-announce] [issue4430] time.strptime does not allow same format directive twice

sil report at bugs.python.org
Tue Nov 25 17:36:42 CET 2008


New submission from sil <sil-python at kryogenix.org>:

$ python -c "import time; print time.strptime('25/11/2008
25/11/2008','%d/%m/%y %d/%m/%y')"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python2.5/_strptime.py", line 311, in strptime
    format_regex = _TimeRE_cache.compile(format)
  File "/usr/lib/python2.5/_strptime.py", line 267, in compile
    return re_compile(self.pattern(format), IGNORECASE)
  File "/usr/lib/python2.5/re.py", line 188, in compile
    return _compile(pattern, flags)
  File "/usr/lib/python2.5/re.py", line 241, in _compile
    raise error, v # invalid expression
sre_constants.error: redefinition of group name 'd' as group 4; was group 1

If a format directive is repeated in time.strptime's format string, it
throws an error and should not do so. Subversion, for example, repeats
date parts in its svn log output ("2008-09-26 16:20:59 +0100 (Fri, 26
Sep 2008)"), which repeats both %d (day) and %y (year).

----------
messages: 76417
nosy: sil
severity: normal
status: open
title: time.strptime does not allow same format directive twice
type: behavior
versions: Python 2.5

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4430>
_______________________________________


More information about the New-bugs-announce mailing list