summaryrefslogtreecommitdiffstats
path: root/Doc/reference
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2012-11-20 20:35:27 (GMT)
committerBarry Warsaw <barry@python.org>2012-11-20 20:35:27 (GMT)
commitb72c10996e804413ebf0cb04ffc6e10f128b90c2 (patch)
treef81b41542a8c1c891d8973d0e65980f8afec5afb /Doc/reference
parent47037d7e4e1f0f71a7640f1e71f8d558c3ac6668 (diff)
parent82c1c781c7ee6496bd4c404b7ba972eed5dbcb12 (diff)
downloadcpython-b72c10996e804413ebf0cb04ffc6e10f128b90c2.zip
cpython-b72c10996e804413ebf0cb04ffc6e10f128b90c2.tar.gz
cpython-b72c10996e804413ebf0cb04ffc6e10f128b90c2.tar.bz2
- Issue #16514: Fix regression causing a traceback when sys.path[0] is None
(actually, any non-string or non-bytes type).
Diffstat (limited to 'Doc/reference')
-rw-r--r--Doc/reference/import.rst24
1 files changed, 15 insertions, 9 deletions
diff --git a/Doc/reference/import.rst b/Doc/reference/import.rst
index fdecc76..ef0235d 100644
--- a/Doc/reference/import.rst
+++ b/Doc/reference/import.rst
@@ -540,7 +540,10 @@ environment variable and various other installation- and
implementation-specific defaults. Entries in :data:`sys.path` can name
directories on the file system, zip files, and potentially other "locations"
(see the :mod:`site` module) that should be searched for modules, such as
-URLs, or database queries.
+URLs, or database queries. Only strings and bytes should be present on
+:data:`sys.path`; all other data types are ignored. The encoding of bytes
+entries is determined by the individual :term:`path entry finders <path entry
+finder>`.
The :term:`path based finder` is a :term:`meta path finder`, so the import
machinery begins the :term:`import path` search by calling the path
@@ -563,14 +566,17 @@ free to remove cache entries from :data:`sys.path_importer_cache` forcing
the path based finder to perform the path entry search again [#fnpic]_.
If the path entry is not present in the cache, the path based finder iterates
-over every callable in :data:`sys.path_hooks`. Each of the
-:term:`path entry hooks <path entry hook>` in this list is called with a
-single argument, the path entry to be searched. This callable may either
-return a :term:`path entry finder` that can handle the path entry, or it may
-raise :exc:`ImportError`.
-An :exc:`ImportError` is used by the path based finder to signal that the hook
-cannot find a :term:`path entry finder` for that :term:`path entry`. The
-exception is ignored and :term:`import path` iteration continues.
+over every callable in :data:`sys.path_hooks`. Each of the :term:`path entry
+hooks <path entry hook>` in this list is called with a single argument, the
+path entry to be searched. This callable may either return a :term:`path
+entry finder` that can handle the path entry, or it may raise
+:exc:`ImportError`. An :exc:`ImportError` is used by the path based finder to
+signal that the hook cannot find a :term:`path entry finder` for that
+:term:`path entry`. The exception is ignored and :term:`import path`
+iteration continues. The hook should expect either a string or bytes object;
+the encoding of bytes objects is up to the hook (e.g. it may be a file system
+encoding, UTF-8, or something else), and if the hook cannot decode the
+argument, it should raise :exc:`ImportError`.
If :data:`sys.path_hooks` iteration ends with no :term:`path entry finder`
being returned, then the path based finder's :meth:`find_module()` method