Fuzzy parser fails if string starts with "p" in some cases

Bug #1056503 reported by Jesse Wakeley
This bug report is a duplicate of:  Bug #1071212: parser breaks with bad input. Edit Remove
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
dateutil
New
Undecided
Unassigned

Bug Description

Code like the following:

test_string = """p
   This is a test with a date: Tuesday, September 25, 2012"""
date = parser.parse(test_string, fuzzy=True)

returns something similar to this:

          File "/home/blahblah/code.py", line 33, in parse
            date = parser.parse(event_info, fuzzy=True)
          File "/home/blahblah//lib/python2.6/site-packages/dateutil/parser.py", line 720, in parse
            return DEFAULTPARSER.parse(timestr, **kwargs)
          File "/home/blahblah/lib/python2.6/site-packages/dateutil/parser.py", line 308, in parse
            res = self._parse(timestr, **kwargs)
          File "/home/blahblah/lib/python2.6/site-packages/dateutil/parser.py", line 575, in _parse
            res.hour += 12
        exceptions.TypeError: unsupported operand type(s) for +=: 'NoneType' and 'int'

Removing the newline then causes it to work:

event_info = """pThis is a test with a date: Tuesday, September 25, 2012"""

Other characters directly after the "p", such as a space, or ">", will also cause it to fail

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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