diff --git a/pep-0302.txt b/pep-0302.txt index 7fcca4f05..898b0a0b8 100644 --- a/pep-0302.txt +++ b/pep-0302.txt @@ -251,21 +251,16 @@ Specification part 1: The Importer Protocol the loader must create a new module object and add it to sys.modules. - In C code, all of these requirements can be met simply by using - the PyImport_AddModule() function, which returns the existing - module or creates a new one and adds it to sys.modules for you. - In Python code, you can use something like: - - module = sys.modules.setdefault(fullname, new.module(fullname)) - - to accomplish the same results. - Note that the module object *must* be in sys.modules before the loader executes the module code. 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. + If the load fails, the loader needs to remove any module it may have + inserted into sys.modules. If the module was already in + sys.modules then the loader should leave it alone. + - The __file__ attribute must be set. This must be a string, but it may be a dummy value, for example "". The privilege of not having a __file__ attribute at all is reserved for built-in