mirror of
https://github.com/python/cpython.git
synced 2025-08-22 09:45:06 +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
|
@ -1262,11 +1262,7 @@ class TarInfo(object):
|
|||
# the newline. keyword and value are both UTF-8 encoded strings.
|
||||
regex = re.compile(br"(\d+) ([^=]+)=")
|
||||
pos = 0
|
||||
while True:
|
||||
match = regex.match(buf, pos)
|
||||
if not match:
|
||||
break
|
||||
|
||||
while match := regex.match(buf, pos):
|
||||
length, keyword = match.groups()
|
||||
length = int(length)
|
||||
if length == 0:
|
||||
|
@ -2418,10 +2414,8 @@ class TarFile(object):
|
|||
"""Read through the entire archive file and look for readable
|
||||
members.
|
||||
"""
|
||||
while True:
|
||||
tarinfo = self.next()
|
||||
if tarinfo is None:
|
||||
break
|
||||
while self.next() is not None:
|
||||
pass
|
||||
self._loaded = True
|
||||
|
||||
def _check(self, mode=None):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue