mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
Issue #16647: save socket error details in LMTP.connect()
Initial patch by Serhiy Storchaka.
This commit is contained in:
commit
2ade6f24cb
3 changed files with 9 additions and 13 deletions
|
@ -309,7 +309,7 @@ class SMTP:
|
|||
try:
|
||||
port = int(port)
|
||||
except ValueError:
|
||||
raise socket.error("nonnumeric port")
|
||||
raise OSError("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.error:
|
||||
except OSError:
|
||||
self.close()
|
||||
raise SMTPServerDisconnected('Server not connected')
|
||||
else:
|
||||
|
@ -363,7 +363,7 @@ class SMTP:
|
|||
while 1:
|
||||
try:
|
||||
line = self.file.readline()
|
||||
except socket.error as e:
|
||||
except OSError 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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue