summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/importlib.rst5
-rw-r--r--Doc/reference/import.rst9
-rw-r--r--Doc/whatsnew/3.5.rst6
3 files changed, 20 insertions, 0 deletions
diff --git a/Doc/library/importlib.rst b/Doc/library/importlib.rst
index beac9d7..3af8d62 100644
--- a/Doc/library/importlib.rst
+++ b/Doc/library/importlib.rst
@@ -794,6 +794,11 @@ find and load modules.
.. versionadded:: 3.4
+ .. versionchanged:: 3.5
+ If the current working directory -- represented by an empty string --
+ is no longer valid then ``None`` is returned but no value is cached
+ in :data:`sys.path_importer_cache`.
+
.. classmethod:: find_module(fullname, path=None)
A legacy wrapper around :meth:`find_spec`.
diff --git a/Doc/reference/import.rst b/Doc/reference/import.rst
index dbb2e0a..99b77be 100644
--- a/Doc/reference/import.rst
+++ b/Doc/reference/import.rst
@@ -754,6 +754,15 @@ hook` callables on :data:`sys.path_hooks`, then the following protocol is used
to ask the finder for a module spec, which is then used when loading the
module.
+The current working directory -- denoted by an empty string -- is handled
+slightly differently from other entries on :data:`sys.path`. First, if the
+current working directory is found to not exist, no value is stored in
+:data:`sys.path_importer_cache`. Second, the value for the current working
+directory is looked up fresh for each module lookup. Third, the path used for
+:data:`sys.path_importer_cache` and returned by
+:meth:`importlib.machinery.PathFinder.find_spec` will be the actual current
+working directory and not the empty string.
+
Path entry finder protocol
--------------------------
diff --git a/Doc/whatsnew/3.5.rst b/Doc/whatsnew/3.5.rst
index 1e8d639..079c80f 100644
--- a/Doc/whatsnew/3.5.rst
+++ b/Doc/whatsnew/3.5.rst
@@ -436,6 +436,12 @@ Changes in the Python API
bytes-like object is required, not 'sometype'". (Contributed by Ezio Melotti
in :issue:`16518`.)
+* If the current directory is set to a directory that no longer exists then
+ :exc:`FileNotFoundError` will no longer be raised and instead
+ :meth:`~importlib.machinery.FileFinder.find_spec` will return ``None``
+ **without** caching ``None`` in :data:`sys.path_importer_cache` which is
+ different than the typical case (:issue:`22834`).
+
Changes in the C API
--------------------