From 74b8d333b708e2f029f60a06bbb5abb31199426f Mon Sep 17 00:00:00 2001 From: Amaury Forgeot d'Arc Date: Sat, 11 Jul 2009 14:33:51 +0000 Subject: [PATCH] #2622 Import errors in email.message, from a py2app standalone application. Patch by Mads Kiilerich, Reviewed by Barry Warsaw. --- Lib/email/base64mime.py | 4 ++-- Lib/email/header.py | 6 +++--- Lib/email/message.py | 4 ++-- Lib/email/quoprimime.py | 6 +++--- Lib/email/test/test_email_codecs.py | 6 +++--- Lib/email/test/test_email_torture.py | 2 +- Lib/test/test_old_mailbox.py | 4 ++-- Lib/wsgiref/headers.py | 4 ++-- Misc/NEWS | 3 +++ 9 files changed, 21 insertions(+), 18 deletions(-) diff --git a/Lib/email/base64mime.py b/Lib/email/base64mime.py index 05f960c3061..8804427b26b 100644 --- a/Lib/email/base64mime.py +++ b/Lib/email/base64mime.py @@ -20,7 +20,7 @@ in To:, From:, Cc:, etc. fields, as well as Subject: lines. This module does not do the line wrapping or end-of-line character conversion necessary for proper internationalized headers; it only does dumb encoding and -decoding. To deal with the various line wrapping issues, use the email.Header +decoding. To deal with the various line wrapping issues, use the email.header module. """ @@ -167,7 +167,7 @@ def decode(s, convert_eols=None): This function does not parse a full MIME header value encoded with base64 (like =?iso-8895-1?b?bmloISBuaWgh?=) -- please use the high - level email.Header class for that functionality. + level email.header class for that functionality. """ if not s: return s diff --git a/Lib/email/header.py b/Lib/email/header.py index ab0d3fc76ed..6e03922aa03 100644 --- a/Lib/email/header.py +++ b/Lib/email/header.py @@ -62,7 +62,7 @@ def decode_header(header): header, otherwise a lower-case string containing the name of the character set specified in the encoded string. - An email.Errors.HeaderParseError may be raised when certain decoding error + An email.errors.HeaderParseError may be raised when certain decoding error occurs (e.g. a base64 decoding exception). """ # If no encoding, just return the header @@ -337,8 +337,8 @@ class Header: # different charsets and/or encodings, and the resulting header will # accurately reflect each setting. # - # Each encoding can be email.Utils.QP (quoted-printable, for - # ASCII-like character sets like iso-8859-1), email.Utils.BASE64 + # Each encoding can be email.utils.QP (quoted-printable, for + # ASCII-like character sets like iso-8859-1), email.utils.BASE64 # (Base64, for non-ASCII like character sets like KOI8-R and # iso-2022-jp), or None (no encoding). # diff --git a/Lib/email/message.py b/Lib/email/message.py index 23cedf6143a..129f4ba405c 100644 --- a/Lib/email/message.py +++ b/Lib/email/message.py @@ -129,7 +129,7 @@ class Message: "From ". For more flexibility, use the flatten() method of a Generator instance. """ - from email.Generator import Generator + from email.generator import Generator fp = StringIO() g = Generator(fp) g.flatten(self, unixfrom=unixfrom) @@ -787,4 +787,4 @@ class Message: return [part.get_content_charset(failobj) for part in self.walk()] # I.e. def walk(self): ... - from email.Iterators import walk + from email.iterators import walk diff --git a/Lib/email/quoprimime.py b/Lib/email/quoprimime.py index 389b276de6d..b9dbfa97e04 100644 --- a/Lib/email/quoprimime.py +++ b/Lib/email/quoprimime.py @@ -11,7 +11,7 @@ character set, but that includes some 8-bit characters that are normally not allowed in email bodies or headers. Quoted-printable is very space-inefficient for encoding binary files; use the -email.base64MIME module for that instead. +email.base64mime module for that instead. This module provides an interface to encode and decode both headers and bodies with quoted-printable encoding. @@ -23,7 +23,7 @@ in To:/From:/Cc: etc. fields, as well as Subject: lines. This module does not do the line wrapping or end-of-line character conversion necessary for proper internationalized headers; it only does dumb encoding and decoding. To deal with the various line -wrapping issues, use the email.Header module. +wrapping issues, use the email.header module. """ __all__ = [ @@ -330,7 +330,7 @@ def header_decode(s): This function does not parse a full MIME header value encoded with quoted-printable (like =?iso-8895-1?q?Hello_World?=) -- please use - the high level email.Header class for that functionality. + the high level email.header class for that functionality. """ s = s.replace('_', ' ') return re.sub(r'=\w{2}', _unquote_match, s) diff --git a/Lib/email/test/test_email_codecs.py b/Lib/email/test/test_email_codecs.py index e85d754c402..532750a6dc3 100644 --- a/Lib/email/test/test_email_codecs.py +++ b/Lib/email/test/test_email_codecs.py @@ -6,9 +6,9 @@ import unittest from test.test_support import run_unittest from email.test.test_email import TestEmailBase -from email.Charset import Charset -from email.Header import Header, decode_header -from email.Message import Message +from email.charset import Charset +from email.header import Header, decode_header +from email.message import Message # We're compatible with Python 2.3, but it doesn't have the built-in Asian # codecs, so we have to skip all these tests. diff --git a/Lib/email/test/test_email_torture.py b/Lib/email/test/test_email_torture.py index d708b74f9a3..3ec4c6653b5 100644 --- a/Lib/email/test/test_email_torture.py +++ b/Lib/email/test/test_email_torture.py @@ -17,7 +17,7 @@ from test.test_support import TestSkipped import email from email import __file__ as testfile -from email.Iterators import _structure +from email.iterators import _structure def openfile(filename): from os.path import join, dirname, abspath diff --git a/Lib/test/test_old_mailbox.py b/Lib/test/test_old_mailbox.py index e61b19fd002..c1bebaf2a11 100644 --- a/Lib/test/test_old_mailbox.py +++ b/Lib/test/test_old_mailbox.py @@ -99,11 +99,11 @@ class MaildirTestCase(unittest.TestCase): def test_unix_mbox(self): ### should be better! - import email.Parser + import email.parser fname = self.createMessage("cur", True) n = 0 for msg in mailbox.PortableUnixMailbox(open(fname), - email.Parser.Parser().parse): + email.parser.Parser().parse): n += 1 self.assertEqual(msg["subject"], "Simple Test") self.assertEqual(len(str(msg)), len(FROM_)+len(DUMMY_MESSAGE)) diff --git a/Lib/wsgiref/headers.py b/Lib/wsgiref/headers.py index 02fd6a0ad6a..6bd304ef970 100644 --- a/Lib/wsgiref/headers.py +++ b/Lib/wsgiref/headers.py @@ -1,6 +1,6 @@ """Manage HTTP Response Headers -Much of this module is red-handedly pilfered from email.Message in the stdlib, +Much of this module is red-handedly pilfered from email.message in the stdlib, so portions are Copyright (C) 2001,2002 Python Software Foundation, and were written by Barry Warsaw. """ @@ -174,7 +174,7 @@ class Headers: h.add_header('content-disposition', 'attachment', filename='bud.gif') - Note that unlike the corresponding 'email.Message' method, this does + Note that unlike the corresponding 'email.message' method, this does *not* handle '(charset, language, value)' tuples: all values must be strings or None. """ diff --git a/Misc/NEWS b/Misc/NEWS index c8eb5d23fb0..9b452f128cf 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -350,6 +350,9 @@ Core and Builtins Library ------- +- Issue #2622: Fixed an ImportError when importing email.messsage from a + standalone application built with py2exe or py2app. + - Issue #6459: distutils.command.build_ext.get_export_symbols now uses the "PyInit" prefix, rather than "init".