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, belopolsky
Date 2013-11-10.17:03:44
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1384103025.17.0.0483523701082.issue19545@psf.upfronthosting.co.za>
In-reply-to
Content
time.strptime leaks an IndexError, as seen in the following traceback. 

[root@clnstor /tank/libs/cpython]# ./python
Python 3.4.0a4+ (default:0aa2aedc6a21+, Nov  5 2013, 17:10:42)
[GCC 4.2.1 20070831 patched [FreeBSD]] on freebsd8
Type "help", "copyright", "credits" or "license" for more information.
>>> import time
>>> time.strptime('19', '%Y %')
Traceback (most recent call last):
  File "/tank/libs/cpython/Lib/_strptime.py", line 320, in _strptime
    format_regex = _TimeRE_cache.compile(format)
  File "/tank/libs/cpython/Lib/_strptime.py", line 268, in compile
    return re_compile(self.pattern(format), IGNORECASE)
  File "/tank/libs/cpython/Lib/_strptime.py", line 262, in pattern
    self[format[directive_index]])
IndexError: string index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/tank/libs/cpython/Lib/_strptime.py", line 494, in _strptime_time
    tt = _strptime(data_string, format)[0]
  File "/tank/libs/cpython/Lib/_strptime.py", line 332, in _strptime
    raise ValueError("stray %% in format '%s'" % format)
ValueError: stray % in format '%Y %'
>>>

The attached patch suppresses the exception. This issue is similar (and based on) the issue17572.
History
Date User Action Args
2013-11-10 17:03:45Claudiu.Popasetrecipients: + Claudiu.Popa, belopolsky
2013-11-10 17:03:45Claudiu.Popasetmessageid: <1384103025.17.0.0483523701082.issue19545@psf.upfronthosting.co.za>
2013-11-10 17:03:45Claudiu.Popalinkissue19545 messages
2013-11-10 17:03:44Claudiu.Popacreate