Use `str` | `bytes` union for typing msg dump
parent
5168700fbf
commit
41983edc43
|
@ -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:
|
||||||
|
|
Loading…
Reference in New Issue