Fix Issue #4841: timeout is now applied for connections resulting from PORT/EPRT commands
diff --git a/Lib/ftplib.py b/Lib/ftplib.py
index 31ac526..c1cef8e 100644
--- a/Lib/ftplib.py
+++ b/Lib/ftplib.py
@@ -295,6 +295,8 @@
resp = self.sendport(host, port)
else:
resp = self.sendeprt(host, port)
+ if self.timeout is not _GLOBAL_DEFAULT_TIMEOUT:
+ sock.settimeout(self.timeout)
return sock
def makepasv(self):
@@ -347,6 +349,8 @@
if resp[0] != '1':
raise error_reply, resp
conn, sockaddr = sock.accept()
+ if self.timeout is not _GLOBAL_DEFAULT_TIMEOUT:
+ conn.settimeout(self.timeout)
if resp[:3] == '150':
# this is conditional in case we received a 125
size = parse150(resp)