[Email-SIG] [Python-3000] fix email module for python 3000 (bytes/str)
Barry Warsaw
barry at python.org
Sun Aug 12 16:50:05 CEST 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Aug 10, 2007, at 6:49 PM, Victor Stinner wrote:
> It's really hard to convert email module to Python 3000 because it
> does mix
> byte strings and (unicode) character strings...
Indeed, but I'm making progress.
Just a very quick follow up now, with hopefully more detail soon.
I'm cross posting this one on purpose because of a couple of more
general py3k issues involved.
In r56957 I committed changes to sndhdr.py and imghdr.py so that they
compare what they read out of the files against proper byte
literals. AFAICT, neither module has a unittest, and if you run them
from the command line, you'll see that they're completely broken
(without my fix). The email package uses these to guess content type
subparts for the MIMEAudio and MIMEImage subclasses. I didn't add
unittests, just some judicious 'b' prefixes, and a quick command line
test seems to make the situation better. This also makes a bunch of
email unittests pass.
Another general Python thing that bit me was when an exception gets
raised with a non-ascii message, e.g.
>>> raise RuntimeError('oops')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
RuntimeError: oops
>>> raise RuntimeError('oo\xfcps')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
>>>
Um, what? (I'm using a XEmacs shell buffer on OS X, but you get
something similar in an iTerm and Terminal window.). In the email
unittests, I was getting one unexpected exception that had a non-
ascii character in it, but this crashed the unittest harness because
when it tried to print the exception message out, you'd instead get
an exception in io.py and the test run would exit. Okay, that all
makes sense, but IWBNI py3k could do better <wink>.
Fixing other simple issues (not checked in yet), I'm down to 20
failures, 13 errors out of 247 tests. I'm running
test_email_renamed.py only because test_email.py will go away (we
should remove the old module names and bump the email pkg version
number too).
As for the other questions Victor raises, we definitely need to
answer them, but that should be for another reply.
- -Barry
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)
iQCVAwUBRr8eHXEjvBPtnXfVAQIrJgQAoWGaoN82/KFLggu0IIM0BSghIQppiFVv
9weB+Kq6oAcgN95XKGSCZmPwA8jHkeUAWRpm8gZn7k44N2fJuZw11Klajy0tzUPW
Y4b5y8jPVU85phOKinynmHb9suXroyb35ZgMSp+WipL4L5PkOMv/x9q59Rs6ldjZ
cQu3Sssai9I=
=QG9j
-----END PGP SIGNATURE-----
More information about the Email-SIG
mailing list