[Core] Fix for peer.client UnicodeDecodeError

Some users have been reporting unhandled UnicodeDecodeErrors and the
traces show it occuring in the call to `peer.client`. Although unable to
replicate it seems prudent to put a try..except around the call to
ensure it does not break the UIs.

Refs: https://github.com/arvidn/libtorrent/issues/3858

Closes: #3279
This commit is contained in:
Calum Lind 2019-06-24 16:34:15 +01:00
parent 833b5a1f30
commit 4b29436cd5
1 changed files with 5 additions and 1 deletions

View File

@ -810,7 +810,11 @@ class Torrent(object):
if peer.flags & peer.connecting or peer.flags & peer.handshake: if peer.flags & peer.connecting or peer.flags & peer.handshake:
continue continue
try:
client = decode_bytes(peer.client) client = decode_bytes(peer.client)
except UnicodeDecodeError:
# libtorrent on Py3 can raise UnicodeDecodeError for peer_info.client
client = 'unknown'
try: try:
country = component.get('Core').geoip_instance.country_code_by_addr( country = component.get('Core').geoip_instance.country_code_by_addr(