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.

Title: Thinko in Lib/, decoding b"==" to b"="
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.4, Python 3.5
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: gvanrossum, martin.panter, orsenthil, pfalcon, python-dev, r.david.murray, terry.reedy
Priority: normal Keywords: easy, patch

Created on 2014-05-15 16:37 by pfalcon, last changed 2022-04-11 14:58 by admin. This issue is now closed.

File name Uploaded Description Edit
fix_issue_21511.diff gvanrossum, 2015-04-11 21:39 unittest by CW review
Messages (9)
msg218618 - (view) Author: Paul Sokolovsky (pfalcon) * Date: 2014-05-15 16:37
Lib/ for version 3.3..3.5-tip contains following code:

ESCAPE = b'='
        line = input.readline()
        if not line: break
        i, n = 0, len(line)
        if n > 0 and line[n-1:n] == b'\n':
            elif i+1 < n and line[i+1] == ESCAPE:

So, ESCAPE is defined as bytes, we see that "line" is read as bytes, and characters are accessed using idiom like "line[n-1:n]", but then it uses "line[i+1]", which returns int and thus will never be equal to ESCAPE.

I'm not sure what exact semantic condition that branch represents, for me it looks like "==" sequence to be decoded as "=". But I don't see such encoding variant in . Either way, replacing that condition with "and False", still passes
msg218678 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2014-05-16 19:16
Senthil, David, I hope one of you understands this. I looks like a minor fix.
msg218679 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-05-16 19:22
We should resolve issue 18022 before we decide how to "fix" this.
msg218680 - (view) Author: Paul Sokolovsky (pfalcon) * Date: 2014-05-16 19:49
This is minor issue indeed, uncovered when trying to run with MicroPython . I now worked around this on MicroPython side, but otherwise I set to report any issues I've seen with MicroPython porting, in the hope that MicroPython effort is good member of Python community. If the original report is unclear, feel free to point to any vague spots, and I'll elaborate on it. Thanks.
msg218681 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-05-16 20:05
Thanks.  It's very clear.  What isn't clear is if the line should be made to work as apparently intended, or removed :)  (My guess at this point without re-reading the RFCs is that it should be removed.)
msg239095 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2015-03-24 08:00
The implementation has been fixed for Issue 23681 to slice instead of index, and now compares byte strings:

>>> import quopri
>>> quopri.decodestring(b"123==four")
>>> quopri.a2b_qp = None
>>> quopri.decodestring(b"123==four")

However, I think a test still needs to be written to cover this branch of the code.
msg240496 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2015-04-11 21:39
Here's a unittest by Christie Wilson for this issue.
msg240497 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-04-11 21:46
New changeset 2582962ccf17 by Guido van Rossum in branch '3.4':
Unittest for Issue 21511 by Christie Wilson

New changeset 23d37a147051 by Guido van Rossum in branch 'default':
Unittest for Issue 21511 by Christie Wilson (merge from 3.4).
msg240499 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2015-04-11 21:48
Fixed, and removing the dependency on issue 18022. Thanks Christie!
Date User Action Args
2022-04-11 14:58:03adminsetgithub: 65710
2015-04-11 22:31:43r.david.murraysetstatus: open -> closed
stage: test needed -> resolved
2015-04-11 21:48:00gvanrossumsetresolution: fixed
dependencies: - Inconsistency between quopri.decodestring() and email.quoprimime.decode()
messages: + msg240499
2015-04-11 21:46:09python-devsetnosy: + python-dev
messages: + msg240497
2015-04-11 21:39:37gvanrossumsetfiles: + fix_issue_21511.diff

nosy: + gvanrossum
messages: + msg240496

keywords: + patch
2015-03-24 12:06:38berker.peksagsetkeywords: + easy
2015-03-24 08:00:46martin.pantersetnosy: + martin.panter

messages: + msg239095
title: Thinko in Lib/ -> Thinko in Lib/, decoding b"==" to b"="
2014-05-16 20:05:02r.david.murraysetmessages: + msg218681
2014-05-16 19:49:26pfalconsetmessages: + msg218680
2014-05-16 19:22:01r.david.murraysetdependencies: + Inconsistency between quopri.decodestring() and email.quoprimime.decode()
messages: + msg218679
2014-05-16 19:16:40terry.reedysetversions: + Python 3.4
nosy: + terry.reedy, r.david.murray, orsenthil

messages: + msg218678

stage: test needed
2014-05-15 16:37:35pfalconcreate