summaryrefslogtreecommitdiffstats
path: root/Lib/lzma.py
diff options
context:
space:
mode:
authorNadeem Vawda <nadeem.vawda@gmail.com>2013-10-18 22:06:19 (GMT)
committerNadeem Vawda <nadeem.vawda@gmail.com>2013-10-18 22:06:19 (GMT)
commit42ca98217ca544220fdf4d33875c811f342edc56 (patch)
tree4ca867f69d20ab9c69779ae4a87dda0b116649b4 /Lib/lzma.py
parentc5168153538b46885a5345033c124d4a3d6c9dcc (diff)
downloadcpython-42ca98217ca544220fdf4d33875c811f342edc56.zip
cpython-42ca98217ca544220fdf4d33875c811f342edc56.tar.gz
cpython-42ca98217ca544220fdf4d33875c811f342edc56.tar.bz2
Issue #19201: Add support for the 'x' mode to the lzma module.
Patch by Tim Heaney and Vajrasky Kok.
Diffstat (limited to 'Lib/lzma.py')
-rw-r--r--Lib/lzma.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/Lib/lzma.py b/Lib/lzma.py
index b2e2f7e..011ad27 100644
--- a/Lib/lzma.py
+++ b/Lib/lzma.py
@@ -54,9 +54,9 @@ class LZMAFile(io.BufferedIOBase):
bytes object), in which case the named file is opened, or it can
be an existing file object to read from or write to.
- mode can be "r" for reading (default), "w" for (over)writing, or
- "a" for appending. These can equivalently be given as "rb", "wb"
- and "ab" respectively.
+ mode can be "r" for reading (default), "w" for (over)writing,
+ "x" for creating exclusively, or "a" for appending. These can
+ equivalently be given as "rb", "wb", "xb" and "ab" respectively.
format specifies the container format to use for the file.
If mode is "r", this defaults to FORMAT_AUTO. Otherwise, the
@@ -112,7 +112,7 @@ class LZMAFile(io.BufferedIOBase):
self._decompressor = LZMADecompressor(**self._init_args)
self._buffer = b""
self._buffer_offset = 0
- elif mode in ("w", "wb", "a", "ab"):
+ elif mode in ("w", "wb", "a", "ab", "x", "xb"):
if format is None:
format = FORMAT_XZ
mode_code = _MODE_WRITE
@@ -426,8 +426,9 @@ def open(filename, mode="rb", *,
object), in which case the named file is opened, or it can be an
existing file object to read from or write to.
- The mode argument can be "r", "rb" (default), "w", "wb", "a" or "ab"
- for binary mode, or "rt", "wt" or "at" for text mode.
+ The mode argument can be "r", "rb" (default), "w", "wb", "x", "xb",
+ "a", or "ab" for binary mode, or "rt", "wt", "xt", or "at" for text
+ mode.
The format, check, preset and filters arguments specify the
compression settings, as for LZMACompressor, LZMADecompressor and