Fixup #17 which replaced commands.getstatusoutput() without taking the changed return code into account#22
Merged
bernhardkaindl merged 2 commits intoNov 28, 2023
Conversation
…usoutput() Fix the 1st commit of #17 which replaced commands.getstatusoutput() with subprocess.getstatusoutput() without taking the change of the status code into account: Unfortunately, the Python3 developers broke the compatibility: The return code changes: python2 -c 'import commands ; print( commands.getstatusoutput("false"))' (256, '') python3 -c 'import subprocess; print(subprocess.getstatusoutput("false"))' (1, '') With commands.getstatusoutput(), you had to use this to get the actual exit code: status = os.WEXITSTATUS(status) These calls have to be removed because now they just shift away the error code: As shown at benjaminp/six#207, the operation is just `status >> 8` Luckily, the status code is checked to against 0 at most places, so there is no change for these checks. There is only one location where a bit is checked. Fix this location too. Also, that commit did not take into account that subprocess.get*output do not exist in Python2, which goes against the directive by Andrew in PR #16 where he requires that we keep Python2 working: The current master branch works neither for Python2, nor Python3 - fix this breakage in the 2nd commit. Signed-off-by: Bernhard Kaindl <bernhard.kaindl@cloud.com>
Fix the code base to work at least with one Python version(Python2) After the previous commit updated the code base to work with the exit status returned by Python3 getstatusoutput(), add a compatible wrapper for commands.getstatusoutput() to have one Python version functional. Signed-off-by: Bernhard Kaindl <bernhard.kaindl@cloud.com>
42b5980 to
d436071
Compare
andyhhp
approved these changes
Nov 24, 2023
liulinC
approved these changes
Nov 27, 2023
Collaborator
There was a problem hiding this comment.
I know the purpose of py2 compatible code,
But we have agreed master branch is target py3 only, for simple and clean (As both xs8 stream and xs9 have py3).
We are targeting to remove py2 code.
For Yangtze (will be EoL in 2024) which is py2 only, we will branch out for support if necessary.
GeraldEV
approved these changes
Nov 27, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fix the 1st commit of #17 which replaced
commands.getstatusoutput()withsubprocess.getstatusoutput()without taking the change of thestatuscode into account:Unfortunately, the Python3 developers broke the compatibility: The return code changes!!!
With commands.getstatusoutput(), you had to use this to get the actual exit code:
These calls have to be removed because now they just shift away the error code:
As shown at benjaminp/six#207, the operation is just
status >> 8Luckily, the status code is checked to against 0 at most places, so there is no change
for these checks. There is only one location where a bit is checked. Fix this location too.
Also, that commit did not take into account that
subprocess.get*outputdo not existin
Python2, which goes against the directive by Andrew in PR #16 where he requiresthat we keep Python2 working:
The current master branch works neither for Python2 nor Python3.
Fix this breakage in the 2nd commit:
Fix the code base to work at least with one Python version(Python2)
After the previous commit updated the code base to work with the exit status
returned by Python3
getstatusoutput(), add a compatible wrapper forcommands.getstatusoutput()to have one Python version functional.