This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: uu.decode() raises binascii.Error instead of uu.Error on invalid data
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.11, Python 3.10, Python 3.9
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: Barro, PulakIIIT, iritkatriel
Priority: normal Keywords: easy, patch

Created on 2018-07-20 09:53 by Barro, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 30648 closed PulakIIIT, 2022-01-17 18:56
Messages (2)
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/uu.py", 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/uu.py", 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.
msg415052 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2022-03-13 17:26
uu is deprecated as per PEP 594, so there won't be further enhancements to it.
History
Date User Action Args
2022-04-11 14:59:03adminsetgithub: 78346
2022-03-13 17:26:12iritkatrielsetstatus: open -> closed

nosy: + iritkatriel
messages: + msg415052

resolution: wont fix
stage: patch review -> resolved
2022-01-17 18:56:16PulakIIITsetkeywords: + patch
nosy: + PulakIIIT

pull_requests: + pull_request28850
stage: patch review
2022-01-15 18:01:22iritkatrielsetkeywords: + easy
type: behavior
versions: + Python 3.9, Python 3.10, Python 3.11, - Python 3.7
2018-07-20 09:53:48Barrocreate