/lib/django-1.5/django/utils/simplejson.py

https://github.com/theosp/google_appengine · Python · 31 lines · 18 code · 5 blank · 8 comment · 5 complexity · 41fa2a6a10c1604c24be886451bf2d81 MD5 · raw file

  1. # Django 1.5 only supports Python >= 2.6, where the standard library includes
  2. # the json module. Previous version of Django shipped a copy for Python < 2.6.
  3. # For backwards compatibility, we're keeping an importable json module
  4. # at this location, with the same lookup sequence.
  5. # Avoid shadowing the simplejson module
  6. from __future__ import absolute_import
  7. import warnings
  8. warnings.warn("django.utils.simplejson is deprecated; use json instead.",
  9. PendingDeprecationWarning)
  10. try:
  11. import simplejson
  12. except ImportError:
  13. use_simplejson = False
  14. else:
  15. # The system-installed version has priority providing it is either not an
  16. # earlier version or it contains the C speedups.
  17. from json import __version__ as stdlib_json_version
  18. use_simplejson = (hasattr(simplejson, '_speedups') or
  19. simplejson.__version__.split('.') >= stdlib_json_version.split('.'))
  20. # Make sure we copy over the version. See #17071
  21. if use_simplejson:
  22. from simplejson import *
  23. from simplejson import __version__
  24. else:
  25. from json import *
  26. from json import __version__