[Python-checkins] python/nondist/peps pep-0302.txt,1.13,1.14
pje at users.sourceforge.net
pje at users.sourceforge.net
Thu Sep 23 06:06:42 CEST 2004
Update of /cvsroot/python/python/nondist/peps
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18527
Modified Files:
pep-0302.txt
Log Message:
Fix specification error that makes it impossible for 'reload()' to work
correctly with PEP 302 module loaders. See also SF#1029475, and:
http://mail.python.org/pipermail/python-dev/2004-September/048970.html
Index: pep-0302.txt
===================================================================
RCS file: /cvsroot/python/python/nondist/peps/pep-0302.txt,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- pep-0302.txt 2 Jan 2003 18:47:04 -0000 1.13
+++ pep-0302.txt 23 Sep 2004 04:06:40 -0000 1.14
@@ -240,16 +240,22 @@
The load_module() method has a few responsibilities that it must
fulfill *before* it runs any code:
- - It must create the module object. From Python this can be done
+ - It must use the existing module object from sys.modules, if one
+ exists. (Otherwise, the reload() builtin will not work
+ correctly.)
+
+ - If a module object is not already present in sys.modules, the
+ loader must create a module object. From Python this can be done
via the new.module() function, the imp.new_module() function or
via the module type object; from C with the PyModule_New()
function or the PyImport_ModuleAdd() function. The latter also
does the following step:
- - It must add the module to sys.modules. This is crucial because
- the module code may (directly or indirectly) import itself; adding
- it to sys.modules beforehand prevents unbounded recursion in the
- worst case and multiple loading in the best.
+ - It must add the module to sys.modules, if it was not already
+ present there. This is crucial because the module code may
+ (directly or indirectly) import itself; adding it to sys.modules
+ beforehand prevents unbounded recursion in the worst case and
+ multiple loading in the best.
- The __file__ attribute must be set. This must be a string, but it
may be a dummy value, for example "<frozen>". The privilege of
More information about the Python-checkins
mailing list