[Python-checkins] r55020 - peps/trunk/pep-0302.txt

brett.cannon python-checkins at python.org
Sun Apr 29 22:19:52 CEST 2007


Author: brett.cannon
Date: Sun Apr 29 22:19:50 2007
New Revision: 55020

Modified:
   peps/trunk/pep-0302.txt
Log:
Specify that load_module is to raise ImportError if an error has occurred and
no exceptino is being propagated or it has been asked to load a module that it
cannot.

Also specify that __name__ must be set on all loaded modules.


Modified: peps/trunk/pep-0302.txt
==============================================================================
--- peps/trunk/pep-0302.txt	(original)
+++ peps/trunk/pep-0302.txt	Sun Apr 29 22:19:50 2007
@@ -223,9 +223,13 @@
 
         loader.load_module(fullname)
 
-    This method returns the loaded module.  In many cases the importer
-    and loader can be one and the same object: importer.find_module()
-    would just return self.
+    This method returns the loaded module or raises and exception,
+    preferably ImportError if an existing exception is not being
+    propagated.  If load_module() is asked to laod a module that it
+    cannot, ImportError is to be raised.
+    
+    In many cases the importer and loader can be one and the same
+    object: importer.find_module() would just return self.
 
     The 'fullname' argument of both methods is the fully qualified
     module name, for example "spam.eggs.ham".  As explained above, when
@@ -267,6 +271,9 @@
       not having a __file__ attribute at all is reserved for built-in
       modules.
 
+    - The __name__ attribute must be set.  If one uses
+      imp.new_module() then the attribute is set automatically.
+
     - If it's a package, the __path__ variable must be set.  This must
       be a list, but may be empty if __path__ has no further
       significance to the importer (more on this later).


More information about the Python-checkins mailing list