This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients aeros, asvetlov, corona10, vstinner, yselivanov
Date 2020-04-22.16:51:11
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
I added os.waitstatus_to_exitcode() in bpo-40094. I propose to replace _compute_returncode() with os.waitstatus_to_exitcode() in Lib/asyncio/ 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)
        # 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/ is trivial. The problem is to update Lib/test/test_asyncio/ 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:11vstinnersetrecipients: + vstinner, asvetlov, yselivanov, corona10, aeros
2020-04-22 16:51:11vstinnersetmessageid: <>
2020-04-22 16:51:11vstinnerlinkissue40364 messages
2020-04-22 16:51:11vstinnercreate