[Python-checkins] peps: Simplified find_loader return values.

eric.smith python-checkins at python.org
Fri May 11 03:04:44 CEST 2012


http://hg.python.org/peps/rev/29a064eab994
changeset:   4366:29a064eab994
parent:      4364:342624df7c93
user:        Eric V. Smith <eric at trueblade.com>
date:        Thu May 10 21:01:01 2012 -0400
summary:
  Simplified find_loader return values.

files:
  pep-0420.txt |  29 ++++++++++++-----------------
  1 files changed, 12 insertions(+), 17 deletions(-)


diff --git a/pep-0420.txt b/pep-0420.txt
--- a/pep-0420.txt
+++ b/pep-0420.txt
@@ -168,29 +168,23 @@
 
 For a finder to contribute to namespace packages, it must implement a
 new ``find_loader(fullname)`` method.  ``fullname`` has the same
-meaning as for ``find_module``.  ``find_loader`` has 3 possible return
-values, depending on whether it found a normal package, a namespace
-package portion, or neither.  In all cases the return value is a
-2-tuple.
+meaning as for ``find_module``.  ``find_loader`` always returns a
+2-tuple of ``(loader, <iterable-of-path-entries>)``.  ``loader`` may
+be None, in which case ``<iterable-of-path-entries>`` (which may be
+empty) is added to the list of recorded path entries and path
+searching continues.  If ``loader`` is not None, it is immediately
+used to load the regular package.
 
-===== =======================  ============
-Case  Meaning                  Return value
------ -----------------------  ------------
-1     normal package found     ``(loader, None)``
-2     portion(s) found         ``(None, <sequence of strings>)``
-3     neither found            ``(None, None)``
-===== =======================  ============
-
-Note that in case 2 a sequence of strings is returned.  This is to
+Note that multiple path entries per finder are allowed.  This is to
 support the case where a finder discovers multiple namespace portions
 for a given ``fullname``.  Many finders will support only a single
 namespace package portion per ``find_loader`` call, in which case this
-will normally be a list containing only a single string.
+iterable will be a list containing only a single string.
 
-Legacy finders which implement ``find_module`` but not ``find_loader``
-will be unable to contribute portions to a namespace package.  The
-import machinery will call ``find_loader`` if it exists, else fall
-back to ``find_module``.
+The import machinery will call ``find_loader`` if it exists, else fall
+back to ``find_module``.  Legacy finders which implement
+``find_module`` but not ``find_loader`` will be unable to contribute
+portions to a namespace package.
 
 The specification expands PEP 302 loaders to include an optional method called
 ``module_repr()`` which if present, is used to generate module object reprs.

-- 
Repository URL: http://hg.python.org/peps


More information about the Python-checkins mailing list