summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGiampaolo Rodola' <g.rodola@gmail.com>2012-12-17 13:23:41 (GMT)
committerGiampaolo Rodola' <g.rodola@gmail.com>2012-12-17 13:23:41 (GMT)
commit527e725732b01c92fb141cb7b667e30860dc6f17 (patch)
tree05fed87b155c5972ac9a11563652e253397a7a4d
parent84188c891cf6e76d9b34cbe09cac713fd349e3da (diff)
parent896cb15d0c4a32775cbead257ae85047b5bdba14 (diff)
downloadcpython-527e725732b01c92fb141cb7b667e30860dc6f17.zip
cpython-527e725732b01c92fb141cb7b667e30860dc6f17.tar.gz
cpython-527e725732b01c92fb141cb7b667e30860dc6f17.tar.bz2
Fix issue #16646: ftplib.FTP.makeport() might lose socket error details. (patch by Serhiy Storchaka)
-rw-r--r--Lib/ftplib.py10
-rw-r--r--Misc/NEWS3
2 files changed, 10 insertions, 3 deletions
diff --git a/Lib/ftplib.py b/Lib/ftplib.py
index 18887a6..490f900 100644
--- a/Lib/ftplib.py
+++ b/Lib/ftplib.py
@@ -288,20 +288,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 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 --git a/Misc/NEWS b/Misc/NEWS
index c1282e8..7890f64 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -167,6 +167,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.