derek-schaefer / django-json-field

Generic JSON model and form fields.
BSD 3-Clause "New" or "Revised" License
122 stars 86 forks source link

TypeError: 'NoneType' object is not iterable - for string that begins with date, but not represent date #33

Closed caxap closed 10 years ago

caxap commented 10 years ago

Steps to reproduce

>>> import json_field, dateutil
>>> json_field.__version__
'0.5.4'
>>> dateutil.__version__
'2.2'
>>> from json_field.fields import JSONDecoder
>>> from django.utils import simplejson as json
>>>
>>> json_payload = '{"title": "2014-01-27 | Title with date"}'
>>>
>>> json.loads(json_payload)  # default decoder - OK
{u'title': u'2014-01-27 | Title with date'}
>>>
>>> json.loads(json_payload, cls=JSONDecoder)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 351, in loads
    return cls(encoding=encoding, **kw).decode(s)
  File "/Users/caxap/Work/pd/api/venv/lib/python2.7/site-packages/json_field/fields.py", line 76, in decode
    obj[key] = self.decode(value, recurse=True)
  File "/Users/caxap/Work/pd/api/venv/lib/python2.7/site-packages/json_field/fields.py", line 85, in decode
    return date_parser.parse(obj).date()
  File "/Users/caxap/Work/pd/api/venv/lib/python2.7/site-packages/dateutil/parser.py", line 748, in parse
    return DEFAULTPARSER.parse(timestr, **kwargs)
  File "/Users/caxap/Work/pd/api/venv/lib/python2.7/site-packages/dateutil/parser.py", line 310, in parse
    res, skipped_tokens = self._parse(timestr, **kwargs)
TypeError: 'NoneType' object is not iterable
derek-schaefer commented 10 years ago

Addressed in version 0.5.7.

dreadatour commented 10 years ago

Could you, please, also update pypi package? https://pypi.python.org/simple/django-json-field/ - no version 0.5.7 available.

derek-schaefer commented 10 years ago

Looks like the version was registered but the distribution wasn't available for whatever reason. Should be fixed now.

dreadatour commented 10 years ago

Derek, thank you!