Author eric.snow
Recipients benjamin.peterson, brett.cannon, docs@python, eric.snow
Date 2012-04-20.04:31:06
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
(see #14609 and #14582)

The specification for the import statement says the following:

"The first form of import statement binds the module name in the local namespace to the module object".

This is not the case and has not been the case perhaps ever.  Instead of getting bound to the module (returned by loader.load_module() during import), the name is bound to the value at sys.modules[module_name].

Normally two approaches yield the same result.  However, if during import the sys.modules value for the module is assigned to something else, the behavior deviates from the specfication.  See #14609 for an example.

Considering the backwards-compatibility issues, the language reference should be updated to reflect the actual behavior.
Date User Action Args
2012-04-20 04:31:07eric.snowsetrecipients: + eric.snow, brett.cannon, benjamin.peterson, docs@python
2012-04-20 04:31:07eric.snowsetmessageid: <>
2012-04-20 04:31:07eric.snowlinkissue14628 messages
2012-04-20 04:31:06eric.snowcreate