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.

Author martin.panter
Recipients martin.panter
Date 2014-09-14.13:46:54
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1410702414.35.0.316849103636.issue22406@psf.upfronthosting.co.za>
In-reply-to
Content
The handler for the “Trailing garbage” error for “uu-codec” uses Python 2 code, while the copy in the "uu” module has the correct Python 3 code.

Please change the line at

https://hg.python.org/cpython/file/775453a7b85d/Lib/encodings/uu_codec.py#l57

to look like

https://hg.python.org/cpython/file/775453a7b85d/Lib/uu.py#l148

In particular, drop ord() and use floor division. Better yet, maybe the code could be reused so that there is less duplication!

Demonstration:

>>> codecs.decode(b"begin 666 <data>\n!,___\n \nend\n", "uu-codec")
Traceback (most recent call last):
  File "/usr/lib/python3.4/encodings/uu_codec.py", line 54, in uu_decode
    data = binascii.a2b_uu(s)
binascii.Error: Trailing garbage

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.4/encodings/uu_codec.py", line 57, in uu_decode
    nbytes = (((ord(s[0])-32) & 63) * 4 + 5) / 3
TypeError: ord() expected string of length 1, but int found

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: decoding with 'uu-codec' codec failed (TypeError: ord() expected string of length 1, but int found)
>>> codecs.decode(b"begin 666 <data>\n!,P  \n \nend\n", "uu-codec")
b'3'  # Expected output for both cases
History
Date User Action Args
2014-09-14 13:46:54martin.pantersetrecipients: + martin.panter
2014-09-14 13:46:54martin.pantersetmessageid: <1410702414.35.0.316849103636.issue22406@psf.upfronthosting.co.za>
2014-09-14 13:46:54martin.panterlinkissue22406 messages
2014-09-14 13:46:54martin.pantercreate