summaryrefslogtreecommitdiff
path: root/django/core
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2012-04-29 19:58:00 +0200
committerAymeric Augustin <aymeric.augustin@m4x.org>2012-04-29 19:58:00 +0200
commitcec6bd5a59547dc97fe98975c570fc27a1e970be (patch)
treed084ff2008e4bba125c4b28297d6469992f2ec95 /django/core
parentee0a7c741e98214bac7eeb60b848cf099ff28836 (diff)
Fixed #18023 -- Removed bundled simplejson.
And started the deprecation path for django.utils.simplejson. Thanks Alex Ogier, Clueless, and other contributors for their work on the patch.
Diffstat (limited to 'django/core')
-rw-r--r--django/core/serializers/json.py13
-rw-r--r--django/core/signing.py9
2 files changed, 13 insertions, 9 deletions
diff --git a/django/core/serializers/json.py b/django/core/serializers/json.py
index 91af84e9ca..ab0cd0e590 100644
--- a/django/core/serializers/json.py
+++ b/django/core/serializers/json.py
@@ -2,14 +2,17 @@
Serialize data to/from JSON
"""
+# Avoid shadowing the standard library json module
+from __future__ import absolute_import
+
import datetime
import decimal
+import json
from StringIO import StringIO
from django.core.serializers.base import DeserializationError
from django.core.serializers.python import Serializer as PythonSerializer
from django.core.serializers.python import Deserializer as PythonDeserializer
-from django.utils import simplejson
from django.utils.timezone import is_aware
class Serializer(PythonSerializer):
@@ -19,10 +22,10 @@ class Serializer(PythonSerializer):
internal_use_only = False
def end_serialization(self):
- if simplejson.__version__.split('.') >= ['2', '1', '3']:
+ if json.__version__.split('.') >= ['2', '1', '3']:
# Use JS strings to represent Python Decimal instances (ticket #16850)
self.options.update({'use_decimal': False})
- simplejson.dump(self.objects, self.stream, cls=DjangoJSONEncoder, **self.options)
+ json.dump(self.objects, self.stream, cls=DjangoJSONEncoder, **self.options)
def getvalue(self):
if callable(getattr(self.stream, 'getvalue', None)):
@@ -38,7 +41,7 @@ def Deserializer(stream_or_string, **options):
else:
stream = stream_or_string
try:
- for obj in PythonDeserializer(simplejson.load(stream), **options):
+ for obj in PythonDeserializer(json.load(stream), **options):
yield obj
except GeneratorExit:
raise
@@ -47,7 +50,7 @@ def Deserializer(stream_or_string, **options):
raise DeserializationError(e)
-class DjangoJSONEncoder(simplejson.JSONEncoder):
+class DjangoJSONEncoder(json.JSONEncoder):
"""
JSONEncoder subclass that knows how to encode date/time and decimal types.
"""
diff --git a/django/core/signing.py b/django/core/signing.py
index 7f92d61098..f2c79de706 100644
--- a/django/core/signing.py
+++ b/django/core/signing.py
@@ -33,12 +33,13 @@ There are 65 url-safe characters: the 64 used by url-safe base64 and the ':'.
These functions make use of all of them.
"""
import base64
+import json
import time
import zlib
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
-from django.utils import baseconv, simplejson
+from django.utils import baseconv
from django.utils.crypto import constant_time_compare, salted_hmac
from django.utils.encoding import force_unicode, smart_str
from django.utils.importlib import import_module
@@ -89,14 +90,14 @@ def get_cookie_signer(salt='django.core.signing.get_cookie_signer'):
class JSONSerializer(object):
"""
- Simple wrapper around simplejson to be used in signing.dumps and
+ Simple wrapper around json to be used in signing.dumps and
signing.loads.
"""
def dumps(self, obj):
- return simplejson.dumps(obj, separators=(',', ':'))
+ return json.dumps(obj, separators=(',', ':'))
def loads(self, data):
- return simplejson.loads(data)
+ return json.loads(data)
def dumps(obj, key=None, salt='django.core.signing', serializer=JSONSerializer, compress=False):