Message367021
I added os.waitstatus_to_exitcode() in bpo-40094. I propose to replace _compute_returncode() with os.waitstatus_to_exitcode() in Lib/asyncio/unix_events.py to simplify the code *and* to raise an exception if asyncio gets an unexpected wait status from os.waitpid().
There is a comment which suggest to detect when asyncio gets an unexpected status, see the last comment of:
def _compute_returncode(status):
if os.WIFSIGNALED(status):
# The child process died because of a signal.
return -os.WTERMSIG(status)
elif os.WIFEXITED(status):
# The child process exited (e.g sys.exit()).
return os.WEXITSTATUS(status)
else:
# The child exited, but we don't understand its status.
# This shouldn't happen, but if it does, let's just
# return that status; perhaps that helps debug it.
return status
Replacing _compute_returncode() with os.waitstatus_to_exitcode() in Lib/asyncio/unix_events.py is trivial. The problem is to update Lib/test/test_asyncio/test_unix_events.py which uses tons of mocks on os.W*() functions (ex: os.WIFEXITED()).
I'm not sure how tests should be updated.
Is there someone interested to propose a PR for that? |
|
Date |
User |
Action |
Args |
2020-04-22 16:51:11 | vstinner | set | recipients:
+ vstinner, asvetlov, yselivanov, corona10, aeros |
2020-04-22 16:51:11 | vstinner | set | messageid: <1587574271.75.0.606427962214.issue40364@roundup.psfhosted.org> |
2020-04-22 16:51:11 | vstinner | link | issue40364 messages |
2020-04-22 16:51:11 | vstinner | create | |
|