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

@ -1915,9 +1915,7 @@ class LWPCookieJar(FileCookieJar):
"comment", "commenturl")
try:
while 1:
line = f.readline()
if line == "": break
while (line := f.readline()) != "":
if not line.startswith(header):
continue
line = line[len(header):].strip()
@ -2017,12 +2015,9 @@ class MozillaCookieJar(FileCookieJar):
filename)
try:
while 1:
line = f.readline()
while (line := f.readline()) != "":
rest = {}
if line == "": break
# httponly is a cookie flag as defined in rfc6265
# when encoded in a netscape cookie file,
# the line is prepended with "#HttpOnly_"