From e2d0295f0f016db18bbf87b40ee6b64277a6b048 Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Sun, 29 Apr 2007 20:19:50 +0000 Subject: [PATCH] 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. --- pep-0302.txt | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pep-0302.txt b/pep-0302.txt index ffcf68204..b387c80a6 100644 --- a/pep-0302.txt +++ b/pep-0302.txt @@ -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).