Message226870
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 |
|
Date |
User |
Action |
Args |
2014-09-14 13:46:54 | martin.panter | set | recipients:
+ martin.panter |
2014-09-14 13:46:54 | martin.panter | set | messageid: <1410702414.35.0.316849103636.issue22406@psf.upfronthosting.co.za> |
2014-09-14 13:46:54 | martin.panter | link | issue22406 messages |
2014-09-14 13:46:54 | martin.panter | create | |
|