This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2012年04月20日 04:31 by eric.snow, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Messages (5) | |||
|---|---|---|---|
| msg158793 - (view) | Author: Eric Snow (eric.snow) * (Python committer) | Date: 2012年04月20日 04:31 | |
(see #14609 and #14582) http://docs.python.org/dev/reference/simple_stmts.html#the-import-statement 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. |
|||
| msg158833 - (view) | Author: Brett Cannon (brett.cannon) * (Python committer) | Date: 2012年04月20日 15:13 | |
So I think the sentence is saying exactly what is going on, but you want clarification that the module object is originating from sys.modules specifically. So you could change the sentence to "The first form of import statement binds the module name in the local namespace to the module object as found in sys.modules." |
|||
| msg158841 - (view) | Author: Eric Snow (eric.snow) * (Python committer) | Date: 2012年04月20日 15:27 | |
Sounds mostly right. sys.modules[name] won't necessarily contain a module object, as Benjamin brought up in issue14609. |
|||
| msg158843 - (view) | Author: Brett Cannon (brett.cannon) * (Python committer) | Date: 2012年04月20日 15:34 | |
OK, so you say "to the object found in sys.modules." |
|||
| msg158879 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2012年04月20日 19:58 | |
New changeset 150bd84e737e by Brett Cannon in branch 'default': Issue #14628: Document the fact that import always returns the module http://hg.python.org/cpython/rev/150bd84e737e |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:29 | admin | set | github: 58833 |
| 2012年04月20日 19:58:32 | brett.cannon | set | status: open -> closed assignee: docs@python -> brett.cannon resolution: fixed stage: resolved |
| 2012年04月20日 19:58:04 | python-dev | set | nosy:
+ python-dev messages: + msg158879 |
| 2012年04月20日 15:34:07 | brett.cannon | set | messages: + msg158843 |
| 2012年04月20日 15:27:57 | eric.snow | set | messages: + msg158841 |
| 2012年04月20日 15:13:51 | brett.cannon | set | messages: + msg158833 |
| 2012年04月20日 06:14:51 | Arfrever | set | nosy:
+ Arfrever |
| 2012年04月20日 04:31:07 | eric.snow | create | |