Skip to content

bpo-30645: use an internal variable while iterating in imp.load_package() #2268

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

Merged
merged 3 commits into from
Jun 23, 2017
Merged

bpo-30645: use an internal variable while iterating in imp.load_package() #2268

merged 3 commits into from
Jun 23, 2017

Conversation

commodo
Copy link
Contributor

@commodo commodo commented Jun 18, 2017

The imp.load_package() function is marked as deprecated,
however, some packages (like virtualenv) seem to use it.

The problem with that loop, is that if the .py file
does not exist, you'll get a
<path-to-package>__init__.py/__init__.pyc file.

When shipping only Python bytecodes, we don't want that.

Signed-off-by: Alexandru Ardelean [email protected]

@mention-bot
Copy link

@commodo, thanks for your PR! By analyzing the history of the files in this pull request, we identified @brettcannon, @ericsnowcurrently and @ncoghlan to be potential reviewers.

@brettcannon brettcannon added needs backport to 2.7 type-bug An unexpected behavior, bug, or error labels Jun 19, 2017
@brettcannon brettcannon self-requested a review June 19, 2017 17:01
@brettcannon
Copy link
Member

@commodo Did you want to add yourself to the ACKS file and write an entry for Misc/NEWS (somewhere not at the top of the Library section to avoid merge conflicts)?

@commodo
Copy link
Contributor Author

commodo commented Jun 19, 2017

ack
added myself;
force pushed PR

thanks :)

Misc/NEWS Outdated
@@ -381,6 +381,8 @@ Library
- bpo-30508: Don't log exceptions if Task/Future "cancel()" method was
called.

- bpo-30645: use an internal variable while iterating in imp.load_package()

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"use an internal variable" is implementation detail and it's not suitable for NEWS entry.
Please describe the bug you fixed.

@commodo
Copy link
Contributor Author

commodo commented Jun 20, 2017

ack
re-spinned

commodo and others added 3 commits June 21, 2017 14:48
…ge()

The imp.load_package() function is marked as deprecated,
however, some packages (like virtualenv) seem to use it.

The problem with that loop, is that if the .py file
does not exist, you'll get a
`<path-to-package>__init__.py/__init__.pyc` file.

When shipping only Python bytecodes, we don't want that.

Signed-off-by: Alexandru Ardelean <[email protected]>
Copy link
Member

@brettcannon brettcannon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not worrying about tests since the problem is very obvious and this whole module is actually deprecated.

@brettcannon brettcannon merged commit c38e32a into python:master Jun 23, 2017
brettcannon pushed a commit to brettcannon/cpython that referenced this pull request Jun 23, 2017
…ythonGH-2268)

Bug didn't manifest itself when importing a module with source as .py files are always the first on the search path. The issue only showed up in bytecode-only packages where the calculated file path would be ``__init__.py/__init__.pyc``.

Patch by Alexandru Ardelean.

(cherry picked from commit c38e32a)
brettcannon added a commit to brettcannon/cpython that referenced this pull request Jun 23, 2017
…ge() (pythonGH-2268)

Bug didn't manifest itself when importing a module with source as .py files are always the first on the search path. The issue only showed up in bytecode-only packages where the calculated file path would be ``__init__.py/__init__.pyc``.

Patch by Alexandru Ardelean..
(cherry picked from commit c38e32a)
@bedevere-bot
Copy link

GH-2364 is a backport of this pull request to the 3.6 branch.

brettcannon pushed a commit to brettcannon/cpython that referenced this pull request Jun 23, 2017
…ge() (pythonGH-2268)

Bug didn't manifest itself when importing a module with source as .py files are always the first on the search path. The issue only showed up in bytecode-only packages where the calculated file path would be ``__init__.py/__init__.pyc``.

Patch by Alexandru Ardelean..
(cherry picked from commit c38e32a)
@bedevere-bot
Copy link

GH-2365 is a backport of this pull request to the 3.5 branch.

@brettcannon
Copy link
Member

Thanks for the PR, @commodo !

brettcannon added a commit that referenced this pull request Jun 23, 2017
…ge() (GH-2268) (#2364)

Bug didn't manifest itself when importing a module with source as .py files are always the first on the search path. The issue only showed up in bytecode-only packages where the calculated file path would be ``__init__.py/__init__.pyc``.

Patch by Alexandru Ardelean.

(cherry picked from commit c38e32a)
brettcannon added a commit that referenced this pull request Jun 23, 2017
…ge() (GH-2268) (GH-2365)

Bug didn't manifest itself when importing a module with source as .py files are always the first on the search path. The issue only showed up in bytecode-only packages where the calculated file path would be ``__init__.py/__init__.pyc``.

Patch by Alexandru Ardelean.
(cherry picked from commit c38e32a)
@commodo
Copy link
Contributor Author

commodo commented Jun 24, 2017

thank you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants