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.

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

Created on 2012-04-22 19:37 by brett.cannon, last changed 2022-04-11 14:57 by admin. 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) (Python triager) Date: 2012-04-27 21:33
New changeset 496c68f90a03 by Brett Cannon in branch 'default':
Issue #14646: __import__() now sets __loader__ if need be.
Date User Action Args
2022-04-11 14:57:29adminsetnosy: + georg.brandl
github: 58851
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