Should use stdlib json in django 1.5+ #1517

Closed
craigds opened this Issue Nov 15, 2012 · 5 comments

Projects

None yet

5 participants

@craigds
Contributor
craigds commented Nov 15, 2012
In [6]: from cms.templatetags.cms_js_tags import *
js
In [7]: js('hi')
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (3, 0))

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

/home/cdestigter/<ipython console> in <module>()

/home/cdestigter/checkout/django-cms/cms/templatetags/cms_js_tags.pyc in js(value)
     10 @register.filter
     11 def js(value):
---> 12     return simplejson.dumps(value, cls=DjangoJSONEncoder)
     13 
     14 @register.filter

/usr/lib/pymodules/python2.6/simplejson/__init__.pyc in dumps(obj, skipkeys, ensure_ascii, check_circular, allow_nan, cls, indent, separators, encoding, default, use_decimal, **kw)
    267         check_circular=check_circular, allow_nan=allow_nan, indent=indent,
    268         separators=separators, encoding=encoding, default=default,
--> 269         use_decimal=use_decimal, **kw).encode(obj)
    270 
    271 

TypeError: __init__() got an unexpected keyword argument 'use_decimal'

This occurs with python 2.6 (json.__version__ == '1.9') and simplejson 2.1.6 installed.
In django 1.5 the DjangoJSONEncoder is a subclass of json.JSONEncoder from the stdlib json. However django-cms uses django.utils.simplejson, which is actually simplejson instead of the stdlib json, and that expects the DjangoJSONEncoder constructor to accept a use_decimal kwarg.

@craigds craigds added a commit to koordinates/django-cms that referenced this issue Nov 15, 2012
@craigds craigds use stdlib json instead of django.utils.simplejson when using django …
…1.5+ . refs divio/django-cms#1517
355ef62
Member
digi604 commented Jul 11, 2013

could you open a pull request for this?

Contributor
yakky commented Jul 11, 2013

Also, this is part of the django 1.6 support PR #1995

@czpython czpython was assigned Aug 30, 2013
Contributor
meshy commented Dec 22, 2013

The referenced PR has been merged, so I presume this has been resolved and can be closed.

Contributor
yakky commented Dec 22, 2013

Thanks for the reminder :)

@yakky yakky closed this Dec 22, 2013
Contributor
meshy commented Dec 22, 2013

No problem ;)

@czpython czpython removed their assignment Jun 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment