Skip to content

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

Closed
caxap opened this Issue Jan 28, 2014 · 4 comments

3 participants

@caxap
caxap commented Jan 28, 2014

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
Owner

Addressed in version 0.5.7.

@dreadatour

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

@derek-schaefer
Owner

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

@dreadatour

Derek, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.