[issue14360] email.encoders.encode_quopri doesn't work with python 3.2
Dmitry Shachnev
report at bugs.python.org
Sun Mar 18 10:36:35 CET 2012
New submission from Dmitry Shachnev <Mitya57 at gmail.com>:
Currently my /usr/lib/python3.2/email/encoders.py has this code:
def _qencode(s):
enc = _encodestring(s, quotetabs=True)
# Must encode spaces, which quopri.encodestring() doesn't do
return enc.replace(' ', '=20')
The problem is that _encodestring (which is just quopri.encodestring) always returns bytes, trying to run replace() on bytes raises "TypeError: expected an object with the buffer interface".
This leads to email.encoders.encode_quopri never working.
So, I think this should be changed to something like this:
<...>
return enc.decode().replace(' ', '=20')
Example log:
Python 3.2.3rc1 (default, Mar 9 2012, 23:02:43)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import email.encoders
>>> from email.mime.text import MIMEText
>>> msg = MIMEText(b'some text here')
>>> email.encoders.encode_quopri(msg)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.2/email/encoders.py", line 44, in encode_quopri
encdata = _qencode(orig)
File "/usr/lib/python3.2/email/encoders.py", line 23, in _qencode
return enc.replace(' ', '=20')
TypeError: expected an object with the buffer interface
Reproduced on Ubuntu precise with Python 3.2.3rc1. Replacing encode_quopri with encode_base64 works fine.
----------
components: Library (Lib)
messages: 156238
nosy: barry, mitya57
priority: normal
severity: normal
status: open
title: email.encoders.encode_quopri doesn't work with python 3.2
type: crash
versions: Python 3.2
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14360>
_______________________________________
More information about the Python-bugs-list
mailing list