Movatterモバイル変換


[0]ホーム

URL:


homepage

Issue22406

This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title:uu-codec trailing garbage workaround is Python 2 code
Type:behaviorStage:resolved
Components:Library (Lib)Versions:Python 3.4, Python 3.5
process
Status:closedResolution:fixed
Dependencies:Superseder:
Assigned To: serhiy.storchakaNosy List: doerwalter, lemburg, martin.panter, python-dev, serhiy.storchaka
Priority:lowKeywords:easy

Created on2014-09-14 13:46 bymartin.panter, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.

Files
File nameUploadedDescriptionEdit
test.patchmartin.panter,2014-09-15 06:56Testreview
uu_codec.patchmartin.panter,2014-09-15 06:56Fix
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 athttps://hg.python.org/cpython/file/775453a7b85d/Lib/encodings/uu_codec.py#l57to look likehttps://hg.python.org/cpython/file/775453a7b85d/Lib/uu.py#l148In 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 garbageDuring 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) / 3TypeError: ord() expected string of length 1, but int foundThe 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 changesetad89a652b4ed 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/ad89a652b4edNew changesetb18ef4a3e7c1 by Serhiy Storchaka in branch 'default':Issue#22406: Fixed the uu_codec codec incorrectly ported to 3.x.https://hg.python.org/cpython/rev/b18ef4a3e7c1New changeset7b82b58b8329 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
DateUserActionArgs
2022-04-11 14:58:08adminsetgithub: 66596
2014-11-07 12:56:21serhiy.storchakasetstatus: open -> closed
resolution: fixed
messages: +msg230803

stage: patch review -> resolved
2014-11-07 12:12:54python-devsetnosy: +python-dev
messages: +msg230800
2014-09-20 05:12:05berker.peksagsetstage: needs patch -> patch review
2014-09-15 06:56:33martin.pantersetfiles: +uu_codec.patch
2014-09-15 06:56:10martin.pantersetfiles: +test.patch

messages: +msg226898
2014-09-14 16:51:20serhiy.storchakasetmessages: +msg226877
2014-09-14 16:49:03serhiy.storchakasetnosy: +serhiy.storchaka,lemburg,doerwalter
versions: + Python 3.5
priority: normal -> low
assignee:serhiy.storchaka
keywords: +easy
stage: needs patch
2014-09-14 13:46:54martin.pantercreate
Supported byThe Python Software Foundation,
Powered byRoundup
Copyright © 1990-2022,Python Software Foundation
Legal Statements

[8]ページ先頭

©2009-2026 Movatter.jp