diff --git a/docs/changelog.md b/docs/changelog.md index abbf7bd022baf87b47161bb323eb98e60db8155d..b053ff41a8c702ff27d1517cbb91d163db9424c4 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,6 +1,11 @@ Changelog ========= +Next version +------------ + +* _TBA_ + v2.9 ---- diff --git a/minijson.pyx b/minijson.pyx index b7e9869f899e906db1acddb8ea69e4b192526c9c..a6d9d4b3e6ae0acf6ec4ca5022013bd40da526dd 100644 --- a/minijson.pyx +++ b/minijson.pyx @@ -404,7 +404,7 @@ cdef class MiniJSONEncoder: cio.write(data) elif isinstance(data, str): length = len(data) - if length < 128: + if length <= 0x7F: cio.write(bytearray([0x80 | length])) cio.write(data.encode('utf-8')) return 1+length @@ -423,14 +423,14 @@ cdef class MiniJSONEncoder: cio.write(data.encode('utf-8')) return 5+length elif isinstance(data, int): - if -128 <= data <= 127: # signed char, type 3 + if -0x80 <= data <= 0x7F: # signed char, type 3 cio.write(b'\x03') cio.write(STRUCT_b.pack(data)) return 2 elif 0 <= data <= 255: # unsigned char, type 6 cio.write(bytearray([6, data])) return 2 - elif -32768 <= data <= 32767: # signed short, type 2 + elif -0x8000 <= data <= 0x7FFF: # signed short, type 2 cio.write(b'\x02') cio.write(STRUCT_h.pack(data)) return 3 @@ -442,7 +442,7 @@ cdef class MiniJSONEncoder: cio.write(b'\x0C') cio.write(STRUCT_L.pack(data)[1:]) return 4 - elif -2147483648 <= data <= 2147483647: # signed int, type 1 + elif -0x80000000 <= data <= 0x7FFFFFFF: # signed int, type 1 cio.write(b'\x01') cio.write(STRUCT_l.pack(data)) return 5 @@ -471,13 +471,13 @@ cdef class MiniJSONEncoder: return 5 elif isinstance(data, (tuple, list)): length = len(data) - if length < 16: + if length <= 0xF: cio.write(bytearray([0b01000000 | length])) length = 1 - elif length < 256: + elif length <= 0xFF: cio.write(bytearray([7, length])) length = 2 - elif length < 65536: + elif length <= 0xFFFF: cio.write(b'\x0F') cio.write(STRUCT_H.pack(length)) length = 3 @@ -491,13 +491,13 @@ cdef class MiniJSONEncoder: elif isinstance(data, dict): length = len(data) if can_be_encoded_as_a_dict(data): - if length < 16: + if length <= 0xF: cio.write(bytearray([0b01010000 | length])) length = 1 - elif length < 256: + elif length <= 0xFF: cio.write(bytearray([11, len(data)])) length = 2 - elif length < 65536: + elif length <= 0xFFFF: cio.write(b'\x11') cio.write(STRUCT_H.pack(length)) length = 3 diff --git a/setup.cfg b/setup.cfg index 0b4dc578c3d6adb5e9eab4bdfff344559ce5b958..157a4b7383417e6fda75e5f231359fb5ff69fd1e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ # coding: utf-8 [metadata] -version = 2.9 +version = 2.10a1 name = minijson long_description = file: README.md long_description_content_type = text/markdown; charset=UTF-8