bpo-45975: Simplify some while-loops with walrus operator (GH-29347)

This commit is contained in:
Nick Drozd 2022-11-26 16:33:25 -06:00 committed by GitHub
parent 25bc115df9
commit 024ac542d7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 41 additions and 153 deletions

View file

@ -67,10 +67,7 @@ def encode(input, output, quotetabs, header=False):
output.write(s + lineEnd)
prevline = None
while 1:
line = input.readline()
if not line:
break
while line := input.readline():
outline = []
# Strip off any readline induced trailing newline
stripped = b''
@ -126,9 +123,7 @@ def decode(input, output, header=False):
return
new = b''
while 1:
line = input.readline()
if not line: break
while line := input.readline():
i, n = 0, len(line)
if n > 0 and line[n-1:n] == b'\n':
partial = 0; n = n-1