Under both Python 2.7 and 3.3.5, I am trying to parse a string to date.
>>> from dateutil import parser
>>> parser.parse("On")
datetime.datetime(2014, 12, 25, 0, 0)
Today is 2014-12-25, so it appears the result is today when parsing "On" (case insensitive). Is this behavior correct?
In fact, I would like this parse to raise an exception, as I don't think "On" is a valid date. How should I "correct" the behavior to my expectation? I mean not checking the input as "On", because I don't know if any other string like 'On' will surprise me again.
For some special case, even set 'fuzzy=False', the parse returns today without an exception. For example:
>>> parser.parse("' '", fuzzy=False)
datetime.datetime(2014, 12, 25, 0, 0)
Based on the feedback, it seems a possible workaround can be given a rarely used default date. Compare the result to see if parse is success or not.
>>> parser.parse("' '", fuzzy=False, default=datetime(1900,1,1))