Skip to content

Commit 560baac

Browse files
committed
fix blobdispatch and annotation data type problem
1 parent 2a825de commit 560baac

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@
1010
/.cache/
1111
/.eggs/
1212
/.mypy_cache/
13+
/.pytest_cache/

Pyro5/client.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,8 @@ def deserialized(self):
651651
if self._contains_blob:
652652
protocol_msg = self._data
653653
serializer = serializers.serializers_by_id[protocol_msg.serializer_id]
654-
return serializer.loads(protocol_msg.data)
654+
_, _, data, _ = serializer.loads(protocol_msg.data)
655+
return data
655656
else:
656657
return self._data
657658

Pyro5/protocol.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ def __init__(self, msgtype, flags, seq, serializer_id, payload, annotations=None
9797
if len(k) != 4:
9898
raise errors.ProtocolError("annotation identifier must be 4 ascii characters")
9999
annotation_data.append(struct.pack("!4sI", k.encode("ascii"), len(v)))
100-
if not isinstance(v, (bytes, bytearray)):
101-
raise errors.ProtocolError("annotation data must be bytes")
100+
if not isinstance(v, (bytes, bytearray, memoryview)):
101+
raise errors.ProtocolError("annotation data must be bytes, bytearray, or memoryview", type(v))
102102
annotation_data.append(v) # note: annotations are not compressed by Pyro
103103
self.data = header_data + b"".join(annotation_data) + payload
104104

examples/blob-dispatch/client/client.py

-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,5 @@
1818
break
1919
# create our custom data object and send it through the dispatcher
2020
data = CustomData(42, "hello world", datetime.datetime.now())
21-
22-
# @todo FIX THIS -- CRASHES WITH SOCKET ERROR NOT ENOUGH DATA
2321
dispatcher.process_blob(Pyro5.api.SerializedBlob(topic, data))
2422
print("processed")

0 commit comments

Comments
 (0)