diff options
author | Barry Warsaw <barry@python.org> | 2012-11-20 20:22:51 (GMT) |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 2012-11-20 20:22:51 (GMT) |
commit | 82c1c781c7ee6496bd4c404b7ba972eed5dbcb12 (patch) | |
tree | e487dc3ab171e765a0a272921fa0db38df43a596 /Doc/reference | |
parent | 23089ab1db23333457149b567c125c10445550b6 (diff) | |
download | cpython-82c1c781c7ee6496bd4c404b7ba972eed5dbcb12.zip cpython-82c1c781c7ee6496bd4c404b7ba972eed5dbcb12.tar.gz cpython-82c1c781c7ee6496bd4c404b7ba972eed5dbcb12.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.rst | 24 |
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 |