Title: uu.decode() raises binascii.Error instead of uu.Error on invalid data
Type: Stage:
Components: Library (Lib) Versions: Python 3.7
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Barro
Priority: normal Keywords:

Created on 2018-07-20 09:53 by Barro, last changed 2018-07-20 09:53 by Barro.

Messages (1)
msg321994 - (view) Author: Jussi Judin (Barro) Date: 2018-07-20 09:53
uu.decode() function can leak the internal binascii.Error exception from binascii.a2b_uu() function call instead of the documented uu.Error exception.

Following code demonstrates the issue:

>>> import uu
>>> with open("in.uu", "wb") as fp:
...     fp.write(b'begin 0 \n0\xe8')
>>> uu.decode("in.uu", "out.uu")
Traceback (most recent call last):
  File "/tmp/python-3.7-bin/lib/python3.7/", line 148, in decode
    data = binascii.a2b_uu(s)
binascii.Error: Illegal char

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/tmp/python-3.7-bin/lib/python3.7/", line 152, in decode
    data = binascii.a2b_uu(s[:nbytes])
binascii.Error: Illegal char

It looks like the the workaround for broken encoders that catches the first binascii.Error exception just lets the second one to propagate if the recovery fails. I would except uu.Error to be raised instead, as that is mentioned in the documentation.
Date User Action Args
2018-07-20 09:53:48Barrocreate