From a25174541b405c5ffa421408e26f9ffe77ae5e5f Mon Sep 17 00:00:00 2001 From: SeaHOH Date: Tue, 13 Sep 2022 09:46:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=89=93=E5=8C=85=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=E5=85=BC=E5=AE=B9=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pack_portable.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pack_portable.py b/pack_portable.py index 8a485d3..7f84d4c 100644 --- a/pack_portable.py +++ b/pack_portable.py @@ -6,7 +6,6 @@ import re import io import sys -import gzip import stat import json import zlib @@ -22,6 +21,11 @@ except ImportError: from pkg_resources import packaging, parse_version +try: + from gzip import _GzipReader, BadGzipFile +except ImportError: + BadGzipFile = OSError + sitecustomize = b'''\ import os @@ -314,7 +318,7 @@ def write_cb(self, data): if self.f.tell() and not self.accept_ranges: self.new_file() if self.fgzip is None and bool(CEG(self.headers)): - self.fgzip = gzip._GzipReader(self.f) + self.fgzip = _GzipReader(self.f) self.fungzip = io.BytesIO() if self.fgzip: offset = self.f.tell() @@ -328,7 +332,7 @@ def write_cb(self, data): offset = self.f.tell() try: data = self.fgzip.read(sys.maxsize) - except (EOFError, gzip.BadGzipFile): + except (EOFError, BadGzipFile): if offset == 0: self.fgzip._rewind() elif self.fgzip._decompressor.eof: