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

Issues with string concat and implicit conversion of bytes to chars #20588

Closed
quinn opened this issue Jan 24, 2017 · 4 comments · Fixed by #20835
Closed

Issues with string concat and implicit conversion of bytes to chars #20588

quinn opened this issue Jan 24, 2017 · 4 comments · Fixed by #20835
Labels
affects_2.3 This issue/PR affects Ansible v2.3 c:inventory/script

Comments

@quinn
Copy link

quinn commented Jan 24, 2017

in ansible/inventory/script.py there is code like:

if not isinstance(self.raw, Mapping):
    sys.stderr.write(err + "\n")
    raise AnsibleError("failed to parse executable inventory script results from {0}: data needs to be formatted as a json dict".format(to_native(self.filename)))

I had to to change to this to get the actual error message (instead of the encoding error): sys.stderr.write(err.decode('ascii') + "\n")

I'm running python 3.

@ansibot ansibot added affects_2.3 This issue/PR affects Ansible v2.3 needs_triage Needs a first human triage before being processed. labels Jan 24, 2017
@ryansb ryansb added needs_info This issue requires further information. Please answer any outstanding questions. and removed needs_triage Needs a first human triage before being processed. labels Jan 24, 2017
@ryansb
Copy link
Contributor

ryansb commented Jan 24, 2017

Can you add information about how to reproduce the error message? Just running inventory scripts under Python 3?

@quinn
Copy link
Author

quinn commented Jan 24, 2017

Yes, I'm working on an inventory script. The error message was the one above "data needs to be formatted as a json dict" but instead I was getting "Can't convert 'bytes' object to str implicitly" error

@quinn
Copy link
Author

quinn commented Jan 24, 2017

Also, I am running ansible 2.1, but the source in the master branch here (assuming that is 2.3) I assume has the same problem because it is not encoding the err object

@ansibot ansibot removed the needs_info This issue requires further information. Please answer any outstanding questions. label Jan 24, 2017
ryansb added a commit to ryansb/ansible that referenced this issue Jan 30, 2017
@ryansb
Copy link
Contributor

ryansb commented Jan 30, 2017

@quinn here's a patch that should resolve the problem for you, using our to_native method rather than manual decode. Can you give it a try? #20835

@ansible ansible locked and limited conversation to collaborators Apr 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.3 This issue/PR affects Ansible v2.3 c:inventory/script
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants