New submission from Claudiu.Popa:

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.

----------
components: Library (Lib)
files: strptime.patch
keywords: patch
messages: 185495
nosy: Claudiu.Popa
priority: normal
severity: normal
status: open
title: strptime exception context
type: behavior
versions: Python 3.3, Python 3.4
Added file: http://bugs.python.org/file29602/strptime.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue17572>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to