diff options
author | Bob Ippolito <bob@redivi.com> | 2015-05-22 09:27:19 -0700 |
---|---|---|
committer | Bob Ippolito <bob@redivi.com> | 2015-05-22 09:27:19 -0700 |
commit | c2190efda0e6fdd6783a56a6aeab818b072350a1 (patch) | |
tree | f22f43f9f2bf9fe2085a955f2728a146e7618e43 | |
parent | 71c3672396b32b62f35c53668182720f8f3d5ecc (diff) | |
download | simplejson-c2190efda0e6fdd6783a56a6aeab818b072350a1.tar.gz |
attempt to work around an issue with reloading the Decimal modulev3.7.2
-rw-r--r-- | CHANGES.txt | 5 | ||||
-rw-r--r-- | conf.py | 4 | ||||
-rw-r--r-- | setup.py | 2 | ||||
-rw-r--r-- | simplejson/__init__.py | 2 | ||||
-rw-r--r-- | simplejson/encoder.py | 11 |
5 files changed, 16 insertions, 8 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index 4403a3f..415ec20 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,8 @@ +Version 3.7.2 released 2015-05-22 + +* Do not cache Decimal class in encoder, only reference the decimal module. + This may make reload work in more common scenarios. + Version 3.7.1 released 2015-05-18 * Fix compilation with MSVC @@ -36,7 +36,7 @@ master_doc = 'index' # General substitutions. project = 'simplejson' -copyright = '2014, Bob Ippolito' +copyright = '2015, Bob Ippolito' # The default replacements for |version| and |release|, also used in various # other places throughout the built documents. @@ -44,7 +44,7 @@ copyright = '2014, Bob Ippolito' # The short X.Y version. version = '3.7' # The full version, including alpha/beta/rc tags. -release = '3.7.1' +release = '3.7.2' # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: @@ -11,7 +11,7 @@ from distutils.errors import CCompilerError, DistutilsExecError, \ DistutilsPlatformError IS_PYPY = hasattr(sys, 'pypy_translation_info') -VERSION = '3.7.1' +VERSION = '3.7.2' DESCRIPTION = "Simple, fast, extensible JSON encoder/decoder for Python" with open('README.rst', 'r') as f: diff --git a/simplejson/__init__.py b/simplejson/__init__.py index 647b5aa..5be65e7 100644 --- a/simplejson/__init__.py +++ b/simplejson/__init__.py @@ -98,7 +98,7 @@ Using simplejson.tool from the shell to validate and pretty-print:: Expecting property name: line 1 column 3 (char 2) """ from __future__ import absolute_import -__version__ = '3.7.1' +__version__ = '3.7.2' __all__ = [ 'dump', 'dumps', 'load', 'loads', 'JSONDecoder', 'JSONDecodeError', 'JSONEncoder', diff --git a/simplejson/encoder.py b/simplejson/encoder.py index 7f0b037..a266333 100644 --- a/simplejson/encoder.py +++ b/simplejson/encoder.py @@ -3,7 +3,8 @@ from __future__ import absolute_import import re from operator import itemgetter -from decimal import Decimal +# Do not import Decimal directly to avoid reload issues +import decimal from .compat import u, unichr, binary_type, string_types, integer_types, PY3 def _import_speedups(): try: @@ -337,7 +338,7 @@ class JSONEncoder(object): self.namedtuple_as_object, self.tuple_as_array, int_as_string_bitcount, self.item_sort_key, self.encoding, self.for_json, - self.ignore_nan, Decimal) + self.ignore_nan, decimal.Decimal) else: _iterencode = _make_iterencode( markers, self.default, _encoder, self.indent, floatstr, @@ -346,7 +347,7 @@ class JSONEncoder(object): self.namedtuple_as_object, self.tuple_as_array, int_as_string_bitcount, self.item_sort_key, self.encoding, self.for_json, - Decimal=Decimal) + Decimal=decimal.Decimal) try: return _iterencode(o, 0) finally: @@ -389,7 +390,7 @@ def _make_iterencode(markers, _default, _encoder, _indent, _floatstr, _PY3=PY3, ValueError=ValueError, string_types=string_types, - Decimal=Decimal, + Decimal=None, dict=dict, float=float, id=id, @@ -399,6 +400,8 @@ def _make_iterencode(markers, _default, _encoder, _indent, _floatstr, str=str, tuple=tuple, ): + if _use_decimal and Decimal is None: + Decimal = decimal.Decimal if _item_sort_key and not callable(_item_sort_key): raise TypeError("item_sort_key must be None or callable") elif _sort_keys and not _item_sort_key: |