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.
Created on 2014年09月14日 13:46 by martin.panter, last changed 2022年04月11日 14:58 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| test.patch | martin.panter, 2014年09月15日 06:56 | Test | review | |
| uu_codec.patch | martin.panter, 2014年09月15日 06:56 | Fix | ||
| Messages (5) | |||
|---|---|---|---|
| msg226870 - (view) | Author: Martin Panter (martin.panter) * (Python committer) | Date: 2014年09月14日 13:46 | |
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 |
|||
| msg226877 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2014年09月14日 16:51 | |
Do you want to provide a patch Martin? |
|||
| msg226898 - (view) | Author: Martin Panter (martin.panter) * (Python committer) | Date: 2014年09月15日 06:56 | |
Here are two patches: a test and a fix. I’m not sure if it is okay to add a test for the "codecs" module with the tests for the "uu" module; it was easier that way because I am basically running the same test over the two different APIs. |
|||
| msg230800 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2014年11月07日 12:12 | |
New changeset ad89a652b4ed by Serhiy Storchaka in branch '3.4': Issue #22406: Fixed the uu_codec codec incorrectly ported to 3.x. https://hg.python.org/cpython/rev/ad89a652b4ed New changeset b18ef4a3e7c1 by Serhiy Storchaka in branch 'default': Issue #22406: Fixed the uu_codec codec incorrectly ported to 3.x. https://hg.python.org/cpython/rev/b18ef4a3e7c1 New changeset 7b82b58b8329 by Serhiy Storchaka in branch '2.7': Backported tests for issue #22406. https://hg.python.org/cpython/rev/7b82b58b8329 |
|||
| msg230803 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2014年11月07日 12:56 | |
I think it is safer now just fix existing code than replace it with totally different code with the risk of incompatibility. In any case uu_codec needs rewriting because currently it doesn't support incremental encoding and decoding. Thank you for your contribution Martin. And if you are going to do further contribution, please submit a contributor form (https://www.python.org/psf/contrib/). Few notes. It is more handy to provide all changes as one patch. And your patches contain trailing spaces in blank lines. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:58:08 | admin | set | github: 66596 |
| 2014年11月07日 12:56:21 | serhiy.storchaka | set | status: open -> closed resolution: fixed messages: + msg230803 stage: patch review -> resolved |
| 2014年11月07日 12:12:54 | python-dev | set | nosy:
+ python-dev messages: + msg230800 |
| 2014年09月20日 05:12:05 | berker.peksag | set | stage: needs patch -> patch review |
| 2014年09月15日 06:56:33 | martin.panter | set | files: + uu_codec.patch |
| 2014年09月15日 06:56:10 | martin.panter | set | files:
+ test.patch messages: + msg226898 |
| 2014年09月14日 16:51:20 | serhiy.storchaka | set | messages: + msg226877 |
| 2014年09月14日 16:49:03 | serhiy.storchaka | set | nosy:
+ serhiy.storchaka, lemburg, doerwalter versions: + Python 3.5 priority: normal -> low assignee: serhiy.storchaka keywords: + easy stage: needs patch |
| 2014年09月14日 13:46:54 | martin.panter | create | |