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
4748c95d
Commit
4748c95d
authored
Dec 17, 2012
by
Andrew Svetlov
Browse files
Options
Browse Files
Download
Plain Diff
Issue #16647: save socket error details in LMTP.connect()
Initial patch by Serhiy Storchaka.
parents
2fbc168e
1f7e694c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
13 deletions
+9
-13
Lib/smtplib.py
Lib/smtplib.py
+5
-5
Lib/test/mock_socket.py
Lib/test/mock_socket.py
+2
-6
Lib/test/test_smtplib.py
Lib/test/test_smtplib.py
+2
-2
No files found.
Lib/smtplib.py
View file @
4748c95d
...
...
@@ -309,7 +309,7 @@ class SMTP:
try:
port = int(port)
except ValueError:
raise
socket.e
rror("nonnumeric port")
raise
OSE
rror("nonnumeric port")
if not port:
port = self.default_port
if self.debuglevel > 0:
...
...
@@ -330,7 +330,7 @@ class SMTP:
s = s.encode("ascii")
try:
self.sock.sendall(s)
except
socket.e
rror:
except
OSE
rror:
self.close()
raise SMTPServerDisconnected('Server not connected')
else:
...
...
@@ -363,7 +363,7 @@ class SMTP:
while 1:
try:
line = self.file.readline()
except
socket.e
rror as e:
except
OSE
rror as e:
self.close()
raise SMTPServerDisconnected("Connection unexpectedly closed: "
+ str(e))
...
...
@@ -920,13 +920,13 @@ class LMTP(SMTP):
self
.
sock
=
socket
.
socket
(
socket
.
AF_UNIX
,
socket
.
SOCK_STREAM
)
self
.
file
=
None
self
.
sock
.
connect
(
host
)
except
socket
.
error
as
msg
:
except
OSError
:
if
self
.
debuglevel
>
0
:
print
(
'connect fail:'
,
host
,
file
=
stderr
)
if
self
.
sock
:
self
.
sock
.
close
()
self
.
sock
=
None
raise
socket
.
error
(
msg
)
raise
(
code
,
msg
)
=
self
.
getreply
()
if
self
.
debuglevel
>
0
:
print
(
'connect:'
,
msg
,
file
=
stderr
)
...
...
Lib/test/mock_socket.py
View file @
4748c95d
...
...
@@ -140,12 +140,8 @@ def gethostbyname(name):
return
""
class
gaierror
(
Exception
):
pass
class
error
(
Exception
):
pass
gaierror
=
socket_module
.
gaierror
error
=
socket_module
.
error
# Constants
...
...
Lib/test/test_smtplib.py
View file @
4748c95d
...
...
@@ -542,9 +542,9 @@ class NonConnectingTests(unittest.TestCase):
def
testNonnumericPort
(
self
):
# check that non-numeric port raises socket.error
self
.
assertRaises
(
mock_socket
.
e
rror
,
smtplib
.
SMTP
,
self
.
assertRaises
(
OSE
rror
,
smtplib
.
SMTP
,
"localhost"
,
"bogus"
)
self
.
assertRaises
(
mock_socket
.
e
rror
,
smtplib
.
SMTP
,
self
.
assertRaises
(
OSE
rror
,
smtplib
.
SMTP
,
"localhost:bogus"
)
...
...
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