Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require loaders set __loader__ and __package__ #58851

Closed
brettcannon opened this issue Apr 22, 2012 · 3 comments
Closed

Require loaders set __loader__ and __package__ #58851

brettcannon opened this issue Apr 22, 2012 · 3 comments
Assignees
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) release-blocker type-bug An unexpected behavior, bug, or error

Comments

@brettcannon
Copy link
Member

BPO 14646
Nosy @brettcannon, @ericsnowcurrently

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/brettcannon'
closed_at = <Date 2012-04-27.21:42:35.448>
created_at = <Date 2012-04-22.19:37:53.126>
labels = ['interpreter-core', 'type-bug', 'release-blocker']
title = 'Require loaders set __loader__ and __package__'
updated_at = <Date 2012-04-27.21:42:35.447>
user = 'https://github.com/brettcannon'

bugs.python.org fields:

activity = <Date 2012-04-27.21:42:35.447>
actor = 'brett.cannon'
assignee = 'brett.cannon'
closed = True
closed_date = <Date 2012-04-27.21:42:35.448>
closer = 'brett.cannon'
components = ['Interpreter Core']
creation = <Date 2012-04-22.19:37:53.126>
creator = 'brett.cannon'
dependencies = []
files = []
hgrepos = []
issue_num = 14646
keywords = []
message_count = 3.0
messages = ['158983', '158984', '159495']
nosy_count = 4.0
nosy_names = ['brett.cannon', 'Arfrever', 'python-dev', 'eric.snow']
pr_nums = []
priority = 'release blocker'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue14646'
versions = ['Python 3.3']

@brettcannon
Copy link
Member Author

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

@brettcannon brettcannon self-assigned this Apr 22, 2012
@brettcannon brettcannon added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error labels Apr 22, 2012
@ericsnowcurrently
Copy link
Member

Yeah, that patch for reload() in bpo-13959 relies on this.

@python-dev
Copy link
Mannequin

python-dev mannequin commented Apr 27, 2012

New changeset 496c68f90a03 by Brett Cannon in branch 'default':
Issue bpo-14646: __import__() now sets __loader__ if need be.
http://hg.python.org/cpython/rev/496c68f90a03

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) release-blocker type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants