mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +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
|
@ -475,10 +475,7 @@ class SimpleHandler(BaseHandler):
|
|||
from warnings import warn
|
||||
warn("SimpleHandler.stdout.write() should not do partial writes",
|
||||
DeprecationWarning)
|
||||
while True:
|
||||
data = data[result:]
|
||||
if not data:
|
||||
break
|
||||
while data := data[result:]:
|
||||
result = self.stdout.write(data)
|
||||
|
||||
def _flush(self):
|
||||
|
|
|
@ -214,10 +214,7 @@ class InputWrapper:
|
|||
return lines
|
||||
|
||||
def __iter__(self):
|
||||
while 1:
|
||||
line = self.readline()
|
||||
if not line:
|
||||
return
|
||||
while line := self.readline():
|
||||
yield line
|
||||
|
||||
def close(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue