bpo-39693: mention KeyError in tarfile extractfile documentation (GH-18639)
Co-authored-by: Andrey Darascheka <andrei.daraschenka@leverx.com>
This commit is contained in:
parent
faddc7449d
commit
ec42789e6e
|
@ -445,10 +445,11 @@ be finalized; only the internally used file object will be closed. See the
|
||||||
|
|
||||||
.. method:: TarFile.extractfile(member)
|
.. method:: TarFile.extractfile(member)
|
||||||
|
|
||||||
Extract a member from the archive as a file object. *member* may be a filename
|
Extract a member from the archive as a file object. *member* may be
|
||||||
or a :class:`TarInfo` object. If *member* is a regular file or a link, an
|
a filename or a :class:`TarInfo` object. If *member* is a regular file or
|
||||||
:class:`io.BufferedReader` object is returned. Otherwise, :const:`None` is
|
a link, an :class:`io.BufferedReader` object is returned. For all other
|
||||||
returned.
|
existing members, :const:`None` is returned. If *member* does not appear
|
||||||
|
in the archive, :exc:`KeyError` is raised.
|
||||||
|
|
||||||
.. versionchanged:: 3.3
|
.. versionchanged:: 3.3
|
||||||
Return an :class:`io.BufferedReader` object.
|
Return an :class:`io.BufferedReader` object.
|
||||||
|
|
|
@ -2093,9 +2093,10 @@ class TarFile(object):
|
||||||
|
|
||||||
def extractfile(self, member):
|
def extractfile(self, member):
|
||||||
"""Extract a member from the archive as a file object. `member' may be
|
"""Extract a member from the archive as a file object. `member' may be
|
||||||
a filename or a TarInfo object. If `member' is a regular file or a
|
a filename or a TarInfo object. If `member' is a regular file or
|
||||||
link, an io.BufferedReader object is returned. Otherwise, None is
|
a link, an io.BufferedReader object is returned. For all other
|
||||||
returned.
|
existing members, None is returned. If `member' does not appear
|
||||||
|
in the archive, KeyError is raised.
|
||||||
"""
|
"""
|
||||||
self._check("r")
|
self._check("r")
|
||||||
|
|
||||||
|
|
|
@ -1957,5 +1957,6 @@ Gennadiy Zlobin
|
||||||
Doug Zongker
|
Doug Zongker
|
||||||
Peter Åstrand
|
Peter Åstrand
|
||||||
Vlad Emelianov
|
Vlad Emelianov
|
||||||
|
Andrey Doroschenko
|
||||||
|
|
||||||
(Entries should be added in rough alphabetical order by last names)
|
(Entries should be added in rough alphabetical order by last names)
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Fix tarfile's extractfile documentation
|
Loading…
Reference in New Issue