bpo-32374: Enhance test_importlib.test_bad_traverse() by vstinner · Pull Request #7147 · python/cpython (original) (raw)
AFAIK, C's assert/abort does not guarantee an exit code outside (0, 1) on all possible platforms.
I wasn't sure neither, so I looked at existing tests.
If a process is killed by a signal like SIGSEGV or SIGBUS, subprocess.Popen.returncode is a negative number. subprocess.py:
if _WIFSIGNALED(sts):
self.returncode = -_WTERMSIG(sts)
We have many tests for that. For example, test_subprocess.test_run_abort() calls os.abort() and then checks self.assertEqual(-p.returncode, signal.SIGABRT).
On Windows, the exit code is usually a big number. The test just passed on AppVeyor.
So my PR expects that spec.loader.create_module() kills the process with any signal.