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

Makes fully compatible with Python 3 #25

Merged
merged 2 commits into from
Feb 19, 2019

Conversation

overhacked
Copy link
Contributor

The plugin is calling exec_command() from Ansible's SSH connection plugin, which returns b'' strings. I was getting a TypeError when sshjail tried to split the byte string with a native string in Python 3. That's fixed by the first commit.

The second commit ensures that values used later in a native string context are converted to native strings using Ansible's Python 2- and 3-friendly to_text() method.

Treating it as b'' in Python 2.6+ will work, also.
BaseConnection returns byte strings, but we need
to convert extracted values to native/Unicode strings
in a Python 2 and 3 compatible way. The attempt here
is to keep stdout as a byte string until the latest
possible moment when the extracted substring is
converted.
@overhacked
Copy link
Contributor Author

I've been running this well in production for a few months. Any chance of merging? Thanks!

@dch
Copy link
Contributor

dch commented Feb 19, 2019

LGTM - thanks!

@austinhyde
Copy link
Owner

Argh, sorry I've let this languish. This looks good to me, thanks for doing this!

@austinhyde austinhyde merged commit 62f36d7 into austinhyde:master Feb 19, 2019
@austinhyde austinhyde mentioned this pull request Feb 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants