blaze / datashape

Language defining a data description protocol
BSD 2-Clause "Simplified" License
183 stars 65 forks source link

Add test for string that looks like a date #140

Closed cpcloud closed 9 years ago

cpcloud commented 9 years ago

closes #91

detrout commented 9 years ago

This test fails when running tests on Debian using python 2.7.10, python-dateutil 2.2, and multipledispatch 0.4.7.

My stack trace looks like this:

In [6]: discover('31-DEC-99 12.00.00.000000000')
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-6-26d0b3c97dd5> in <module>()
----> 1 discover('31-DEC-99 12.00.00.000000000')

/usr/lib/python2.7/dist-packages/multipledispatch/dispatcher.pyc in __call__(self, *args, **kwargs)
    162             self._cache[types] = func
    163         try:
--> 164             return func(*args, **kwargs)
    165 
    166         except MDNotImplementedError:

/home/diane/src/bokeh/datashape/datashape/discovery.pyc in discover(s)
    184 
    185     try:
--> 186         d = dateparse(s)
    187     except ValueError:
    188         pass

/usr/lib/python2.7/dist-packages/dateutil/parser.pyc in parse(timestr, parserinfo, **kwargs)
    746         return parser(parserinfo).parse(timestr, **kwargs)
    747     else:
--> 748         return DEFAULTPARSER.parse(timestr, **kwargs)
    749 
    750 

/usr/lib/python2.7/dist-packages/dateutil/parser.pyc in parse(self, timestr, default, ignoretz, tzinfos, **kwargs)                                                                                                
    308 
    309 
--> 310         res, skipped_tokens = self._parse(timestr, **kwargs)
    311 
    312         if res is None:

TypeError: 'NoneType' object is not iterable

My quick solution was this patch:

    --- a/datashape/discovery.py
    +++ b/datashape/discovery.py
    @@ -184,7 +184,7 @@ def discover(s):

         try:
             d = dateparse(s)
    -    except ValueError:
    +    except (ValueError, TypeError):
             pass
         else:
             return date_ if not d.time() else datetime_