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 aleperalta
Recipients aleperalta
Date 2012-11-14.21:22:04
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1352928126.09.0.115783436578.issue16473@psf.upfronthosting.co.za>
In-reply-to
Content
New to python-dev; I grab a beginner tasks "increase test coverage" and I decided to add coverage to this bit of code in the quopri module:

# quopri.py
L138            while n > 0 and line[n-1:n] in b" \t\r": 
L139                n = n-1

As far as I understand to get into that while-loop the line to decode should end in " \t\r\n".

So the I added the following test:

    def test_decodestring_badly_enconded(self):
        e = b"hello     \t\r\n"
        p = b"hello\n"
        s = self.module.decodestring(e)
        self.assertEqual(s, p)

but that only passes when the module doesn't use binascii. In fact I change test_quopri to use support.import_fresh_module to disable binascii and removed a decorator that was used.

The decode text when binascci is used is:

>>> quopri.decodestring("hello \t\r\n")
'hello \t\r\n'

which differs from

>>> quopri.a2b_qp = None
>>> quopri.b2a_qp = None
>>> quopri.decodestring("hello \t\r\n")
'hello\n

And what's the deal with:

>>> import quopri
>>> quopri.encodestring("hello \t\r")
'hello \t\r'
>>> "hello \t\r".encode("quopri")
'hello=20=09\r'
History
Date User Action Args
2012-11-14 21:22:06aleperaltasetrecipients: + aleperalta
2012-11-14 21:22:06aleperaltasetmessageid: <1352928126.09.0.115783436578.issue16473@psf.upfronthosting.co.za>
2012-11-14 21:22:05aleperaltalinkissue16473 messages
2012-11-14 21:22:05aleperaltacreate