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

set __path__ = [] for frozen packages #62265

Closed
brettcannon opened this issue May 25, 2013 · 2 comments
Closed

set __path__ = [] for frozen packages #62265

brettcannon opened this issue May 25, 2013 · 2 comments
Assignees
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@brettcannon
Copy link
Member

BPO 18065
Nosy @warsaw, @brettcannon

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 2013-06-01.03:23:06.081>
created_at = <Date 2013-05-25.23:21:02.008>
labels = ['interpreter-core', 'type-bug']
title = 'set __path__ = [] for frozen packages'
updated_at = <Date 2013-06-01.03:23:06.080>
user = 'https://github.com/brettcannon'

bugs.python.org fields:

activity = <Date 2013-06-01.03:23:06.080>
actor = 'brett.cannon'
assignee = 'brett.cannon'
closed = True
closed_date = <Date 2013-06-01.03:23:06.081>
closer = 'brett.cannon'
components = ['Interpreter Core']
creation = <Date 2013-05-25.23:21:02.008>
creator = 'brett.cannon'
dependencies = []
files = []
hgrepos = []
issue_num = 18065
keywords = []
message_count = 2.0
messages = ['190034', '190436']
nosy_count = 3.0
nosy_names = ['barry', 'brett.cannon', 'python-dev']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue18065'
versions = ['Python 3.4']

@brettcannon
Copy link
Member Author

If you import the frozen __phello__ package, you will notice that __phello__.__path__ == ['__phello__']. While that seems innocuous, that could potentially lead to incorrect results if there just so happens to be a directory named __phello__ which contains a file that isn't a frozen submodule (i.e. FrozenImporter can't find the submodule but PathFinder can find a file that happens to match the module's name).

So for that reason I want to simply set __path__ = [] for frozen packages. The language reference for import states setting __path__ to anything makes a module a package and that it just needs to be an iterable that only returns strings (http://docs.python.org/3.4/reference/import.html#packages), so an empty list works. Plus __package__ contains the same information so there is no lost data by doing this.

Can anyone think of a good reason not to do this? I can't see why someone would be relying upon this for any reason since the existence of __path__ itself is enough to determine something is a package.

@brettcannon brettcannon self-assigned this May 25, 2013
@brettcannon brettcannon added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error labels May 25, 2013
@python-dev
Copy link
Mannequin

python-dev mannequin commented Jun 1, 2013

New changeset 82db02a2e023 by Brett Cannon in branch 'default':
Issue bpo-18065: For frozen packages set __path__ to [].
http://hg.python.org/cpython/rev/82db02a2e023

@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) type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant