[MERGE] An SMTPConnection class for bzrlib

John Arbash Meinel john at arbash-meinel.com
Wed Jun 20 01:26:14 BST 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Adeodato Simó wrote:
> * John Arbash Meinel [Tue, 19 Jun 2007 16:55:22 -0500]:
> 
>> There is a small (major?) problem in that in python2.4 they are called
>> "email.Utils" and in python2.5 they are called "email.utils". Come to think of
>> it, that case isn't handled in the patch (bzr-email does).
> 
>> In bzr-email I do:
> 
>> try:
>>     # python <= 2.4
>>     from email.MIMEText import MIMEText
>>     from email.MIMEMultipart import MIMEMultipart
>>     from email.Utils import parseaddr
>> except ImportError:
>>     # python 2.5 moved MIMEText into a better namespace
>>     from email.mime.text import MIMEText
>>     from email.mime.multipart import MIMEMultipart
>>     from email.utils import parseaddr
> 
> I saw that in bzr-email, of course. However, importing the uppercase
> modules does not raise an exception in python 2.5, and I can't see any
> mention of this issue in the What's New document, nor a Warning is
> raised, so I assume the upper case modules are not going away, and will
> never raise an ImportError.
> 
> If with this explanation you would still like to see the try/except
> block, just say so and I'll add it. But I think it's unnecessary. :-)
> 
> Cheers,
> 

Hmm.. I wonder why it was failing for me.  If I look at the source code, it
seems they implemented a bunch of "LazyImporter" code which maps the names
directly into sys.modules['email.MIMEText'] etc.

They use a __dict__ update trick to make it not require a __getattr__ overhead
for every accessed member.

So it does turn out to not be necessary, and we can just use the python2.4
versions.

John
=:->

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGeHQmJdeBCYSNAAMRAlCEAJ0Y0JMcGbXgfu7XDn/WZxvqx90CuQCgp/u0
Sm8p7fM9TPNae/viY8lDZjw=
=UiWF
-----END PGP SIGNATURE-----



More information about the bazaar mailing list