Opened 16 years ago
Closed 16 years ago
#13526 closed (invalid)
JSONDecoder raise AttributeError with simplejson 2.1.1
| Reported by: | oxys | Owned by: | nobody |
|---|---|---|---|
| Component: | Core (Other) | Version: | dev |
| Severity: | Keywords: | ||
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
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/decoder.py", line 319, in __init__
self.scan_once = make_scanner(self)
AttributeError: 'JSONDecoder' object has no attribute 'object_pairs_hook'
Patch :
Index: django/utils/simplejson/scanner.py
===================================================================
--- django/utils/simplejson/scanner.py (revision 13238)
+++ django/utils/simplejson/scanner.py (working copy)
@@ -3,6 +3,10 @@
import re
try:
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 by , 16 years ago
comment:2 by , 16 years ago
| Resolution: | → invalid |
|---|---|
| Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
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: