Skip to content

Commit bd6932a

Browse files
committed
Closes python#18430: Document that peek() may change the position of the underlying
file for the BZ2File, GzipFile and LZMAFile classes.
2 parents b12cb6a + 6976104 commit bd6932a

3 files changed

Lines changed: 15 additions & 0 deletions

File tree

Doc/library/bz2.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ All of the classes in this module may safely be accessed from multiple threads.
9595
byte of data will be returned (unless at EOF). The exact number of bytes
9696
returned is unspecified.
9797

98+
.. note:: While calling :meth:`peek` does not change the file position of
99+
the :class:`BZ2File`, it may change the position of the underlying file
100+
object (e.g. if the :class:`BZ2File` was constructed by passing a file
101+
object for *filename*).
102+
98103
.. versionadded:: 3.3
99104

100105
.. versionchanged:: 3.1

Doc/library/gzip.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@ The module defines the following items:
117117
the call. The number of bytes returned may be more or less than
118118
requested.
119119

120+
.. note:: While calling :meth:`peek` does not change the file position of
121+
the :class:`GzipFile`, it may change the position of the underlying
122+
file object (e.g. if the :class:`GzipFile` was constructed with the
123+
*fileobj* parameter).
124+
120125
.. versionadded:: 3.2
121126

122127
.. versionchanged:: 3.1

Doc/library/lzma.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ Reading and writing compressed files
102102
byte of data will be returned, unless EOF has been reached. The exact
103103
number of bytes returned is unspecified (the *size* argument is ignored).
104104

105+
.. note:: While calling :meth:`peek` does not change the file position of
106+
the :class:`LZMAFile`, it may change the position of the underlying
107+
file object (e.g. if the :class:`LZMAFile` was constructed by passing a
108+
file object for *filename*).
109+
105110
.. versionchanged:: 3.4
106111
Added support for the ``"x"`` and ``"xb"`` modes.
107112

0 commit comments

Comments
 (0)