summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGiampaolo Rodola' <g.rodola@gmail.com>2012-12-17 13:30:48 (GMT)
committerGiampaolo Rodola' <g.rodola@gmail.com>2012-12-17 13:30:48 (GMT)
commitc2a8169aa30c8f7dee3b874661f73e0b9c3f0919 (patch)
tree09a753ca2122a3545437a4a155fd56e7eb82b298
parent78efadb86f1d5e14d788cbffdba63efcb1a07de2 (diff)
downloadcpython-c2a8169aa30c8f7dee3b874661f73e0b9c3f0919.zip
cpython-c2a8169aa30c8f7dee3b874661f73e0b9c3f0919.tar.gz
cpython-c2a8169aa30c8f7dee3b874661f73e0b9c3f0919.tar.bz2
Fix issue #16646: ftplib.FTP.makeport() might lose socket error details. (patch by Serhiy Storchaka)
-rw-r--r--Lib/ftplib.py11
-rw-r--r--Misc/NEWS3
2 files changed, 10 insertions, 4 deletions
diff --git a/Lib/ftplib.py b/Lib/ftplib.py
index c896433..53b5f44 100644
--- 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"
+ 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, msg:
+ except socket.error, err:
if sock:
sock.close()
sock = None
continue
break
- if not sock:
- raise socket.error, msg
+ if sock is None:
+ if err is not None:
+ raise err
+ else:
+ raise socket.error("getaddrinfo returns an empty list")
sock.listen(1)
port = sock.getsockname()[1] # Get proper port
host = self.sock.getsockname()[0] # Get proper host
diff --git a/Misc/NEWS b/Misc/NEWS
index 4e6e661..8f5460a 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -160,6 +160,9 @@ Core and Builtins
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.