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

Fix importlib pyc loading order #48593

Merged
merged 1 commit into from Jul 17, 2018

Conversation

Projects
None yet
4 participants
@pritambaral
Contributor

pritambaral commented Jul 15, 2018

What does this PR do?

Fixes the order in SUFFIXES to place '.py' before '.pyc' when using importlib (i.e., on Python versions 3.5 and above), the same order that imp.get_suffixes() (deprecated from Python 3.5 onwards) returns its result in.

What issues does this PR fix or reference?

Fixes #46924

Also see: #48195 (comment)

Previous Behavior

On Python 3.5 and newer, .pyc files are preferred by the loader to .py files.

New Behavior

.py files are preferred by the loader to .pyc files.

Tests written?

No

Commits signed with GPG?

Yes

Additional Notes

The patch in this PR has been verified to apply cleanly when cherry-picked onto v2018.3.

loader: Fix suffix order when importlib is used
On Python versions 2 and 3.0-3.4, imp.get_suffixes() is used to get the suffixes
in an ordered list, which contains '.py' before '.pyc'. On Python versions 3.5
and above, our code to construct such a list using importlib.machinery
inadvertently places '.pyc' before '.py'. This, combined with the effects of
4951b9a means that things like #46924 happen.

This fixes #46924 by constructing `SUFFIXES` in the same order
imp.get_suffixes() constructs its result.

@pritambaral pritambaral requested a review from saltstack/team-core as a code owner Jul 15, 2018

@salt-jenkins salt-jenkins requested a review from saltstack/team-suse Jul 15, 2018

@terminalmage

I actually have this exact change as part of a set of loader fixes I'm working on (but haven't yet opened a PR).

@rallytime rallytime requested a review from thatch45 Jul 16, 2018

@isbm

isbm approved these changes Jul 17, 2018

@terminalmage terminalmage merged commit 47b1032 into saltstack:2017.7 Jul 17, 2018

10 of 16 checks passed

jenkins/PR/salt-pr-linode-ubuntu16-py3 Pull Requests » Salt PR - Linode Ubuntu16.04 - PY3 #11443 — ABORTED
Details
default Build finished.
Details
jenkins/PR/salt-pr-linode-cent7-py3 Pull Requests » Salt PR - Linode CentOS 7 - PY3 #6473 — FAILURE
Details
jenkins/PR/salt-pr-rs-cent7-n Pull Requests » Salt PR - RS CentOS 7 #20526 — FAILURE
Details
jenkins/pr/py2-centos-7 The py2-centos-7 job has failed
Details
jenkins/pr/py3-centos-7 The py3-centos-7 job has failed
Details
WIP ready for review
Details
continuous-integration/jenkins/pr-merge This commit looks good
Details
jenkins/PR/salt-pr-clone Pull Requests » Salt PR - Clone #26689 — SUCCESS
Details
jenkins/PR/salt-pr-docs-n Pull Requests » Salt PR - Docs #18718 — SUCCESS
Details
jenkins/PR/salt-pr-linode-ubuntu14-n Pull Requests » Salt PR - Linode Ubuntu14.04 #24401 — SUCCESS
Details
jenkins/PR/salt-pr-lint-n Pull Requests » Salt PR - Code Lint #23355 — SUCCESS
Details
jenkins/pr/docs The docs job has passed
Details
jenkins/pr/lint The lint job has passed
Details
jenkins/pr/py2-ubuntu-1604 The py2-ubuntu-1604 job has passed
Details
jenkins/pr/py3-ubuntu-1604 The py3-ubuntu-1604 job has passed
Details

@pritambaral pritambaral deleted the pritambaral:fix/2017.7-importlib-pyc-loading-order branch Jul 21, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment