@@ -2469,6 +2469,7 @@ def __init__(self, file_path=None, fileobj=None, mode='rb', level=6, wbits=15,
24692469 if any(ch in internal_mode for ch in ('w', 'a', 'x')) and not hasattr(self.file, 'write'):
24702470 raise ValueError("fileobj must support write() in write/append mode")
24712471
2472+ self._fp = self.file
24722473 # Initialize per mode
24732474 if any(ch in internal_mode for ch in ('w', 'a', 'x')):
24742475 if self.wbits <= 0:
@@ -2815,12 +2816,6 @@ def fileobj(self):
28152816 def myfileobj(self):
28162817 return self.file
28172818
2818- # if some code expects ._fp to be “the stream itself”:
2819- @property
2820- def _fp(self):
2821- # OR return self.file if callers intend the raw file
2822- return self
2823-
28242819# ---------- Top-level helpers (optional) ----------
28252820def decompress_bytes(blob, **kw):
28262821 """
@@ -2955,6 +2950,7 @@ def __init__(self, file_path=None, fileobj=None, mode='rb',
29552950 if any(ch in internal_mode for ch in ('w', 'a', 'x')) and not hasattr(self.file, 'write'):
29562951 raise ValueError("fileobj must support write() in write/append mode")
29572952
2953+ self._fp = self.file
29582954 # Init per mode
29592955 if any(ch in internal_mode for ch in ('w', 'a', 'x')):
29602956 # Streaming write: start a new gzip member
@@ -3278,13 +3274,6 @@ def fileobj(self):
32783274 def myfileobj(self):
32793275 return self.file
32803276
3281- # if some code expects ._fp to be “the stream itself”:
3282- @property
3283- def _fp(self):
3284- # OR return self.file if callers intend the raw file
3285- return self
3286-
3287-
32883277# ---------- Top-level helpers ----------
32893278def gzip_decompress_bytes(blob, mode='rb', multi=True, **kw):
32903279 """
@@ -3426,6 +3415,7 @@ def __init__(self, file_path=None, fileobj=None, mode='rb',
34263415 if any(ch in internal_mode for ch in ('w', 'a', 'x')) and not hasattr(self.file, 'write'):
34273416 raise ValueError("fileobj must support write() in write/append mode")
34283417
3418+ self._fp = self.file
34293419 if any(ch in internal_mode for ch in ('w', 'a', 'x')):
34303420 # Start a new member at EOF for append
34313421 if 'a' in internal_mode:
@@ -3815,13 +3805,6 @@ def fileobj(self):
38153805 def myfileobj(self):
38163806 return self.file
38173807
3818- # if some code expects ._fp to be “the stream itself”:
3819- @property
3820- def _fp(self):
3821- # OR return self.file if callers intend the raw file
3822- return self
3823-
3824-
38253808# ---------- Top-level helpers ----------
38263809def lzop_compress_bytes(payload, level=9, text=False, **kw):
38273810 """
@@ -9548,6 +9531,15 @@ def detach(self):
95489531 self._closed = True
95499532 return fp, mm
95509533
9534+ # compatibility aliases for unwrapping utilities
9535+ @property
9536+ def fileobj(self):
9537+ return self.file
9538+
9539+ @property
9540+ def myfileobj(self):
9541+ return self.file
9542+
95519543
95529544# ========= mmap helpers & openers =========
95539545
0 commit comments