parser breaks with bad input

Bug #1071212 reported by Tomi Hukkalainen
24
This bug affects 4 people
Affects Status Importance Assigned to Milestone
dateutil
Confirmed
Undecided
Unassigned

Bug Description

Reported at http://shriphani.com/blog/2012/10/24/dateutil-problems/

>>> dparser.parse("P 16:08 May 14, 2003 UTC", fuzzy=True)
Traceback (most recent call last):
File "", line 1, in
File "/usr/lib/pymodules/python2.6/dateutil/parser.py", line 697, in parse
return DEFAULTPARSER.parse(timestr, **kwargs)
File "/usr/lib/pymodules/python2.6/dateutil/parser.py", line 301, in parse
res = self._parse(timestr, **kwargs)
File "/usr/lib/pymodules/python2.6/dateutil/parser.py", line 557, in _parse
res.hour += 12
TypeError: unsupported operand type(s) for +=: 'NoneType' and 'int'

Revision history for this message
DragonDave (2-dragon) wrote :

Confirmed.
My problematic strings all start with "PM" - they're not dates, but it doesn't raise an exception for other non-date strings.

My understanding is that the "PM" string is being interpreted as "a time in the afternoon", and thus the number before it is having 12 added to it. This isn't valid if the value before it is None.

I can probably patch this, but will do so only if there is an indication that it'll be acted on.

Changed in dateutil:
status: New → Confirmed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.