summaryrefslogtreecommitdiffstats
path: root/Lib/ftplib.py
diff options
context:
space:
mode:
authorNick Drozd <nicholasdrozd@gmail.com>2022-11-26 22:33:25 (GMT)
committerGitHub <noreply@github.com>2022-11-26 22:33:25 (GMT)
commit024ac542d738f56b36bdeb3517a10e93da5acab9 (patch)
tree7e54e0fcc68871e059ccff2adaf39b8a1808dcad /Lib/ftplib.py
parent25bc115df9d0e82309852609a83b5ab7f804cdc1 (diff)
downloadcpython-024ac542d738f56b36bdeb3517a10e93da5acab9.zip
cpython-024ac542d738f56b36bdeb3517a10e93da5acab9.tar.gz
cpython-024ac542d738f56b36bdeb3517a10e93da5acab9.tar.bz2
bpo-45975: Simplify some while-loops with walrus operator (GH-29347)
Diffstat (limited to 'Lib/ftplib.py')
-rw-r--r--Lib/ftplib.py10
1 files changed, 2 insertions, 8 deletions
diff --git a/Lib/ftplib.py b/Lib/ftplib.py
index c7ca8f6..a56e0c3 100644
--- a/Lib/ftplib.py
+++ b/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)