@@ -2443,6 +2443,7 @@ def __init__(self, file_path=None, fileobj=None, mode='rb', level=6, wbits=15,
24432443 if any(ch in internal_mode for ch in ('w', 'a', 'x')) and not hasattr(self.file, 'write'):
24442444 raise ValueError("fileobj must support write() in write/append mode")
24452445
2446+ self._fp = self.file
24462447 # Initialize per mode
24472448 if any(ch in internal_mode for ch in ('w', 'a', 'x')):
24482449 if self.wbits <= 0:
@@ -2789,12 +2790,6 @@ def fileobj(self):
27892790 def myfileobj(self):
27902791 return self.file
27912792
2792- # if some code expects ._fp to be “the stream itself”:
2793- @property
2794- def _fp(self):
2795- # OR return self.file if callers intend the raw file
2796- return self
2797-
27982793# ---------- Top-level helpers (optional) ----------
27992794def decompress_bytes(blob, **kw):
28002795 """
@@ -2929,6 +2924,7 @@ def __init__(self, file_path=None, fileobj=None, mode='rb',
29292924 if any(ch in internal_mode for ch in ('w', 'a', 'x')) and not hasattr(self.file, 'write'):
29302925 raise ValueError("fileobj must support write() in write/append mode")
29312926
2927+ self._fp = self.file
29322928 # Init per mode
29332929 if any(ch in internal_mode for ch in ('w', 'a', 'x')):
29342930 # Streaming write: start a new gzip member
@@ -3252,13 +3248,6 @@ def fileobj(self):
32523248 def myfileobj(self):
32533249 return self.file
32543250
3255- # if some code expects ._fp to be “the stream itself”:
3256- @property
3257- def _fp(self):
3258- # OR return self.file if callers intend the raw file
3259- return self
3260-
3261-
32623251# ---------- Top-level helpers ----------
32633252def gzip_decompress_bytes(blob, mode='rb', multi=True, **kw):
32643253 """
@@ -3400,6 +3389,7 @@ def __init__(self, file_path=None, fileobj=None, mode='rb',
34003389 if any(ch in internal_mode for ch in ('w', 'a', 'x')) and not hasattr(self.file, 'write'):
34013390 raise ValueError("fileobj must support write() in write/append mode")
34023391
3392+ self._fp = self.file
34033393 if any(ch in internal_mode for ch in ('w', 'a', 'x')):
34043394 # Start a new member at EOF for append
34053395 if 'a' in internal_mode:
@@ -3789,13 +3779,6 @@ def fileobj(self):
37893779 def myfileobj(self):
37903780 return self.file
37913781
3792- # if some code expects ._fp to be “the stream itself”:
3793- @property
3794- def _fp(self):
3795- # OR return self.file if callers intend the raw file
3796- return self
3797-
3798-
37993782# ---------- Top-level helpers ----------
38003783def lzop_compress_bytes(payload, level=9, text=False, **kw):
38013784 """
@@ -9523,6 +9506,16 @@ def detach(self):
95239506 self._closed = True
95249507 return fp, mm
95259508
9509+ # compatibility aliases for unwrapping utilities
9510+ @property
9511+ def fileobj(self):
9512+ return self.file
9513+
9514+ @property
9515+ def myfileobj(self):
9516+ return self.file
9517+
9518+
95269519
95279520# ========= mmap helpers & openers =========
95289521
0 commit comments