gh-107398: Fix tarfile stream mode exception when process the file with the gzip extra field#126304
Conversation
|
@serhiy-storchaka PTAL when you got time( |
|
@serhiy-storchaka ping ( |
serhiy-storchaka
left a comment
There was a problem hiding this comment.
I see some refactoring, but except a struct.error the new code looks equivalent to the old one. Could you please point what was changed in the behavior?
| if self.__read(2) != b"\037\213": | ||
| raise ReadError("not a gzip file") | ||
| if self.__read(1) != b"\010": | ||
| (method, flag, _) = struct.unpack("<BBIxx", self.__read(8)) |
There was a problem hiding this comment.
What will happen if it read less than 8 bytes?
Why use I and then ignore the result?
| xlen = ord(self.__read(1)) + 256 * ord(self.__read(1)) | ||
| self.read(xlen) | ||
| extra_len, = struct.unpack("<H", self.__read(2)) | ||
| self.__read(extra_len) |
There was a problem hiding this comment.
Perhaps the only relevant change is in this line.
3bc23ce to
5ffa30b
Compare
|
Hi @serhiy-storchaka Thanks for the review!
|
|
@serhiy-storchaka PTAL when you get time |
|
This PR is stale because it has been open for 30 days with no activity. |
…ile with extra header data
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
…UtA6Q.rst Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
b0107a5 to
f86eec0
Compare
|
Thanks @Zheaoli for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14, 3.15. |
|
GH-150199 is a backport of this pull request to the 3.15 branch. |
|
GH-150200 is a backport of this pull request to the 3.14 branch. |
|
GH-150201 is a backport of this pull request to the 3.13 branch. |
Fix #107398