Issue 31723: Support for python3 in jenkins_script module #33206
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
SUMMARY
Make jenkins_script module compatible with python3 by convert bytes to str when necessary
Fixes #31723
ISSUE TYPE
COMPONENT NAME
jenkins_script
ANSIBLE VERSION
ADDITIONAL INFORMATION
In python3, ansible's
fetch_url
utility function wrapsurllib.request.urlopen
.For HTTP and HTTPS URLs, this function returns a
http.client.HTTPResponse
object slightly modified.Calling
.read()
on anHTTPResponse
object returns bytes (note the docstring fix).Here,
to_native
is used to convert the bytestrings returned byfetch_url
into unicode strings.This is necessary because:
json.loads
requires passing a string, not a bytestring, as its argumentusing the 'in' operator will raise a
TypeError
see:
before:
after: