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

Use io.open() when running on Python 2 #5107

Merged
merged 2 commits into from
Dec 18, 2020
Merged

Use io.open() when running on Python 2 #5107

merged 2 commits into from
Dec 18, 2020

Conversation

blag
Copy link
Contributor

@blag blag commented Dec 18, 2020

This PR fixes a regression introduced by #5106. That code runs within a pack's virtualenv, and because we are still supporting Python 2 in StackStorm Exchange packs, we also need to support Python 2 in st2common/content/loader.py.

Using the encoding keyword argument to open() works on Python 3, but the native open() on Python 2 does not accept the encoding argument.

Instead, this PR imports io.open when running on Python 2, which should resolve the issue.

Thanks to @nmaludy for tracking down the issue and @armab for pointing this Stack Overflow post out on Slack.

@pull-request-size pull-request-size bot added the size/XS PR that changes 0-9 lines. Quick fix/merge. label Dec 18, 2020
@blag
Copy link
Contributor Author

blag commented Dec 18, 2020

See the Ansible pack CI for illuminating this regression.

That issue will affect all Python 2 pack CI runs, which will be ~160 starting later today.

CHANGELOG.rst Show resolved Hide resolved
@blag
Copy link
Contributor Author

blag commented Dec 18, 2020

Thanks for the review! Will merge this later today once all of the CI (except for maybe Travis) are green.

@blag blag added this to the 3.4.0 milestone Dec 18, 2020
@blag blag merged commit 7ad17fd into master Dec 18, 2020
@blag blag deleted the fix-open-python2 branch December 18, 2020 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug packs python3 regression size/XS PR that changes 0-9 lines. Quick fix/merge.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants