[Python-checkins] peps: [PEP 451] "target" arg of find_spec() is not exclusive to reloading.

eric.snow python-checkins at python.org
Tue Nov 5 00:45:08 CET 2013


http://hg.python.org/peps/rev/b8c8299914c5
changeset:   5253:b8c8299914c5
user:        Eric Snow <ericsnowcurrently at gmail.com>
date:        Mon Nov 04 16:40:45 2013 -0700
summary:
  [PEP 451] "target" arg of find_spec() is not exclusive to reloading.

files:
  pep-0451.txt |  33 +++++++++++++++++++--------------
  1 files changed, 19 insertions(+), 14 deletions(-)


diff --git a/pep-0451.txt b/pep-0451.txt
--- a/pep-0451.txt
+++ b/pep-0451.txt
@@ -717,22 +717,27 @@
 The "target" parameter of find_spec()
 -------------------------------------
 
-A module object with the same name as the "name" argument (or None, the
-default) should be passed in to "exising".  This argument allows the
-finder to build the module spec with more information than is otherwise
-available.  This is particularly relevant in identifying the loader to
-use.
+A call to find_spec() may optionally include a "target" argument.  This
+is the module object that will be used subsequently as the target of
+loading.  During normal import (and by default) "target" is None,
+meaning the target module has yet to be created.  During reloading the
+module passed in to reload() is passed through to find_spec() as the
+target.  This argument allows the finder to build the module spec with
+more information than is otherwise available.  Doing so is particularly
+relevant in identifying the loader to use.
 
 Through find_spec() the finder will always identify the loader it
-will return in the spec.  In the case of reload, at this point the
-finder should also decide whether or not the loader supports loading
-into the module-to-be-reloaded (which was passed in to find_spec() as
-"target").  This decision may entail consulting with the loader.  If
-the finder determines that the loader does not support reloading that
-module, it should either find another loader or raise ImportError
-(completely stopping import of the module).  This reload decision is
-important since, as noted in `How Reloading Will Work`_, loaders will
-no longer be able to trivially identify a reload situation on their own.
+will return in the spec (or return None).  At the point the loader is
+identified, the finder should also decide whether or not the loader
+supports loading into the target module, in the case that "target" is
+passed in.  This decision may entail consulting with the loader.
+
+If the finder determines that the loader does not support loading into
+the target module, it should either find another loader or raise
+ImportError (completely stopping import of the module).  This
+determination is especially important during reload since, as noted in
+`How Reloading Will Work`_, loaders will no longer be able to trivially
+identify a reload situation on their own.
 
 Two alternatives were presented to the "target" parameter:
 Loader.supports_reload() and adding "target" to Loader.exec_module()

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


More information about the Python-checkins mailing list