forked from goodboy/tractor
1
0
Fork 0

Use `str` | `bytes` union for typing msg dump

drop_msgpack
Tyler Goodlet 2022-07-11 09:42:26 -04:00
parent 5168700fbf
commit 41983edc43
1 changed files with 3 additions and 3 deletions

View File

@ -186,14 +186,14 @@ class MsgpackTCPStream(MsgTransport):
# do with a channel drop - hope that receiving from the # do with a channel drop - hope that receiving from the
# channel will raise an expected error and bubble up. # channel will raise an expected error and bubble up.
try: try:
data = msg_bytes.decode() msg_str: str | bytes = msg_bytes.decode()
except UnicodeDecodeError: except UnicodeDecodeError:
data = msg_bytes msg_str = msg_bytes
log.error( log.error(
'`msgspec` failed to decode!?\n' '`msgspec` failed to decode!?\n'
'dumping bytes:\n' 'dumping bytes:\n'
f'{data}' f'{msg_str!r}'
) )
decodes_failed += 1 decodes_failed += 1
else: else: