Opened 6 years ago

Closed 6 years ago

#13526 closed (invalid)

JSONDecoder raise AttributeError with simplejson 2.1.1

Reported by: oxys Owned by: nobody
Component: Core (Other) Version: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


To reproduce, setup simplejson 2.1.1

$ python
Python 2.6.1 (r261:67515, Feb 11 2010, 00:51:29) 
>>> from django.utils.simplejson.decoder import JSONDecoder
>>> JSONDecoder()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/me/Code/Django/django_trunk/django/utils/simplejson/", line 319, in __init__
    self.scan_once = make_scanner(self)
AttributeError: 'JSONDecoder' object has no attribute 'object_pairs_hook'

Patch :

Index: django/utils/simplejson/
--- django/utils/simplejson/  (revision 13238)
+++ django/utils/simplejson/  (working copy)
@@ -3,6 +3,10 @@
 import re
     from simplejson._speedups import make_scanner as c_make_scanner
+    from simplejson import __version__ as speedups_version
+    from . import __version__
+    if speedups_version != __version__:
+        c_make_scanner = None
 except ImportError:
     c_make_scanner = None

Change History (2)

comment:1 Changed 6 years ago by oxys

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 6 years ago by russellm

  • Resolution set to invalid
  • Status changed from new to closed

The way you are deep importing into the simplejson module is preventing Django's simplejson support infrastructure from providing a complete simplejson install.

Correct usage is:

>>> from django.utils import simplejson
>>> simplejson.JSONDecoder()
Note: See TracTickets for help on using tickets.
Back to Top