Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
5a096e1b
Commit
5a096e1b
authored
Jan 22, 2007
by
Georg Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use new email module names (#1637162, #1637159, #1637157).
parent
dd7b0525
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
28 additions
and
28 deletions
+28
-28
Lib/logging/handlers.py
Lib/logging/handlers.py
+1
-1
Lib/mailbox.py
Lib/mailbox.py
+12
-12
Lib/smtplib.py
Lib/smtplib.py
+3
-3
Lib/test/test_mailbox.py
Lib/test/test_mailbox.py
+8
-8
Lib/urllib.py
Lib/urllib.py
+2
-2
Lib/urllib2.py
Lib/urllib2.py
+2
-2
No files found.
Lib/logging/handlers.py
View file @
5a096e1b
...
...
@@ -778,7 +778,7 @@ class SMTPHandler(logging.Handler):
try
:
import
smtplib
try
:
from
email.
U
tils
import
formatdate
from
email.
u
tils
import
formatdate
except
ImportError
:
formatdate
=
self
.
date_time
port
=
self
.
mailport
...
...
Lib/mailbox.py
View file @
5a096e1b
...
...
@@ -16,8 +16,8 @@ import socket
import
errno
import
copy
import
email
import
email.
M
essage
import
email.
G
enerator
import
email.
m
essage
import
email.
g
enerator
import
rfc822
import
StringIO
try
:
...
...
@@ -196,9 +196,9 @@ class Mailbox:
# To get native line endings on disk, the user-friendly \n line endings
# used in strings and by email.Message are translated here.
"""Dump message contents to target file."""
if
isinstance
(
message
,
email
.
M
essage
.
Message
):
if
isinstance
(
message
,
email
.
m
essage
.
Message
):
buffer
=
StringIO
.
StringIO
()
gen
=
email
.
G
enerator
.
Generator
(
buffer
,
mangle_from_
,
0
)
gen
=
email
.
g
enerator
.
Generator
(
buffer
,
mangle_from_
,
0
)
gen
.
flatten
(
message
)
buffer
.
seek
(
0
)
target
.
write
(
buffer
.
read
().
replace
(
'
\
n
'
,
os
.
linesep
))
...
...
@@ -707,7 +707,7 @@ class _mboxMMDF(_singlefileMailbox):
message
=
''
elif
isinstance
(
message
,
_mboxMMDFMessage
):
from_line
=
'From '
+
message
.
get_from
()
elif
isinstance
(
message
,
email
.
M
essage
.
Message
):
elif
isinstance
(
message
,
email
.
m
essage
.
Message
):
from_line
=
message
.
get_unixfrom
()
# May be None.
if
from_line
is
None
:
from_line
=
'From MAILER-DAEMON %s'
%
time
.
asctime
(
time
.
gmtime
())
...
...
@@ -1257,9 +1257,9 @@ class Babyl(_singlefileMailbox):
self
.
_file
.
write
(
os
.
linesep
)
else
:
self
.
_file
.
write
(
'1,,'
+
os
.
linesep
)
if
isinstance
(
message
,
email
.
M
essage
.
Message
):
if
isinstance
(
message
,
email
.
m
essage
.
Message
):
orig_buffer
=
StringIO
.
StringIO
()
orig_generator
=
email
.
G
enerator
.
Generator
(
orig_buffer
,
False
,
0
)
orig_generator
=
email
.
g
enerator
.
Generator
(
orig_buffer
,
False
,
0
)
orig_generator
.
flatten
(
message
)
orig_buffer
.
seek
(
0
)
while
True
:
...
...
@@ -1270,7 +1270,7 @@ class Babyl(_singlefileMailbox):
self
.
_file
.
write
(
'*** EOOH ***'
+
os
.
linesep
)
if
isinstance
(
message
,
BabylMessage
):
vis_buffer
=
StringIO
.
StringIO
()
vis_generator
=
email
.
G
enerator
.
Generator
(
vis_buffer
,
False
,
0
)
vis_generator
=
email
.
g
enerator
.
Generator
(
vis_buffer
,
False
,
0
)
vis_generator
.
flatten
(
message
.
get_visible
())
while
True
:
line
=
vis_buffer
.
readline
()
...
...
@@ -1326,12 +1326,12 @@ class Babyl(_singlefileMailbox):
return
(
start
,
stop
)
class
Message
(
email
.
M
essage
.
Message
):
class
Message
(
email
.
m
essage
.
Message
):
"""Message with mailbox-format-specific properties."""
def
__init__
(
self
,
message
=
None
):
"""Initialize a Message instance."""
if
isinstance
(
message
,
email
.
M
essage
.
Message
):
if
isinstance
(
message
,
email
.
m
essage
.
Message
):
self
.
_become_message
(
copy
.
deepcopy
(
message
))
if
isinstance
(
message
,
Message
):
message
.
_explain_to
(
self
)
...
...
@@ -1340,7 +1340,7 @@ class Message(email.Message.Message):
elif
hasattr
(
message
,
"read"
):
self
.
_become_message
(
email
.
message_from_file
(
message
))
elif
message
is
None
:
email
.
M
essage
.
Message
.
__init__
(
self
)
email
.
m
essage
.
Message
.
__init__
(
self
)
else
:
raise
TypeError
(
'Invalid message type: %s'
%
type
(
message
))
...
...
@@ -1471,7 +1471,7 @@ class _mboxMMDFMessage(Message):
def
__init__
(
self
,
message
=
None
):
"""Initialize an mboxMMDFMessage instance."""
self
.
set_from
(
'MAILER-DAEMON'
,
True
)
if
isinstance
(
message
,
email
.
M
essage
.
Message
):
if
isinstance
(
message
,
email
.
m
essage
.
Message
):
unixfrom
=
message
.
get_unixfrom
()
if
unixfrom
is
not
None
and
unixfrom
.
startswith
(
'From '
):
self
.
set_from
(
unixfrom
[
5
:])
...
...
Lib/smtplib.py
View file @
5a096e1b
...
...
@@ -43,10 +43,10 @@ Example:
import
socket
import
re
import
email.
U
tils
import
email.
u
tils
import
base64
import
hmac
from
email.base64
MIME
import
encode
as
encode_base64
from
email.base64
mime
import
encode
as
encode_base64
from
sys
import
stderr
__all__
=
[
"SMTPException"
,
"SMTPServerDisconnected"
,
"SMTPResponseException"
,
...
...
@@ -172,7 +172,7 @@ def quoteaddr(addr):
"""
m
=
(
None
,
None
)
try
:
m
=
email
.
U
tils
.
parseaddr
(
addr
)[
1
]
m
=
email
.
u
tils
.
parseaddr
(
addr
)[
1
]
except
AttributeError
:
pass
if
m
==
(
None
,
None
):
# Indicates parse failure or AttributeError
...
...
Lib/test/test_mailbox.py
View file @
5a096e1b
...
...
@@ -4,7 +4,7 @@ import time
import
stat
import
socket
import
email
import
email.
M
essage
import
email.
m
essage
import
rfc822
import
re
import
StringIO
...
...
@@ -22,7 +22,7 @@ class TestBase(unittest.TestCase):
def
_check_sample
(
self
,
msg
):
# Inspect a mailbox.Message representation of the sample message
self
.
assert_
(
isinstance
(
msg
,
email
.
M
essage
.
Message
))
self
.
assert_
(
isinstance
(
msg
,
email
.
m
essage
.
Message
))
self
.
assert_
(
isinstance
(
msg
,
mailbox
.
Message
))
for
key
,
value
in
_sample_headers
.
iteritems
():
self
.
assert_
(
value
in
msg
.
get_all
(
key
))
...
...
@@ -30,7 +30,7 @@ class TestBase(unittest.TestCase):
self
.
assert_
(
len
(
msg
.
get_payload
())
==
len
(
_sample_payloads
))
for
i
,
payload
in
enumerate
(
_sample_payloads
):
part
=
msg
.
get_payload
(
i
)
self
.
assert_
(
isinstance
(
part
,
email
.
M
essage
.
Message
))
self
.
assert_
(
isinstance
(
part
,
email
.
m
essage
.
Message
))
self
.
assert_
(
not
isinstance
(
part
,
mailbox
.
Message
))
self
.
assert_
(
part
.
get_payload
()
==
payload
)
...
...
@@ -946,7 +946,7 @@ class TestMessage(TestBase):
self._delete_recursively(self._path)
def test_initialize_with_eMM(self):
# Initialize based on email.
M
essage.Message instance
# Initialize based on email.
m
essage.Message instance
eMM = email.message_from_string(_sample_message)
msg = self._factory(eMM)
self._post_initialize_hook(msg)
...
...
@@ -972,7 +972,7 @@ class TestMessage(TestBase):
# Initialize without arguments
msg = self._factory()
self._post_initialize_hook(msg)
self.assert_(isinstance(msg, email.
M
essage.Message))
self.assert_(isinstance(msg, email.
m
essage.Message))
self.assert_(isinstance(msg, mailbox.Message))
self.assert_(isinstance(msg, self._factory))
self.assert_(msg.keys() == [])
...
...
@@ -999,7 +999,7 @@ class TestMessage(TestBase):
mailbox.BabylMessage, mailbox.MMDFMessage):
other_msg = class_()
msg._explain_to(other_msg)
other_msg = email.
M
essage.Message()
other_msg = email.
m
essage.Message()
self.assertRaises(TypeError, lambda: msg._explain_to(other_msg))
def _post_initialize_hook(self, msg):
...
...
@@ -1739,11 +1739,11 @@ class MaildirTestCase(unittest.TestCase):
def test_unix_mbox(self):
### should be better!
import email.
P
arser
import email.
p
arser
fname = self.createMessage("
cur
", True)
n = 0
for msg in mailbox.PortableUnixMailbox(open(fname),
email.
P
arser.Parser().parse):
email.
p
arser.Parser().parse):
n += 1
self.assertEqual(msg["
subject
"], "
Simple
Test
")
self.assertEqual(len(str(msg)), len(FROM_)+len(DUMMY_MESSAGE))
...
...
Lib/urllib.py
View file @
5a096e1b
...
...
@@ -452,7 +452,7 @@ class URLopener:
def
open_local_file
(
self
,
url
):
"""Use local file."""
import
mimetypes
,
mimetools
,
email
.
U
tils
import
mimetypes
,
mimetools
,
email
.
u
tils
try
:
from
cStringIO
import
StringIO
except
ImportError
:
...
...
@@ -464,7 +464,7 @@ class URLopener:
except
OSError
,
e
:
raise
IOError
(
e
.
errno
,
e
.
strerror
,
e
.
filename
)
size
=
stats
.
st_size
modified
=
email
.
U
tils
.
formatdate
(
stats
.
st_mtime
,
usegmt
=
True
)
modified
=
email
.
u
tils
.
formatdate
(
stats
.
st_mtime
,
usegmt
=
True
)
mtype
=
mimetypes
.
guess_type
(
url
)[
0
]
headers
=
mimetools
.
Message
(
StringIO
(
'Content-Type: %s
\
n
Content-Length: %d
\
n
Last-modified: %s
\
n
'
%
...
...
Lib/urllib2.py
View file @
5a096e1b
...
...
@@ -1209,14 +1209,14 @@ class FileHandler(BaseHandler):
# not entirely sure what the rules are here
def
open_local_file
(
self
,
req
):
import
email.
U
tils
import
email.
u
tils
import
mimetypes
host
=
req
.
get_host
()
file
=
req
.
get_selector
()
localfile
=
url2pathname
(
file
)
stats
=
os
.
stat
(
localfile
)
size
=
stats
.
st_size
modified
=
email
.
U
tils
.
formatdate
(
stats
.
st_mtime
,
usegmt
=
True
)
modified
=
email
.
u
tils
.
formatdate
(
stats
.
st_mtime
,
usegmt
=
True
)
mtype
=
mimetypes
.
guess_type
(
file
)[
0
]
headers
=
mimetools
.
Message
(
StringIO
(
'Content-type: %s
\
n
Content-length: %d
\
n
Last-modified: %s
\
n
'
%
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment