mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-45975: Simplify some while-loops with walrus operator (GH-29347)
This commit is contained in:
parent
25bc115df9
commit
024ac542d7
28 changed files with 41 additions and 153 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue