X-Git-Url: https://git.phdru.name/?p=extfs.d.git;a=blobdiff_plain;f=torrent;h=7841fa7e672c950180e94414f2426a5e440891ba;hp=ba725c965aed4ac000d185a2ba481f19066e59b9;hb=HEAD;hpb=fb3d556801d2162536d73d5cd28bd3a9fee5f31b diff --git a/torrent b/torrent index ba725c9..a0f827e 100755 --- a/torrent +++ b/torrent @@ -317,11 +317,16 @@ def decode_torrent(): encoding = encoding.decode('ascii') elif codepage: encoding = codepage.decode('ascii') - - if PY3 and encoding: + else: + for encoding in ('ascii', 'utf-8', default_encoding): + try: + return decode_dict(torrent, encoding) + except UnicodeDecodeError: + pass + torrent_error('UnicodeDecodeError') return decode_dict(torrent, encoding) - else: - return torrent + + return torrent def decode_datetime_asc(dt):