classification
Title: Require loaders set __loader__ and __package__
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: brett.cannon Nosy List: Arfrever, brett.cannon, eric.snow, python-dev
Priority: release blocker Keywords:

Created on 2012-04-22 19:37 by brett.cannon, last changed 2012-04-27 21:42 by brett.cannon. This issue is now closed.

Messages (3)
msg158983 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2012-04-22 19:37
As discussed and agreed to on python-dev, it makes sense to require loaders to set __loader__ and __package__ so that they can be relied upon by globally executed code in a module.

The following needs to happen to close this bug:

* Update PEP 302 to say __loader__ is required, not optional
* Update PEP 366 to say __package__ is required
* Update PEP 302 to point to PEP 366 and mention the requirement
* Update importlib.util.module_for_loader to set both __loader__ and __package__
* Update importlib.util.set_loader and importlib.util.set_package to point out that module_for_loader supercedes those decorators
* Update importlib._bootstrap to set __loader__ when it is absent
msg158984 - (view) Author: Eric Snow (eric.snow) * (Python committer) Date: 2012-04-22 19:51
Yeah, that patch for reload() in issue13959 relies on this.
msg159495 - (view) Author: Roundup Robot (python-dev) Date: 2012-04-27 21:33
New changeset 496c68f90a03 by Brett Cannon in branch 'default':
Issue #14646: __import__() now sets __loader__ if need be.
http://hg.python.org/cpython/rev/496c68f90a03
History
Date User Action Args
2012-04-27 21:42:35brett.cannonsetstatus: open -> closed
resolution: fixed
stage: test needed -> resolved
2012-04-27 21:33:07python-devsetnosy: + python-dev
messages: + msg159495
2012-04-22 20:23:57Arfreversetnosy: + Arfrever
2012-04-22 19:51:48eric.snowsetnosy: + eric.snow
messages: + msg158984
2012-04-22 19:37:53brett.cannoncreate