Skip to content

Commit 0599609

Browse files
Add files via upload
1 parent a1fa864 commit 0599609

1 file changed

Lines changed: 12 additions & 20 deletions

File tree

pycatfile.py

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2455,6 +2455,7 @@ def __init__(self, file_path=None, fileobj=None, mode='rb', level=6, wbits=15,
24552455
if any(ch in internal_mode for ch in ('w', 'a', 'x')) and not hasattr(self.file, 'write'):
24562456
raise ValueError("fileobj must support write() in write/append mode")
24572457

2458+
self._fp = self.file
24582459
# Initialize per mode
24592460
if any(ch in internal_mode for ch in ('w', 'a', 'x')):
24602461
if self.wbits <= 0:
@@ -2801,12 +2802,6 @@ def fileobj(self):
28012802
def myfileobj(self):
28022803
return self.file
28032804

2804-
# if some code expects ._fp to be “the stream itself”:
2805-
@property
2806-
def _fp(self):
2807-
# OR return self.file if callers intend the raw file
2808-
return self
2809-
28102805
# ---------- Top-level helpers (optional) ----------
28112806
def decompress_bytes(blob, **kw):
28122807
"""
@@ -2941,6 +2936,7 @@ def __init__(self, file_path=None, fileobj=None, mode='rb',
29412936
if any(ch in internal_mode for ch in ('w', 'a', 'x')) and not hasattr(self.file, 'write'):
29422937
raise ValueError("fileobj must support write() in write/append mode")
29432938

2939+
self._fp = self.file
29442940
# Init per mode
29452941
if any(ch in internal_mode for ch in ('w', 'a', 'x')):
29462942
# Streaming write: start a new gzip member
@@ -3264,13 +3260,6 @@ def fileobj(self):
32643260
def myfileobj(self):
32653261
return self.file
32663262

3267-
# if some code expects ._fp to be “the stream itself”:
3268-
@property
3269-
def _fp(self):
3270-
# OR return self.file if callers intend the raw file
3271-
return self
3272-
3273-
32743263
# ---------- Top-level helpers ----------
32753264
def gzip_decompress_bytes(blob, mode='rb', multi=True, **kw):
32763265
"""
@@ -3412,6 +3401,7 @@ def __init__(self, file_path=None, fileobj=None, mode='rb',
34123401
if any(ch in internal_mode for ch in ('w', 'a', 'x')) and not hasattr(self.file, 'write'):
34133402
raise ValueError("fileobj must support write() in write/append mode")
34143403

3404+
self._fp = self.file
34153405
if any(ch in internal_mode for ch in ('w', 'a', 'x')):
34163406
# Start a new member at EOF for append
34173407
if 'a' in internal_mode:
@@ -3801,13 +3791,6 @@ def fileobj(self):
38013791
def myfileobj(self):
38023792
return self.file
38033793

3804-
# if some code expects ._fp to be “the stream itself”:
3805-
@property
3806-
def _fp(self):
3807-
# OR return self.file if callers intend the raw file
3808-
return self
3809-
3810-
38113794
# ---------- Top-level helpers ----------
38123795
def lzop_compress_bytes(payload, level=9, text=False, **kw):
38133796
"""
@@ -9535,6 +9518,15 @@ def detach(self):
95359518
self._closed = True
95369519
return fp, mm
95379520

9521+
# compatibility aliases for unwrapping utilities
9522+
@property
9523+
def fileobj(self):
9524+
return self.file
9525+
9526+
@property
9527+
def myfileobj(self):
9528+
return self.file
9529+
95389530

95399531
# ========= mmap helpers & openers =========
95409532

0 commit comments

Comments
 (0)