Modify

Opened 8 months ago

Closed 8 months ago

Last modified 8 months ago

#11432 closed defect (duplicate)

email.utils does not exist in Python 2.4

Reported by: rjollos Owned by: hasienda
Priority: normal Component: AnnouncerPlugin
Severity: normal Keywords:
Cc: jun66j5 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 8 months ago by rjollos

  • Resolution set to duplicate
  • Status changed from new to closed

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

Last edited 8 months ago by rjollos (previous) (diff)

comment:2 Changed 8 months ago by jun66j5

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>

Add Comment

Modify Ticket

Action
as closed .
as The resolution will be set. Next status will be 'closed'.
to The owner will be changed from hasienda. Next status will be 'closed'.
The resolution will be deleted. Next status will be 'reopened'.
Author


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

 
Note: See TracTickets for help on using tickets.