@@ -540,7 +540,10 @@ environment variable and various other installation- and
540540implementation-specific defaults. Entries in :data: `sys.path ` can name
541541directories on the file system, zip files, and potentially other "locations"
542542(see the :mod: `site ` module) that should be searched for modules, such as
543- URLs, or database queries.
543+ URLs, or database queries. Only strings and bytes should be present on
544+ :data: `sys.path `; all other data types are ignored. The encoding of bytes
545+ entries is determined by the individual :term: `path entry finders <path entry
546+ finder> `.
544547
545548The :term: `path based finder ` is a :term: `meta path finder `, so the import
546549machinery 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
563566the path based finder to perform the path entry search again [#fnpic ]_.
564567
565568If the path entry is not present in the cache, the path based finder iterates
566- over every callable in :data: `sys.path_hooks `. Each of the
567- :term: `path entry hooks <path entry hook> ` in this list is called with a
568- single argument, the path entry to be searched. This callable may either
569- return a :term: `path entry finder ` that can handle the path entry, or it may
570- raise :exc: `ImportError `.
571- An :exc: `ImportError ` is used by the path based finder to signal that the hook
572- cannot find a :term: `path entry finder ` for that :term: `path entry `. The
573- exception is ignored and :term: `import path ` iteration continues.
569+ over every callable in :data: `sys.path_hooks `. Each of the :term: `path entry
570+ hooks <path entry hook> ` in this list is called with a single argument, the
571+ path entry to be searched. This callable may either return a :term: `path
572+ entry finder ` that can handle the path entry, or it may raise
573+ :exc: `ImportError `. An :exc: `ImportError ` is used by the path based finder to
574+ signal that the hook cannot find a :term: `path entry finder ` for that
575+ :term: `path entry `. The exception is ignored and :term: `import path `
576+ iteration continues. The hook should expect either a string or bytes object;
577+ the encoding of bytes objects is up to the hook (e.g. it may be a file system
578+ encoding, UTF-8, or something else), and if the hook cannot decode the
579+ argument, it should raise :exc: `ImportError `.
574580
575581If :data: `sys.path_hooks ` iteration ends with no :term: `path entry finder `
576582being returned, then the path based finder's :meth: `find_module() ` method
0 commit comments