summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorNadeem Vawda <nadeem.vawda@gmail.com>2012-06-04 21:31:20 (GMT)
committerNadeem Vawda <nadeem.vawda@gmail.com>2012-06-04 21:31:20 (GMT)
commitaebcdba8297bf5174ecf4e8687ad23883e35b14b (patch)
treeb9b55d8bb72a27f439da47f98d676f56876d8237 /Doc
parent68721019efb16ba8acad036c331a9a195d6f7da0 (diff)
downloadcpython-aebcdba8297bf5174ecf4e8687ad23883e35b14b.zip
cpython-aebcdba8297bf5174ecf4e8687ad23883e35b14b.tar.gz
cpython-aebcdba8297bf5174ecf4e8687ad23883e35b14b.tar.bz2
Make BZ2File's fileobj support easier to use.
The fileobj argument was added during the 3.3 development cycle, so this change does not break backward compatibility with 3.2.
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/bz2.rst16
1 files changed, 9 insertions, 7 deletions
diff --git a/Doc/library/bz2.rst b/Doc/library/bz2.rst
index 9577f31..de5c825 100644
--- a/Doc/library/bz2.rst
+++ b/Doc/library/bz2.rst
@@ -26,17 +26,18 @@ All of the classes in this module may safely be accessed from multiple threads.
(De)compression of files
------------------------
-.. class:: BZ2File(filename=None, mode='r', buffering=None, compresslevel=9, \*, fileobj=None)
+.. class:: BZ2File(filename, mode='r', buffering=None, compresslevel=9)
Open a bzip2-compressed file.
- The :class:`BZ2File` can wrap an existing :term:`file object` (given by
- *fileobj*), or operate directly on a named file (named by *filename*).
- Exactly one of these two parameters should be provided.
+ If *filename* is a :class:`str` or :class:`bytes` object, open the named file
+ directly. Otherwise, *filename* should be a :term:`file object`, which will
+ be used to read or write the compressed data.
The *mode* argument can be either ``'r'`` for reading (default), ``'w'`` for
- overwriting, or ``'a'`` for appending. If *fileobj* is provided, a mode of
- ``'w'`` does not truncate the file, and is instead equivalent to ``'a'``.
+ overwriting, or ``'a'`` for appending. If *filename* is a file object (rather
+ than an actual file name), a mode of ``'w'`` does not truncate the file, and
+ is instead equivalent to ``'a'``.
The *buffering* argument is ignored. Its use is deprecated.
@@ -69,7 +70,8 @@ All of the classes in this module may safely be accessed from multiple threads.
:meth:`read1` and :meth:`readinto` methods were added.
.. versionchanged:: 3.3
- The *fileobj* argument to the constructor was added.
+ Support was added for *filename* being a :term:`file object` instead of an
+ actual filename.
.. versionchanged:: 3.3
The ``'a'`` (append) mode was added, along with support for reading