Skip to content

Commit c308042

Browse files
Revert unrelated changes.
1 parent d2bc9b4 commit c308042

1 file changed

Lines changed: 8 additions & 10 deletions

File tree

Lib/tarfile.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -490,27 +490,25 @@ def _init_read_gz(self):
490490
# taken from gzip.GzipFile with some alterations
491491
if self.__read(2) != b"\037\213":
492492
raise ReadError("not a gzip file")
493-
method, flag = struct.unpack("<BB6x", self.__read(8))
494-
if method != 8:
493+
if self.__read(1) != b"\010":
495494
raise CompressionError("unsupported compression method")
496495

497-
# process FEXTRA
496+
flag = ord(self.__read(1))
497+
self.__read(6)
498+
498499
if flag & 4:
499-
extra_len, = struct.unpack("<H", self.__read(2))
500-
self.__read(extra_len)
501-
# process FNAME
500+
xlen = ord(self.__read(1)) + 256 * ord(self.__read(1))
501+
self.__read(xlen)
502502
if flag & 8:
503503
while True:
504504
s = self.__read(1)
505-
if not s or s == b'\000':
505+
if not s or s == NUL:
506506
break
507-
# process FCOMMENT
508507
if flag & 16:
509508
while True:
510509
s = self.__read(1)
511-
if not s or s == b'\000':
510+
if not s or s == NUL:
512511
break
513-
# process FHCRC
514512
if flag & 2:
515513
self.__read(2)
516514

0 commit comments

Comments
 (0)