diff --git a/CHANGELOG.md b/CHANGELOG.md index 8733a44ce1880d7f7220b2f52577e7f73380f5b3..6713db68e99805f980556b3b5dd0543ab01a13c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,3 +3,4 @@ here's only the changelog for the version in development # v1.7 +* I totally forgot about booleans! diff --git a/docs/conf.py b/docs/conf.py index fb6fa39b814d6097c1639a180d827f56e1158efa..429e388b6934abffc4c71a033e8d0fa719052d90 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -22,7 +22,7 @@ copyright = '2021 Dronehub Group sp. z o. o.' author = 'Piotr MaĹlanka' # The full version, including alpha/beta/rc tags -release = '1.3' +release = '1.7' # -- General configuration --------------------------------------------------- diff --git a/docs/specification.rst b/docs/specification.rst index a64aebecb78968f92c3021f994b74a8bcaaa5e18..5fc538db0da4161e0362c8d9c0856e882501ce1c 100644 --- a/docs/specification.rst +++ b/docs/specification.rst @@ -61,3 +61,5 @@ Type Value consists of: and then follow that many pairs of Values (key: value) * If value is 21, then next data is an unsigned short, and then follow that many pairs of Values (key: value) +* If value is 22, then it's True +* If value is 23, then it's False diff --git a/minijson/routines.pyx b/minijson/routines.pyx index 4447b043dda408d2526ce0824361028e31563ec1..bce59dea4bff6c8079dd859c20b1c383096a7eea 100644 --- a/minijson/routines.pyx +++ b/minijson/routines.pyx @@ -255,7 +255,12 @@ cpdef tuple parse(bytes data, int starting_position): elements, = STRUCT_H.unpack(data[starting_position+1:starting_position+3]) offset, e_dict = parse_sdict(data, elements, starting_position+3) return offset+3, e_dict - raise DecodingError('Unknown sequence type %s!' % (value_type, )) + elif value_type == 22: + return 1, True + elif value_type == 23: + return 1, False + else: + raise DecodingError('Unknown sequence type %s!' % (value_type, )) except (IndexError, struct.error) as e: raise DecodingError('String too short!') from e @@ -285,6 +290,12 @@ cpdef int dump(object data, cio: io.BytesIO) except -1: if data is None: cio.write(b'\x08') return 1 + elif data is True: + cio.write(b'\x16') + return 1 + elif data is False: + cio.write(b'\x17') + return 1 elif isinstance(data, str): length = len(data) if length < 128: diff --git a/setup.py b/setup.py index bc8e610b8aec47b989039619a3a6a5d163032d7a..e3b13263832224297f35aa99b8a835852dc66714 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ if 'DEBUG' in os.environ: directives['embedsignature'] = True -setup(version='1.7a1', +setup(version='1.7', packages=find_packages(include=['minijson', 'minijson.*']), ext_modules=build([Multibuild('minijson', find_pyx('minijson'), dont_snakehouse=dont_snakehouse), ], diff --git a/tests/test_minijson.py b/tests/test_minijson.py index 55dd3ea5c83e08e63e389791a4ad0c809ef901ef..522349e2e8b3ce4cd2fdedd3bf30e4a8d7bcab74 100644 --- a/tests/test_minijson.py +++ b/tests/test_minijson.py @@ -26,6 +26,10 @@ class TestMiniJSON(unittest.TestCase): a[i] = i self.assertSameAfterDumpsAndLoads(a) + def test_booleans(self): + self.assertSameAfterDumpsAndLoads({'test': True, + 'test2': False}) + def test_string(self): a = 'test' b = 't'*128