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
2566dd20
Commit
2566dd20
authored
Jul 10, 2004
by
Brett Cannon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Debug output is now printed to sys.stderr .
Closes bug #980938.
parent
d85c0134
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
9 deletions
+12
-9
Lib/smtplib.py
Lib/smtplib.py
+10
-9
Misc/NEWS
Misc/NEWS
+2
-0
No files found.
Lib/smtplib.py
View file @
2566dd20
...
@@ -47,6 +47,7 @@ import rfc822
...
@@ -47,6 +47,7 @@ import rfc822
import
base64
import
base64
import
hmac
import
hmac
from
email.base64MIME
import
encode
as
encode_base64
from
email.base64MIME
import
encode
as
encode_base64
from
sys
import
stderr
__all__
=
[
"SMTPException"
,
"SMTPServerDisconnected"
,
"SMTPResponseException"
,
__all__
=
[
"SMTPException"
,
"SMTPServerDisconnected"
,
"SMTPResponseException"
,
"SMTPSenderRefused"
,
"SMTPRecipientsRefused"
,
"SMTPDataError"
,
"SMTPSenderRefused"
,
"SMTPRecipientsRefused"
,
"SMTPDataError"
,
...
@@ -282,17 +283,17 @@ class SMTP:
...
@@ -282,17 +283,17 @@ class SMTP:
except ValueError:
except ValueError:
raise socket.error, "nonnumeric port"
raise socket.error, "nonnumeric port"
if not port: port = SMTP_PORT
if not port: port = SMTP_PORT
if self.debuglevel > 0: print '
connect
:
', (host, port)
if self.debuglevel > 0: print
>>stderr,
'
connect
:
', (host, port)
msg = "getaddrinfo returns an empty list"
msg = "getaddrinfo returns an empty list"
self.sock = None
self.sock = None
for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM):
for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM):
af, socktype, proto, canonname, sa = res
af, socktype, proto, canonname, sa = res
try:
try:
self.sock = socket.socket(af, socktype, proto)
self.sock = socket.socket(af, socktype, proto)
if self.debuglevel > 0: print '
connect
:
', (host, port)
if self.debuglevel > 0: print
>>stderr,
'
connect
:
', (host, port)
self.sock.connect(sa)
self.sock.connect(sa)
except socket.error, msg:
except socket.error, msg:
if self.debuglevel > 0: print '
connect
fail
:
', (host, port)
if self.debuglevel > 0: print
>>stderr,
'
connect
fail
:
', (host, port)
if self.sock:
if self.sock:
self.sock.close()
self.sock.close()
self.sock = None
self.sock = None
...
@@ -301,12 +302,12 @@ class SMTP:
...
@@ -301,12 +302,12 @@ class SMTP:
if not self.sock:
if not self.sock:
raise socket.error, msg
raise socket.error, msg
(code, msg) = self.getreply()
(code, msg) = self.getreply()
if self.debuglevel > 0: print "connect:", msg
if self.debuglevel > 0: print
>>stderr,
"connect:", msg
return (code, msg)
return (code, msg)
def send(self, str):
def send(self, str):
"""Send `str'
to
the
server
.
"""
"""Send `str'
to
the
server
.
"""
if self.debuglevel > 0: print 'send:', repr(str)
if self.debuglevel > 0: print
>>stderr,
'send:', repr(str)
if self.sock:
if self.sock:
try:
try:
self.sock.sendall(str)
self.sock.sendall(str)
...
@@ -345,7 +346,7 @@ class SMTP:
...
@@ -345,7 +346,7 @@ class SMTP:
if line == '':
if line == '':
self.close()
self.close()
raise SMTPServerDisconnected("Connection unexpectedly closed")
raise SMTPServerDisconnected("Connection unexpectedly closed")
if self.debuglevel > 0: print '
reply
:
', repr(line)
if self.debuglevel > 0: print
>>stderr,
'
reply
:
', repr(line)
resp.append(line[4:].strip())
resp.append(line[4:].strip())
code=line[:3]
code=line[:3]
# Check that the error code is syntactically correct.
# Check that the error code is syntactically correct.
...
@@ -361,7 +362,7 @@ class SMTP:
...
@@ -361,7 +362,7 @@ class SMTP:
errmsg
=
"
\
n
"
.
join
(
resp
)
errmsg
=
"
\
n
"
.
join
(
resp
)
if
self
.
debuglevel
>
0
:
if
self
.
debuglevel
>
0
:
print
'reply: retcode (%s); Msg: %s'
%
(
errcode
,
errmsg
)
print
>>
stderr
,
'reply: retcode (%s); Msg: %s'
%
(
errcode
,
errmsg
)
return
errcode
,
errmsg
return
errcode
,
errmsg
def
docmd
(
self
,
cmd
,
args
=
""
):
def
docmd
(
self
,
cmd
,
args
=
""
):
...
@@ -474,7 +475,7 @@ class SMTP:
...
@@ -474,7 +475,7 @@ class SMTP:
"""
"""
self.putcmd("data")
self.putcmd("data")
(code,repl)=self.getreply()
(code,repl)=self.getreply()
if self.debuglevel >0 : print "data:", (code,repl)
if self.debuglevel >0 : print
>>stderr,
"data:", (code,repl)
if code != 354:
if code != 354:
raise SMTPDataError(code,repl)
raise SMTPDataError(code,repl)
else:
else:
...
@@ -484,7 +485,7 @@ class SMTP:
...
@@ -484,7 +485,7 @@ class SMTP:
q = q + "." + CRLF
q = q + "." + CRLF
self.send(q)
self.send(q)
(code,msg)=self.getreply()
(code,msg)=self.getreply()
if self.debuglevel >0 : print "data:", (code,msg)
if self.debuglevel >0 : print
>>stderr,
"data:", (code,msg)
return (code,msg)
return (code,msg)
def verify(self, address):
def verify(self, address):
...
...
Misc/NEWS
View file @
2566dd20
...
@@ -29,6 +29,8 @@ Extension modules
...
@@ -29,6 +29,8 @@ Extension modules
Library
Library
-------
-------
-
Bug
#
980938
:
smtplib
now
prints
debug
output
to
sys
.
stderr
.
-
Bug
#
930024
:
posixpath
.
realpath
()
now
handles
infinite
loops
in
symlinks
by
-
Bug
#
930024
:
posixpath
.
realpath
()
now
handles
infinite
loops
in
symlinks
by
returning
the
last
point
in
the
path
that
was
not
part
of
any
loop
.
Thanks
returning
the
last
point
in
the
path
that
was
not
part
of
any
loop
.
Thanks
AM
Kuchling
.
AM
Kuchling
.
...
...
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