Modify

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#11432 closed defect (duplicate)

email.utils does not exist in Python 2.4

Reported by: Ryan J Ollos Owned by: Steffen Hoffmann
Priority: normal Component: AnnouncerPlugin
Severity: normal Keywords:
Cc: Jun Omae Trac Release: 0.12

Description

This issue was raised in SO:20284917.

In [8081], the email.utils package was imported.

$ python2.5
Python 2.5.6 (r256:88840, Oct 28 2013, 23:50:06) 
[GCC 4.7.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import email.utils
>>> 
user@ubuntu:~/Workspace/bhdev$ python2.4
Python 2.4.6 (#2, Oct 28 2013, 20:07:19) 
[GCC 4.7.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import email.utils
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
ImportError: No module named utils

It appears that email.Utils existed in Python 2.4 and was renamed to email.utils in Python 2.5. Unfortunately this doesn't seem to have been captured in the Python documentation. Here is another ticket where they came to the same conclusion.

May I push the following change?

-from email.utils import parseaddr
+try
+    from email.utils import parseaddr
+except ImportError:  # python 2.4
+    from email.Utils import parseaddr

Attachments (0)

Change History (2)

comment:1 Changed 11 years ago by Ryan J Ollos

Resolution: duplicate
Status: newclosed

Now that I've caught up on recent activity, I see this is a duplicate of #11428 and #9106.

Last edited 11 years ago by Ryan J Ollos (previous) (diff)

comment:2 Changed 11 years ago by Jun Omae

Python 2.5 to 2.7 keep backwards compatibility for package naming of email library, see http://hg.python.org/cpython/file/ae9fb85ab4e0/Lib/email/__init__.py#l87.

$ for i in 2.{4,5,6,7}; do python$i -c 'from email.Utils import parseaddr; import sys; print "%r\n%r" % (sys.version_info, parseaddr)'; done
(2, 4, 3, 'final', 0)
<function parseaddr at 0xb7f233e4>
(2, 5, 6, 'final', 0)
<function parseaddr at 0x96a417c>
(2, 6, 8, 'final', 0)
<function parseaddr at 0xb7cb872c>
sys.version_info(major=2, minor=7, micro=2, releaselevel='final', serial=0)
<function parseaddr at 0x9d76cdc>

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Steffen Hoffmann.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.