diff --git a/CHANGES.txt b/CHANGES.txt index c8b89d3a1f7b627c7e78edf55b938173b0be5a7c_Q0hBTkdFUy50eHQ=..57ae20fdf8f921b0e8172c0665ed71fbf14cd86c_Q0hBTkdFUy50eHQ= 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,8 @@ +Version 3.5.1 released 2014-05-21 + +* Consistently reject int_as_string_bitcount settings that are not + positive integers + Version 3.5.0 released 2014-05-20 * Added int_as_string_bitcount encoder option diff --git a/conf.py b/conf.py index c8b89d3a1f7b627c7e78edf55b938173b0be5a7c_Y29uZi5weQ==..57ae20fdf8f921b0e8172c0665ed71fbf14cd86c_Y29uZi5weQ== 100644 --- a/conf.py +++ b/conf.py @@ -44,7 +44,7 @@ # The short X.Y version. version = '3.5' # The full version, including alpha/beta/rc tags. -release = '3.5.0' +release = '3.5.1' # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: diff --git a/setup.py b/setup.py index c8b89d3a1f7b627c7e78edf55b938173b0be5a7c_c2V0dXAucHk=..57ae20fdf8f921b0e8172c0665ed71fbf14cd86c_c2V0dXAucHk= 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ DistutilsPlatformError IS_PYPY = hasattr(sys, 'pypy_translation_info') -VERSION = '3.5.0' +VERSION = '3.5.1' 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 c8b89d3a1f7b627c7e78edf55b938173b0be5a7c_c2ltcGxlanNvbi9fX2luaXRfXy5weQ==..57ae20fdf8f921b0e8172c0665ed71fbf14cd86c_c2ltcGxlanNvbi9fX2luaXRfXy5weQ== 100644 --- a/simplejson/__init__.py +++ b/simplejson/__init__.py @@ -98,7 +98,7 @@ Expecting property name: line 1 column 3 (char 2) """ from __future__ import absolute_import -__version__ = '3.5.0' +__version__ = '3.5.1' __all__ = [ 'dump', 'dumps', 'load', 'loads', 'JSONDecoder', 'JSONDecodeError', 'JSONEncoder', diff --git a/simplejson/encoder.py b/simplejson/encoder.py index c8b89d3a1f7b627c7e78edf55b938173b0be5a7c_c2ltcGxlanNvbi9lbmNvZGVyLnB5..57ae20fdf8f921b0e8172c0665ed71fbf14cd86c_c2ltcGxlanNvbi9lbmNvZGVyLnB5 100644 --- a/simplejson/encoder.py +++ b/simplejson/encoder.py @@ -401,7 +401,9 @@ elif _sort_keys and not _item_sort_key: _item_sort_key = itemgetter(0) - if _int_as_string_bitcount is not None and _int_as_string_bitcount < 0: + if (_int_as_string_bitcount is not None and + (_int_as_string_bitcount <= 0 or + not isinstance(_int_as_string_bitcount, integer_types))): raise TypeError("int_as_string_bitcount must be a positive integer") def _encode_int(value): diff --git a/simplejson/tests/__init__.py b/simplejson/tests/__init__.py index c8b89d3a1f7b627c7e78edf55b938173b0be5a7c_c2ltcGxlanNvbi90ZXN0cy9fX2luaXRfXy5weQ==..57ae20fdf8f921b0e8172c0665ed71fbf14cd86c_c2ltcGxlanNvbi90ZXN0cy9fX2luaXRfXy5weQ== 100644 --- a/simplejson/tests/__init__.py +++ b/simplejson/tests/__init__.py @@ -37,6 +37,7 @@ def get_suite(): return additional_tests( unittest.TestLoader().loadTestsFromNames([ + 'simplejson.tests.test_bitsize_int_as_string', 'simplejson.tests.test_bigint_as_string', 'simplejson.tests.test_check_circular', 'simplejson.tests.test_decode', diff --git a/simplejson/tests/test_bitsize_int_as_string.py b/simplejson/tests/test_bitsize_int_as_string.py index c8b89d3a1f7b627c7e78edf55b938173b0be5a7c_c2ltcGxlanNvbi90ZXN0cy90ZXN0X2JpdHNpemVfaW50X2FzX3N0cmluZy5weQ==..57ae20fdf8f921b0e8172c0665ed71fbf14cd86c_c2ltcGxlanNvbi90ZXN0cy90ZXN0X2JpdHNpemVfaW50X2FzX3N0cmluZy5weQ== 100644 --- a/simplejson/tests/test_bitsize_int_as_string.py +++ b/simplejson/tests/test_bitsize_int_as_string.py @@ -17,6 +17,12 @@ ((-1 << 31) + 1, (-1 << 31) + 1), ] + def test_invalid_counts(self): + for n in ['foo', -1, 0, 1.0]: + self.assertRaises( + TypeError, + json.dumps, 0, int_as_string_bitcount=n) + def test_ints_outside_range_fails(self): self.assertNotEqual( str(1 << 15),