Invalid strings in Dateutil 2.2 now cause TypeError instead of ValueError
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
dateutil |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
Traceback in dateutil 2.1 looks like this:
>>> import dateutil
>>> dateutil.
'2.1'
>>> from dateutil import parser
>>> parser.
datetime.
>>> parser.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/
return DEFAULTPARSER.
File "/Users/
raise ValueError("unknown string format")
ValueError: unknown string format
And in dateutil 2.2 looks like this:
>>> import dateutil
>>> dateutil.
'2.2'
>>> from dateutil import parser
>>> parser.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/
return DEFAULTPARSER.
File "/Users/
res, skipped_tokens = self._parse(
TypeError: 'NoneType' object is not iterable
It works for a number of unknown strings, like 'fooflaf', 'hello my name is bob' or anything else seemingly that starts without a number.
Here's a patch which works for me and passes all the tests.
Essentially, the issue is that _parse returns None in a number of instances, but the interface has changed and a 2-tuple is now expected. It's essentially saying:
a, b = None
which fails miserably. Instead we return (None, None).