diff --git a/coolamqp/framing/field_table.py b/coolamqp/framing/field_table.py index e797556e486fc92dd505cd7a9c760fb3ed6d65f0..a8188590d4558eb4b4d5d316a2edc15a1642630b 100644 --- a/coolamqp/framing/field_table.py +++ b/coolamqp/framing/field_table.py @@ -30,6 +30,7 @@ def _tobufv(buf, value, pattern, *vals): def _frombuf(pattern, buf, offset): return struct.unpack_from(pattern, buf, offset) + def enframe_decimal(buf, v): # convert decimal to bytes dps = 0 for k in six.moves.xrange(20): @@ -63,6 +64,9 @@ def enframe_longstr(buf, value): _tobufv(buf, value, '!I', len(value)) +def _c2none(buf, v): + return None + FIELD_TYPES = { # length, struct, (option)to_bytes (callable(buffer, value)), # (option)from_bytes (callable(buffer, offset) -> @@ -89,7 +93,7 @@ FIELD_TYPES = { lambda val: len(val) + 4), # longstr 'T': (8, '!Q'), - 'V': (0, None, lambda buf, v: None, lambda buf, ofs: None, 0), + 'V': (0, None, _c2none, _c2none, 0), # rendered as None } diff --git a/coolamqp/uplink/connection/recv_framer.py b/coolamqp/uplink/connection/recv_framer.py index 854990fcd1e8f832872881b53520dbd7201607fd..946e25342eda4a2bb141e0b208b91787bab39387 100644 --- a/coolamqp/uplink/connection/recv_framer.py +++ b/coolamqp/uplink/connection/recv_framer.py @@ -19,10 +19,7 @@ FRAME_TYPES = { } -if six.PY2: - ordpy2 = ord -else: - ordpy2 = lambda x: x +ordpy2 = ord if six.PY2 else lambda x: x class ReceivingFramer(object):