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.
This commit is contained in:
Brett Cannon 2007-04-29 20:19:50 +00:00
parent fd3f447b80
commit e2d0295f0f
1 changed files with 10 additions and 3 deletions

View File

@ -223,9 +223,13 @@ Specification part 1: The Importer Protocol
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 @@ Specification part 1: The Importer Protocol
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).