SnakeBridge.SerializationError exception (SnakeBridge v0.7.4)
View SourceRaised when attempting to encode a value that cannot be serialized for Python.
SnakeBridge supports encoding:
- Primitives:
nil, booleans, integers, floats, strings - Collections: lists, maps, tuples, MapSets
- Special types: atoms, DateTime, Date, Time, SnakeBridge.Bytes
- References: SnakeBridge.Ref, SnakeBridge.StreamRef
- Functions: anonymous functions (as callbacks)
- Special floats:
:infinity,:neg_infinity,:nan
Types that cannot be serialized:
- PIDs, ports, references
- Custom structs without serialization support
- File handles, sockets, other system resources
Resolution
For unsupported types, you have several options:
Create a Python object and pass the ref:
{:ok, ref} = SnakeBridge.call("module", "create_object", [...]) SnakeBridge.call("module", "use_object", [ref])Convert to a supported type:
# Instead of passing a PID SnakeBridge.call("module", "fn", [inspect(pid)]) # Or extract relevant data SnakeBridge.call("module", "fn", [pid_to_list(pid)])Use explicit bytes for binary data:
SnakeBridge.call("module", "fn", [SnakeBridge.bytes(binary)])
Summary
Functions
Creates a SerializationError from a message string.