Skip to content

Commit

Permalink
修复打包脚本兼容性
Browse files Browse the repository at this point in the history
  • Loading branch information
SeaHOH committed Sep 13, 2022
1 parent dbd6290 commit a251745
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pack_portable.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import re
import io
import sys
import gzip
import stat
import json
import zlib
Expand All @@ -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
Expand Down Expand Up @@ -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()
Expand All @@ -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:
Expand Down

0 comments on commit a251745

Please sign in to comment.