diff options
author | Omer Katz <omer.drow@gmail.com> | 2019-03-02 11:55:31 +0200 |
---|---|---|
committer | Asif Saif Uddin <auvipy@gmail.com> | 2019-03-02 15:55:31 +0600 |
commit | 68b880070dc92f0b139c089cff154a3522a7504a (patch) | |
tree | 701798d9fa169595447235c93e3e08a0e4715acf | |
parent | e3bf8c2c39388567d7105a41616b346d3992ffa8 (diff) | |
download | py-amqp-68b880070dc92f0b139c089cff154a3522a7504a.tar.gz |
The bitcount will reset only when we move to the next byte. (#260)
Add a test to verify that parsing two consecutive bitmaps does not fail.
-rw-r--r-- | amqp/serialization.py | 3 | ||||
-rw-r--r-- | t/unit/test_serialization.py | 7 |
2 files changed, 8 insertions, 2 deletions
diff --git a/amqp/serialization.py b/amqp/serialization.py index 183ae2e..758a3c0 100644 --- a/amqp/serialization.py +++ b/amqp/serialization.py @@ -172,11 +172,10 @@ def loads(format, buf, offset=0, if not bitcount: bits = ord(buf[offset:offset + 1]) offset += 1 - bitcount = 8 + bitcount = 8 val = (bits & 1) == 1 bits >>= 1 bitcount -= 1 - elif p == 'o': bitcount = bits = 0 val, = unpack_from('>B', buf, offset) diff --git a/t/unit/test_serialization.py b/t/unit/test_serialization.py index 88838a8..9a3a0bf 100644 --- a/t/unit/test_serialization.py +++ b/t/unit/test_serialization.py @@ -112,6 +112,13 @@ class test_serialization: actual, _ = loads('BssbbbbbF', buf) assert actual == expected + def test_sixteen_bitflags(self): + expected = [True, False] * 8 + format = 'b' * len(expected) + buf = dumps(format, expected) + actual, _ = loads(format, buf) + assert actual == expected + class test_GenericContent: |