summaryrefslogtreecommitdiffstats
path: root/Lib/lzma.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/lzma.py')
-rw-r--r--Lib/lzma.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/Lib/lzma.py b/Lib/lzma.py
index 800f521..c1e3d33 100644
--- a/Lib/lzma.py
+++ b/Lib/lzma.py
@@ -29,7 +29,7 @@ from _lzma import _encode_filter_properties, _decode_filter_properties
import _compression
-_MODE_CLOSED = 0
+# Value 0 no longer used
_MODE_READ = 1
# Value 2 no longer used
_MODE_WRITE = 3
@@ -92,7 +92,7 @@ class LZMAFile(_compression.BaseStream):
"""
self._fp = None
self._closefp = False
- self._mode = _MODE_CLOSED
+ self._mode = None
if mode in ("r", "rb"):
if check != -1:
@@ -137,7 +137,7 @@ class LZMAFile(_compression.BaseStream):
May be called more than once without error. Once the file is
closed, any other operation on it will raise a ValueError.
"""
- if self._mode == _MODE_CLOSED:
+ if self.closed:
return
try:
if self._mode == _MODE_READ:
@@ -153,12 +153,20 @@ class LZMAFile(_compression.BaseStream):
finally:
self._fp = None
self._closefp = False
- self._mode = _MODE_CLOSED
@property
def closed(self):
"""True if this file is closed."""
- return self._mode == _MODE_CLOSED
+ return self._fp is None
+
+ @property
+ def name(self):
+ self._check_not_closed()
+ return self._fp.name
+
+ @property
+ def mode(self):
+ return 'wb' if self._mode == _MODE_WRITE else 'rb'
def fileno(self):
"""Return the file descriptor for the underlying file."""