diff --git a/coolamqp/framing/compilation/compile_definitions.py b/coolamqp/framing/compilation/compile_definitions.py index 4c8d5bebd33cba48912b2b9a353ab724036dd6d9..cdfae03c73feca38b0c1e15daa746ad9442184e1 100644 --- a/coolamqp/framing/compilation/compile_definitions.py +++ b/coolamqp/framing/compilation/compile_definitions.py @@ -50,6 +50,9 @@ CoolAMQP is copyright (c) 2016 DMS Serwis s.c. # # # this has some use - speed :D # ########################################################### +tl;dr - you received something and it's supposed to be a +binary string? It's a memoryview all right. +Only thing that isn't are field names in tables. """ import struct, collections, warnings, logging, six @@ -302,7 +305,7 @@ Field = collections.namedtuple('Field', ('name', 'type', 'basic_type', 'reserved while ord(buf[offset + pfl - 1]) & 1: pfl += 2 else: - while buf[offset + pfl - 1]) & 1: + while buf[offset + pfl - 1] & 1: pfl += 2 zpf = %s.zero_property_flags(buf[offset:offset+pfl]).tobytes() if zpf in %s.PARTICULAR_CLASSES: diff --git a/coolamqp/framing/definitions.py b/coolamqp/framing/definitions.py index 8a9e7d8cb9f56227ac7d587864c5361ac5819f6c..e387a50b53f813f3f2e4f10d25d7879806fb5e30 100644 --- a/coolamqp/framing/definitions.py +++ b/coolamqp/framing/definitions.py @@ -10,13 +10,17 @@ AMQP is copyright (c) 2016 OASIS CoolAMQP is copyright (c) 2016 DMS Serwis s.c. -########################################### -# IMPORTANT NOTE -# Type of field may depend on the origin of packet. -# strings will be memoryviews if we received the packet -# while they may be bytes if we created it -# -# this has some use - speed :D +########################################################### +# IMPORTANT NOTE # +# Type of field may depend on the origin of packet. # +# strings will be memoryviews if we received the packet # +# while they may be bytes if we created it # +# # +# this has some use - speed :D # +########################################################### +tl;dr - you received something and it's supposed to be a +binary string? It's a memoryview all right. +Only thing that isn't are field names in tables. """ import struct, collections, warnings, logging, six @@ -2424,8 +2428,12 @@ class BasicContentPropertyList(AMQPContentPropertyList): """ # extract property flags pfl = 2 - while ord(buf[offset + pfl - 1]) & 1: - pfl += 2 + if six.PY2: + while ord(buf[offset + pfl - 1]) & 1: + pfl += 2 + else: + while buf[offset + pfl - 1] & 1: + pfl += 2 zpf = BasicContentPropertyList.zero_property_flags(buf[offset:offset+pfl]).tobytes() if zpf in BasicContentPropertyList.PARTICULAR_CLASSES: return BasicContentPropertyList.PARTICULAR_CLASSES[zpf].from_buffer(buf, offset)