changeset: 80907:a0b1942600a2 parent: 80904:45dfb657b430 parent: 80906:b8289a08d720 user: Giampaolo Rodola' date: Mon Dec 17 14:23:41 2012 +0100 files: Misc/NEWS description: Fix issue #16646: ftplib.FTP.makeport() might lose socket error details. (patch by Serhiy Storchaka) diff -r 45dfb657b430 -r a0b1942600a2 Lib/ftplib.py --- a/Lib/ftplib.py Mon Dec 17 14:01:45 2012 +0200 +++ b/Lib/ftplib.py Mon Dec 17 14:23:41 2012 +0100 @@ -288,20 +288,24 @@ def makeport(self): '''Create a new socket and send a PORT command for it.''' - msg = "getaddrinfo returns an empty list" + err = None sock = None for res in socket.getaddrinfo(None, 0, self.af, socket.SOCK_STREAM, 0, socket.AI_PASSIVE): af, socktype, proto, canonname, sa = res try: sock = socket.socket(af, socktype, proto) sock.bind(sa) - except socket.error as msg: + except socket.error as err: if sock: sock.close() sock = None continue break - if not sock: + if sock is None: + if err is not None: + raise err + else: + raise socket.error("getaddrinfo returns an empty list") raise socket.error(msg) sock.listen(1) port = sock.getsockname()[1] # Get proper port diff -r 45dfb657b430 -r a0b1942600a2 Misc/NEWS --- a/Misc/NEWS Mon Dec 17 14:01:45 2012 +0200 +++ b/Misc/NEWS Mon Dec 17 14:23:41 2012 +0100 @@ -167,6 +167,9 @@ Library ------- +- Issue #16646: ftplib.FTP.makeport() might lose socket error details. + (patch by Serhiy Storchaka) + - Issue #16626: Fix infinite recursion in glob.glob() on Windows when the pattern contains a wildcard in the drive or UNC path. Patch by Serhiy Storchaka.