cpython: 6e07be3dfb6b (original) (raw)
Mercurial > cpython
changeset 80908:6e07be3dfb6b 2.7
Fix issue #16646: ftplib.FTP.makeport() might lose socket error details. (patch by Serhiy Storchaka) [#16646]
Giampaolo Rodola' g.rodola@gmail.com | |
---|---|
date | Mon, 17 Dec 2012 14:30:48 +0100 |
parents | 542cfc75c043 |
children | fd57dbfa5765 |
files | Lib/ftplib.py Misc/NEWS |
diffstat | 2 files changed, 10 insertions(+), 4 deletions(-)[+] [-] Lib/ftplib.py 11 Misc/NEWS 3 |
line wrap: on
line diff
--- a/Lib/ftplib.py +++ b/Lib/ftplib.py @@ -273,21 +273,24 @@ class FTP: def makeport(self): '''Create a new socket and send a PORT command for it.'''
msg = "getaddrinfo returns an empty list"[](#l1.7)
err = None[](#l1.8) sock = None[](#l1.9) for res in socket.getaddrinfo(None, 0, self.af, socket.SOCK_STREAM, 0, socket.AI_PASSIVE):[](#l1.10) af, socktype, proto, canonname, sa = res[](#l1.11) try:[](#l1.12) sock = socket.socket(af, socktype, proto)[](#l1.13) sock.bind(sa)[](#l1.14)
except socket.error, msg:[](#l1.15)
except socket.error, err:[](#l1.16) if sock:[](#l1.17) sock.close()[](#l1.18) sock = None[](#l1.19) continue[](#l1.20) break[](#l1.21)
if not sock:[](#l1.22)
raise socket.error, msg[](#l1.23)
if sock is None:[](#l1.24)
if err is not None:[](#l1.25)
raise err[](#l1.26)
else:[](#l1.27)
raise socket.error("getaddrinfo returns an empty list")[](#l1.28) sock.listen(1)[](#l1.29) port = sock.getsockname()[1] # Get proper port[](#l1.30) host = self.sock.getsockname()[0] # Get proper host[](#l1.31)
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -160,6 +160,9 @@ Core and Builtins Library ------- +- Issue #16646: ftplib.FTP.makeport() might lose socket error details.