@@ -8836,6 +8836,14 @@ def UncompressFileAlt(fp, formatspecs=__file_format_multi_dict__, filestart=0,
88368836 if not hasattr(fp, "read"):
88378837 return False
88388838
8839+ # If caller already gave us a FileLikeAdapter => honor it and return it.
8840+ if isinstance(fp, FileLikeAdapter):
8841+ try:
8842+ fp.write_through = True
8843+ except Exception:
8844+ pass
8845+ return fp
8846+
88398847 # Detect format on the fileobj at filestart
88408848 compresscheck = CheckCompressionType(fp, formatspecs, filestart, False)
88418849 if IsNestedDict(formatspecs) and compresscheck in formatspecs:
@@ -8885,15 +8893,8 @@ def UncompressFileAlt(fp, formatspecs=__file_format_multi_dict__, filestart=0,
88858893
88868894 return FileLikeAdapter(fp, mode="rb", mm=mm)
88878895
8888- def UncompressFileAlt(fp, formatspecs=__file_format_multi_dict__, filestart=0,
8889- use_mmap=False):
8890- """
8891- Accepts an already-open *bytes* file-like (fp). Detects compression and
8892- returns a FileLikeAdapter opened for 'rb'. If the stream is uncompressed
8893- and backed by a real file, you can enable mmap via use_mmap=True.
8894- """
8895- if not hasattr(fp, "read"):
8896- return False
8896+ def UncompressFile(infile, formatspecs=__file_format_multi_dict__, mode="rb",
8897+ filestart=0, use_mmap=False):
88978898
88988899 # If caller already gave us a FileLikeAdapter => honor it and return it.
88998900 if isinstance(fp, FileLikeAdapter):
@@ -9647,6 +9648,14 @@ def CompressOpenFile(outfile, compressionenable=True, compressionlevel=None,
96479648 if outfile is None:
96489649 return False
96499650
9651+ # If caller already gave us a FileLikeAdapter => honor it and return it.
9652+ if isinstance(fp, FileLikeAdapter):
9653+ try:
9654+ fp.write_through = True
9655+ except Exception:
9656+ pass
9657+ return fp
9658+
96509659 fbasename, fextname = os.path.splitext(outfile)
96519660 compressionlevel = 9 if compressionlevel is None else int(compressionlevel)
96529661 mode = "w" if PY2 else "wb"
0 commit comments