Skip to content

Commit 8a2cabb

Browse files
committed
fix: add default_encoder fallback to msgpack.packb in write_frame
numpy dtype objects are not MessagePack-serializable and caused TypeError when calling getAttr('dtype'). The default_encoder fallback converts non-serializable objects to str() to prevent crashes.
1 parent 4d050de commit 8a2cabb

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

  • python-embed-runtime/src/main/resources/io/github/howtis/pythonembed

python-embed-runtime/src/main/resources/io/github/howtis/pythonembed/bridge.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ def read_frame(stream):
444444

445445
def write_frame(stream, obj):
446446
"""Write a dict as a length-prefixed MessagePack frame to a binary stream."""
447-
data = msgpack.packb(obj)
447+
data = msgpack.packb(obj, default=default_encoder)
448448
length = len(data)
449449
stream.write(struct.pack('>I', length))
450450
stream.write(data)

0 commit comments

Comments
 (0)