This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Claudiu.Popa
Recipients Claudiu.Popa
Date 2013-03-29.10:48:03
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1364554084.0.0.791831324367.issue17572@psf.upfronthosting.co.za>
In-reply-to
Content
When using a directive that is not recognised by time.strptime, the following occurs in Python 3:

>>> time.strptime("", "%D")
Traceback (most recent call last):
  File "C:\Python33\lib\_strptime.py", line 320, in _strptime
    format_regex = _TimeRE_cache.compile(format)
  File "C:\Python33\lib\_strptime.py", line 268, in compile
    return re_compile(self.pattern(format), IGNORECASE)
  File "C:\Python33\lib\_strptime.py", line 262, in pattern
    self[format[directive_index]])
KeyError: 'D'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python33\lib\_strptime.py", line 494, in _strptime_time
    tt = _strptime(data_string, format)[0]
  File "C:\Python33\lib\_strptime.py", line 329, in _strptime
    (bad_directive, format))
ValueError: 'D' is a bad directive in format '%D'
>>>

Probably the KeyError should be supressed when raising the ValueError. The attached patch tries to fix this issue, by suppressing the context.
History
Date User Action Args
2013-03-29 10:48:04Claudiu.Popasetrecipients: + Claudiu.Popa
2013-03-29 10:48:03Claudiu.Popasetmessageid: <1364554084.0.0.791831324367.issue17572@psf.upfronthosting.co.za>
2013-03-29 10:48:03Claudiu.Popalinkissue17572 messages
2013-03-29 10:48:03Claudiu.Popacreate