diff options
author | Nick Drozd <nicholasdrozd@gmail.com> | 2022-11-26 22:33:25 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-26 22:33:25 (GMT) |
commit | 024ac542d738f56b36bdeb3517a10e93da5acab9 (patch) | |
tree | 7e54e0fcc68871e059ccff2adaf39b8a1808dcad /Lib/tarfile.py | |
parent | 25bc115df9d0e82309852609a83b5ab7f804cdc1 (diff) | |
download | cpython-024ac542d738f56b36bdeb3517a10e93da5acab9.zip cpython-024ac542d738f56b36bdeb3517a10e93da5acab9.tar.gz cpython-024ac542d738f56b36bdeb3517a10e93da5acab9.tar.bz2 |
bpo-45975: Simplify some while-loops with walrus operator (GH-29347)
Diffstat (limited to 'Lib/tarfile.py')
-rwxr-xr-x | Lib/tarfile.py | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/Lib/tarfile.py b/Lib/tarfile.py index b47015f..d686435 100755 --- a/Lib/tarfile.py +++ b/Lib/tarfile.py @@ -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): |