summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorShahriar Heidrich <smheidrich@weltenfunktion.de>2023-09-06 20:53:32 (GMT)
committerGitHub <noreply@github.com>2023-09-06 20:53:32 (GMT)
commit9f0c0a46f00d687e921990ee83894b2f4ce8a6e7 (patch)
tree204a5a1e0ff33bfa11e888c82a5f1089852c5410 /Doc
parentf9bd6e49ae58e0ba2934f29dd0f3299ba844cc8d (diff)
downloadcpython-9f0c0a46f00d687e921990ee83894b2f4ce8a6e7.zip
cpython-9f0c0a46f00d687e921990ee83894b2f4ce8a6e7.tar.gz
cpython-9f0c0a46f00d687e921990ee83894b2f4ce8a6e7.tar.bz2
gh-107732: Mention dir support in importlib.resources docs (#107734)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/importlib.resources.rst13
-rw-r--r--Doc/whatsnew/3.12.rst6
2 files changed, 14 insertions, 5 deletions
diff --git a/Doc/library/importlib.resources.rst b/Doc/library/importlib.resources.rst
index 76faf73..3de97e8 100644
--- a/Doc/library/importlib.resources.rst
+++ b/Doc/library/importlib.resources.rst
@@ -82,15 +82,18 @@ for example, a package and its resources can be imported from a zip file using
.. function:: as_file(traversable)
Given a :class:`~importlib.resources.abc.Traversable` object representing
- a file, typically from :func:`importlib.resources.files`, return
- a context manager for use in a :keyword:`with` statement.
+ a file or directory, typically from :func:`importlib.resources.files`,
+ return a context manager for use in a :keyword:`with` statement.
The context manager provides a :class:`pathlib.Path` object.
- Exiting the context manager cleans up any temporary file created when the
- resource was extracted from e.g. a zip file.
+ Exiting the context manager cleans up any temporary file or directory
+ created when the resource was extracted from e.g. a zip file.
Use ``as_file`` when the Traversable methods
- (``read_text``, etc) are insufficient and an actual file on
+ (``read_text``, etc) are insufficient and an actual file or directory on
the file system is required.
.. versionadded:: 3.9
+
+ .. versionchanged:: 3.12
+ Added support for ``traversable`` representing a directory.
diff --git a/Doc/whatsnew/3.12.rst b/Doc/whatsnew/3.12.rst
index 3afcd13..bdccbe1 100644
--- a/Doc/whatsnew/3.12.rst
+++ b/Doc/whatsnew/3.12.rst
@@ -630,6 +630,12 @@ fractions
* Objects of type :class:`fractions.Fraction` now support float-style
formatting. (Contributed by Mark Dickinson in :gh:`100161`.)
+importlib.resources
+-------------------
+
+* :func:`importlib.resources.as_file` now supports resource directories.
+ (Contributed by Jason R. Coombs in :gh:`97930`.)
+
inspect
-------