summaryrefslogtreecommitdiffstats
path: root/Lib/ftplib.py
diff options
context:
space:
mode:
authorDong-hee Na <donghee.na92@gmail.com>2020-01-13 19:34:34 (GMT)
committerVictor Stinner <vstinner@python.org>2020-01-13 19:34:34 (GMT)
commita190e2ade1a704a6b5a94464a0a19b140c7dd031 (patch)
treea63621bfb1b6dbcfd584600ecc4e0bceddabe08f /Lib/ftplib.py
parent31d6de5aba009914efa8f0f3c3d7da35217578eb (diff)
downloadcpython-a190e2ade1a704a6b5a94464a0a19b140c7dd031.zip
cpython-a190e2ade1a704a6b5a94464a0a19b140c7dd031.tar.gz
cpython-a190e2ade1a704a6b5a94464a0a19b140c7dd031.tar.bz2
bpo-39259: ftplib.FTP/FTP_TLS now reject timeout = 0 (GH-17959)
Diffstat (limited to 'Lib/ftplib.py')
-rw-r--r--Lib/ftplib.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/Lib/ftplib.py b/Lib/ftplib.py
index c339eb2..71b3c28 100644
--- a/Lib/ftplib.py
+++ b/Lib/ftplib.py
@@ -146,6 +146,8 @@ class FTP:
self.port = port
if timeout != -999:
self.timeout = timeout
+ if self.timeout is not None and not self.timeout:
+ raise ValueError('Non-blocking socket (timeout=0) is not supported')
if source_address is not None:
self.source_address = source_address
sys.audit("ftplib.connect", self, self.host, self.port)
@@ -725,12 +727,12 @@ else:
keyfile=keyfile)
self.context = context
self._prot_p = False
- FTP.__init__(self, host, user, passwd, acct, timeout, source_address)
+ super().__init__(host, user, passwd, acct, timeout, source_address)
def login(self, user='', passwd='', acct='', secure=True):
if secure and not isinstance(self.sock, ssl.SSLSocket):
self.auth()
- return FTP.login(self, user, passwd, acct)
+ return super().login(user, passwd, acct)
def auth(self):
'''Set up secure control connection by using TLS/SSL.'''
@@ -740,8 +742,7 @@ else:
resp = self.voidcmd('AUTH TLS')
else:
resp = self.voidcmd('AUTH SSL')
- self.sock = self.context.wrap_socket(self.sock,
- server_hostname=self.host)
+ self.sock = self.context.wrap_socket(self.sock, server_hostname=self.host)
self.file = self.sock.makefile(mode='r', encoding=self.encoding)
return resp
@@ -778,7 +779,7 @@ else:
# --- Overridden FTP methods
def ntransfercmd(self, cmd, rest=None):
- conn, size = FTP.ntransfercmd(self, cmd, rest)
+ conn, size = super().ntransfercmd(cmd, rest)
if self._prot_p:
conn = self.context.wrap_socket(conn,
server_hostname=self.host)