|
|
c5093d |
--- anyjson-0.3.3/anyjson/__init__.py 2012-06-21 16:08:51.000000000 -0700
|
|
|
c5093d |
+++ anyjson-0.3.3/anyjson/__init__.py.new 2016-12-24 14:52:05.027940293 -0800
|
|
|
c5093d |
@@ -1,6 +1,7 @@
|
|
|
c5093d |
"""Wraps the best available JSON implementation available in a common
|
|
|
c5093d |
interface"""
|
|
|
c5093d |
|
|
|
c5093d |
+from six import (reraise, string_types)
|
|
|
c5093d |
import sys
|
|
|
c5093d |
|
|
|
c5093d |
VERSION = (0, 3, 3)
|
|
|
c5093d |
@@ -64,9 +65,9 @@
|
|
|
c5093d |
self._encode_error = modinfo["encerror"]
|
|
|
c5093d |
self._decode_error = modinfo["decerror"]
|
|
|
c5093d |
|
|
|
c5093d |
- if isinstance(modinfo["encerror"], basestring):
|
|
|
c5093d |
+ if isinstance(modinfo["encerror"], string_types):
|
|
|
c5093d |
self._encode_error = getattr(module, modinfo["encerror"])
|
|
|
c5093d |
- if isinstance(modinfo["decerror"], basestring):
|
|
|
c5093d |
+ if isinstance(modinfo["decerror"], string_types):
|
|
|
c5093d |
self._decode_error = getattr(module, modinfo["decerror"])
|
|
|
c5093d |
|
|
|
c5093d |
self.name = modinfo["modname"]
|
|
|
c5093d |
@@ -85,8 +86,8 @@
|
|
|
c5093d |
TypeError if the object could not be serialized."""
|
|
|
c5093d |
try:
|
|
|
c5093d |
return self._encode(data)
|
|
|
c5093d |
- except self._encode_error, exc:
|
|
|
c5093d |
- raise TypeError, TypeError(*exc.args), sys.exc_info()[2]
|
|
|
c5093d |
+ except self._encode_error as exc:
|
|
|
c5093d |
+ reraise(TypeError, TypeError(*exc.args), sys.exc_info()[2])
|
|
|
c5093d |
serialize = dumps
|
|
|
c5093d |
|
|
|
c5093d |
def loads(self, s):
|
|
|
c5093d |
@@ -94,11 +95,11 @@
|
|
|
c5093d |
ValueError if the string could not be parsed."""
|
|
|
c5093d |
# uses StringIO to support buffer objects.
|
|
|
c5093d |
try:
|
|
|
c5093d |
- if self._filedecode and not isinstance(s, basestring):
|
|
|
c5093d |
+ if self._filedecode and not isinstance(s, string_types):
|
|
|
c5093d |
return self._filedecode(StringIO(s))
|
|
|
c5093d |
return self._decode(s)
|
|
|
c5093d |
- except self._decode_error, exc:
|
|
|
c5093d |
- raise ValueError, ValueError(*exc.args), sys.exc_info()[2]
|
|
|
c5093d |
+ except self._decode_error as exc:
|
|
|
c5093d |
+ reraise(ValueError, ValueError(*exc.args), sys.exc_info()[2])
|
|
|
c5093d |
deserialize = loads
|
|
|
c5093d |
|
|
|
c5093d |
|
|
|
c5093d |
@@ -117,8 +118,7 @@
|
|
|
c5093d |
# We do NOT try to load a compatible module because that may throw an
|
|
|
c5093d |
# exception, which renders the package uninstallable with easy_install
|
|
|
c5093d |
# (It trys to execfile the script when installing, to make sure it works)
|
|
|
c5093d |
- print "Running anyjson as a stand alone script is not supported"
|
|
|
c5093d |
- sys.exit(1)
|
|
|
c5093d |
+ sys.exit("Running anyjson as a stand alone script is not supported")
|
|
|
c5093d |
else:
|
|
|
c5093d |
for modspec in _modules:
|
|
|
c5093d |
try:
|