-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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 python3 error in repoquery #4183
Conversation
Explicitly convert from bytes to string so that splitting the string is successful. This change works with python 2 as well. Closes openshift#4182
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ran across this issue and the fix worked for me. If this is a python2 vs python3 error, consider using the Six module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will work. Made a note about a possible future fix to avoid this happening in other lib_utils
modules.
@@ -48,7 +48,7 @@ def process_versions(query_output): | |||
|
|||
version_dict = defaultdict(dict) | |||
|
|||
for version in query_output.split('\n'): | |||
for version in query_output.decode().split('\n'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be hit by other items using _run
(local ref). It may be a better fix to decode()
before _run
returns.
Here is what was done in lib_openshift.
@@ -45,7 +45,7 @@ def test_querying_a_package(self, mock_cmd): | |||
|
|||
# Return values of our mocked function call. These get returned once per call. | |||
mock_cmd.side_effect = [ | |||
(0, '4.2.46|21.el7_3|x86_64|rhel-7-server-rpms|4.2.46-21.el7_3', valid_stderr), # first call to the mock | |||
(0, b'4.2.46|21.el7_3|x86_64|rhel-7-server-rpms|4.2.46-21.el7_3', valid_stderr), # first call to the mock |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 as b''
in Python 2 will become a str
while staying bytes
in 3.
aos-ci-test |
[merge] |
flake openshift/origin#10773 |
[merge] |
Evaluated for openshift ansible merge up to 7fb814d |
[test]ing while waiting on the merge queue |
Evaluated for openshift ansible test up to 7fb814d |
continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_request_openshift_ansible/127/) (Base Commit: eedd16a) |
continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/merge_pull_request_openshift_ansible/407/) (Base Commit: 2677014) |
Explicitly convert from bytes to string so that splitting the string is
successful. This change works with python 2 as well.
Closes #4182