[3.12] gh-107396: tarfiles: set self.exception before _init_read_gz() (GH-107485) (#108207)

gh-107396: tarfiles: set self.exception before _init_read_gz() (GH-107485)

In the stack call of: _init_read_gz()
```
_read, tarfile.py:548
read, tarfile.py:526
_init_read_gz, tarfile.py:491
```
a try;except exists that uses `self.exception`, so it needs to be set before
calling _init_read_gz().
(cherry picked from commit 37135d25e2)

Co-authored-by: balmeida-nokia <83089745+balmeida-nokia@users.noreply.github.com>
This commit is contained in:
Miss Islington (bot) 2023-08-21 05:35:18 -07:00 committed by GitHub
parent 238c8d236b
commit e1b069fe06
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 1 deletions

View file

@ -372,8 +372,8 @@ class _Stream:
self.zlib = zlib
self.crc = zlib.crc32(b"")
if mode == "r":
self._init_read_gz()
self.exception = zlib.error
self._init_read_gz()
else:
self._init_write_gz(compresslevel)