TypeError: 'NoneType' object is not iterable - for string that begins with date, but not represent date
caxap opened this issue · comments
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
Addressed in version 0.5.7.
Could you, please, also update pypi package?
https://pypi.python.org/simple/django-json-field/ - no version 0.5.7 available.
Looks like the version was registered but the distribution wasn't available for whatever reason. Should be fixed now.
Derek, thank you!