Skip to content

Commit

Permalink
Fix is_bencoded
Browse files Browse the repository at this point in the history
  • Loading branch information
egbertbouman committed Dec 13, 2024
1 parent a632d27 commit 63dd687
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/tribler/core/tunnel/community.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,13 @@ def is_bencoded(x: bytes) -> bool:
"""
Returns True is x appears to be valid bencoded byte string.
"""
return bdecode(x) is not None
if not isinstance(x, bytes):
raise ValueError('Value should be of bytes type. Got: %s' % type(x).__name__)
try:
decoded = bdecode(x)
except RuntimeError:
decoded = None
return decoded is not None


class TriblerTunnelSettings(HiddenTunnelSettings):
Expand Down

0 comments on commit 63dd687

Please sign in to comment.