Skip to content

bpo-39693: tarfile extractfile documentation #18639

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions Doc/library/tarfile.rst
Original file line number Diff line number Diff line change
Expand Up @@ -444,10 +444,11 @@ be finalized; only the internally used file object will be closed. See the

.. method:: TarFile.extractfile(member)

Extract a member from the archive as a file object. *member* may be a filename
or a :class:`TarInfo` object. If *member* is a regular file or a link, an
:class:`io.BufferedReader` object is returned. Otherwise, :const:`None` is
returned.
Extract a member from the archive as a file object. *member* may be
a filename or a :class:`TarInfo` object. If *member* is a regular file or
a link, an :class:`io.BufferedReader` object is returned. For all other
existing members, :const:`None` is returned. If *member* does not appear
in the archive, :exc:`KeyError` is raised.

.. versionchanged:: 3.3
Return an :class:`io.BufferedReader` object.
Expand Down
7 changes: 4 additions & 3 deletions Lib/tarfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2089,9 +2089,10 @@ def extract(self, member, path="", set_attrs=True, *, numeric_owner=False):

def extractfile(self, member):
"""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
link, an io.BufferedReader object is returned. Otherwise, None is
returned.
a filename or a TarInfo object. If `member' is a regular file or
a link, an io.BufferedReader object is returned. For all other
existing members, None is returned. If `member' does not appear
in the archive, KeyError is raised.
"""
self._check("r")

Expand Down
1 change: 1 addition & 0 deletions Misc/ACKS
Original file line number Diff line number Diff line change
Expand Up @@ -1937,5 +1937,6 @@ Gennadiy Zlobin
Doug Zongker
Peter Åstrand
Vlad Emelianov
Andrey Doroschenko

(Entries should be added in rough alphabetical order by last names)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix tarfile's extractfile documentation