aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/src/Lib/ftplib.py
diff options
context:
space:
mode:
authorshadchin <shadchin@yandex-team.com>2024-02-12 07:53:52 +0300
committershadchin <shadchin@yandex-team.com>2024-02-12 08:07:36 +0300
commitce1b7ca3171f9158180640c6a02a74b4afffedea (patch)
treee47c1e8391b1b0128262c1e9b1e6ed4c8fff2348 /contrib/tools/python3/src/Lib/ftplib.py
parent57350d96f030db90f220ce50ee591d5c5d403df7 (diff)
downloadydb-ce1b7ca3171f9158180640c6a02a74b4afffedea.tar.gz
Update Python from 3.11.8 to 3.12.2
Diffstat (limited to 'contrib/tools/python3/src/Lib/ftplib.py')
-rw-r--r--contrib/tools/python3/src/Lib/ftplib.py36
1 files changed, 7 insertions, 29 deletions
diff --git a/contrib/tools/python3/src/Lib/ftplib.py b/contrib/tools/python3/src/Lib/ftplib.py
index 40a76c9ca4..10c5d1ea08 100644
--- a/contrib/tools/python3/src/Lib/ftplib.py
+++ b/contrib/tools/python3/src/Lib/ftplib.py
@@ -434,10 +434,7 @@ class FTP:
"""
self.voidcmd('TYPE I')
with self.transfercmd(cmd, rest) as conn:
- while 1:
- data = conn.recv(blocksize)
- if not data:
- break
+ while data := conn.recv(blocksize):
callback(data)
# shutdown ssl layer
if _SSLSocket is not None and isinstance(conn, _SSLSocket):
@@ -496,10 +493,7 @@ class FTP:
"""
self.voidcmd('TYPE I')
with self.transfercmd(cmd, rest) as conn:
- while 1:
- buf = fp.read(blocksize)
- if not buf:
- break
+ while buf := fp.read(blocksize):
conn.sendall(buf)
if callback:
callback(buf)
@@ -561,7 +555,7 @@ class FTP:
LIST command. (This *should* only be used for a pathname.)'''
cmd = 'LIST'
func = None
- if args[-1:] and type(args[-1]) != type(''):
+ if args[-1:] and not isinstance(args[-1], str):
args, func = args[:-1], args[-1]
for arg in args:
if arg:
@@ -713,28 +707,12 @@ else:
'221 Goodbye.'
>>>
'''
- ssl_version = ssl.PROTOCOL_TLS_CLIENT
def __init__(self, host='', user='', passwd='', acct='',
- keyfile=None, certfile=None, context=None,
- timeout=_GLOBAL_DEFAULT_TIMEOUT, source_address=None, *,
- encoding='utf-8'):
- if context is not None and keyfile is not None:
- raise ValueError("context and keyfile arguments are mutually "
- "exclusive")
- if context is not None and certfile is not None:
- raise ValueError("context and certfile arguments are mutually "
- "exclusive")
- if keyfile is not None or certfile is not None:
- import warnings
- warnings.warn("keyfile and certfile are deprecated, use a "
- "custom context instead", DeprecationWarning, 2)
- self.keyfile = keyfile
- self.certfile = certfile
+ *, context=None, timeout=_GLOBAL_DEFAULT_TIMEOUT,
+ source_address=None, encoding='utf-8'):
if context is None:
- context = ssl._create_stdlib_context(self.ssl_version,
- certfile=certfile,
- keyfile=keyfile)
+ context = ssl._create_stdlib_context()
self.context = context
self._prot_p = False
super().__init__(host, user, passwd, acct,
@@ -749,7 +727,7 @@ else:
'''Set up secure control connection by using TLS/SSL.'''
if isinstance(self.sock, ssl.SSLSocket):
raise ValueError("Already using TLS")
- if self.ssl_version >= ssl.PROTOCOL_TLS:
+ if self.context.protocol >= ssl.PROTOCOL_TLS:
resp = self.voidcmd('AUTH TLS')
else:
resp = self.voidcmd('AUTH SSL')