diff options
author | Bob Ippolito <bob@redivi.com> | 2014-05-22 11:56:02 -0700 |
---|---|---|
committer | Bob Ippolito <bob@redivi.com> | 2014-05-22 11:56:02 -0700 |
commit | 1c0ea7f4d3c85cee6904b312922fd50e24e08e78 (patch) | |
tree | a7516126de20b38d8dba61cf8f24a23bb6a29988 | |
parent | 28f1c547909102d2476cca8596f2eac4a7193b65 (diff) | |
download | simplejson-1c0ea7f4d3c85cee6904b312922fd50e24e08e78.tar.gz |
consistently reject int_as_string_bitcount <= 0 #96v3.5.1
-rw-r--r-- | CHANGES.txt | 5 | ||||
-rw-r--r-- | conf.py | 2 | ||||
-rw-r--r-- | setup.py | 2 | ||||
-rw-r--r-- | simplejson/__init__.py | 2 | ||||
-rw-r--r-- | simplejson/encoder.py | 4 | ||||
-rw-r--r-- | simplejson/tests/__init__.py | 1 | ||||
-rw-r--r-- | simplejson/tests/test_bitsize_int_as_string.py | 6 |
7 files changed, 18 insertions, 4 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index 4c599c1..37d2711 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 @@ -44,7 +44,7 @@ copyright = '2014, Bob Ippolito' # 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: @@ -11,7 +11,7 @@ from distutils.errors import CCompilerError, DistutilsExecError, \ 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 ab771ae..3112fd5 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.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 531015a..db18244 100644 --- a/simplejson/encoder.py +++ b/simplejson/encoder.py @@ -401,7 +401,9 @@ def _make_iterencode(markers, _default, _encoder, _indent, _floatstr, 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 5490584..c7551e8 100644 --- a/simplejson/tests/__init__.py +++ b/simplejson/tests/__init__.py @@ -37,6 +37,7 @@ def all_tests_suite(): 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 7bb4d2c..fd7d103 100644 --- a/simplejson/tests/test_bitsize_int_as_string.py +++ b/simplejson/tests/test_bitsize_int_as_string.py @@ -17,6 +17,12 @@ class TestBitSizeIntAsString(TestCase): ((-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), |