py3-branch - Check instance type before using startswith
Posted: May 28th, 2019, 1:49 pm
Apparently in Python 3 the line in line.startswith('X-') can be a byte type, which requires different parameters. The article that caused it contains no metadata , only what seems like base64 encoded content. The header or subject has no encoding info.
2019-05-28 15:12:59,702::INFO::[downloader:302] Post-processing finished, resuming download
Exception in thread Thread-6:
Traceback (most recent call last):
File "C:\git\sabnzbd\sabnzbd\decoder.py", line 115, in run
data = self.decode(article, lines, raw_data)
File "C:\git\sabnzbd\sabnzbd\decoder.py", line 212, in decode
decoded_data, output_filename, crc, crc_expected, crc_correct = sabyenc3.decode_usenet_chunks(raw_data, article.bytes)
ValueError: Could not get filename
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\t\AppData\Local\Programs\Python\Python37\lib\threading.py", line 917, in _bootstrap_inner
self.run()
File "C:\git\sabnzbd\sabnzbd\decoder.py", line 160, in run
if not line.startswith('X-') and match_str(lline, ('dmca', 'removed', 'cancel', 'blocked')):
TypeError: startswith first arg must be bytes or a tuple of bytes, not str
2019-05-28 15:12:59,702::INFO::[downloader:302] Post-processing finished, resuming download
Exception in thread Thread-6:
Traceback (most recent call last):
File "C:\git\sabnzbd\sabnzbd\decoder.py", line 115, in run
data = self.decode(article, lines, raw_data)
File "C:\git\sabnzbd\sabnzbd\decoder.py", line 212, in decode
decoded_data, output_filename, crc, crc_expected, crc_correct = sabyenc3.decode_usenet_chunks(raw_data, article.bytes)
ValueError: Could not get filename
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\t\AppData\Local\Programs\Python\Python37\lib\threading.py", line 917, in _bootstrap_inner
self.run()
File "C:\git\sabnzbd\sabnzbd\decoder.py", line 160, in run
if not line.startswith('X-') and match_str(lline, ('dmca', 'removed', 'cancel', 'blocked')):
TypeError: startswith first arg must be bytes or a tuple of bytes, not str