[issue3727] poplib module broken by str to unicode conversion
STINNER Victor
report at bugs.python.org
Fri Oct 17 02:05:35 CEST 2008
STINNER Victor <victor.stinner at haypocalc.com> added the comment:
New patch: resp() returns bytes
- self.file is now a binary file
- encode commands using POP3.encoding charset, default is UTF-8
- use md5.hexdigest()
- factorize POP3_SSL code: code specific for SSL is just the creation
of the socket
The default charset is UTF-8, but most servers only accept pure ASCII
login/password (eg. gmail.com) or a smaller subset of ASCII (eg. only
A-Z, a-z, 0-9 and some ponctuation signs :-/). If you user non-ASCII
login/password and your server doesn't use UTF-8, change POP3.encoding
or <your pop object>.encoding (encoding is not used in the
constructor).
welcome attribute (and getwelcome() results) is a bytes string.
You have to parse the message headers to get the right charset to
decode bytes to unicode characters. A multipart message may contains
two or more charsets and different encoding. But poplib is not
responsible to decode messages, just to download a message as bytes.
Arguments (username (login), password, a message identifier) are
unicode strings. For a message identifier, you can also use an integer
(nothing new, it was already possible).
I hope that apop() works. No Python error is raised but no server does
support his authentication method. I tested 3 servers
(pop3.haypocalc.com, pop.laposte.net and pop.gmail.com) and none
supports APOP. I tested POP3 and POP3_SSL (gmail requires SSL).
Added file: http://bugs.python.org/file11812/poplib-bytes.patch
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue3727>
_______________________________________
More information about the Python-bugs-list
mailing list