Skip numpy types serialization errors on Message.Encoder.

This commit is contained in:
Fabio Manganiello 2023-10-06 22:54:19 +02:00
parent e5a5ac5ffb
commit 9acd71944c
Signed by: blacklight
GPG key ID: D90FBA7F76362774

View file

@ -34,8 +34,6 @@ class Message:
def parse_numpy(obj): def parse_numpy(obj):
try: try:
import numpy as np import numpy as np
except ImportError:
return
if isinstance(obj, np.floating): if isinstance(obj, np.floating):
return float(obj) return float(obj)
@ -49,6 +47,8 @@ class Message:
return '0x' + ''.join([f'{x:02x}' for x in obj]) return '0x' + ''.join([f'{x:02x}' for x in obj])
if callable(obj): if callable(obj):
return '<function at {}.{}>'.format(obj.__module__, obj.__name__) return '<function at {}.{}>'.format(obj.__module__, obj.__name__)
except (ImportError, TypeError):
pass
return return