Eryk Sun <[email protected]> added the comment:
> Perhaps the child interpreter used by test_repl doesn't inherit
> that behavior.
The OS error mode is inherited, unless the child is created with
CREATE_DEFAULT_ERROR_MODE flag. But the CRT error mode isn't inherited. (For
the spawn* family, in principle the CRT could pass its error modes in reserved
STARTUPINFO fields, like it does for file descriptors, but it doesn't do that,
and subprocess wouldn't be privy to that protocol anyway.)
For example:
>>> import sys, subprocess
>>> from msvcrt import *
>>> SEM_FAILCRITICALERRORS, CRTDBG_MODE_FILE, CRTDBG_MODE_WNDW
(1, 1, 4)
>>> SetErrorMode(SEM_FAILCRITICALERRORS)
0
>>> CrtSetReportMode(CRT_ERROR, CRTDBG_MODE_FILE)
4
The return values are the previous values, which are respectively 0 (default)
for the OS and CRTDBG_MODE_WNDW (message box) for the CRT. Now check the
initial values in a child process:
>>> subprocess.call(f'{sys.executable} -q')
>>> from msvcrt import *
>>> SetErrorMode(SEM_FAILCRITICALERRORS)
1
>>> CrtSetReportMode(CRT_ERROR, CRTDBG_MODE_FILE)
4
The OS error mode of the parent was inherited, but the parent's CRT error mode
was not.
libregrtest has a convenient function to suppress error reporting in the child.
For example:
>>> import sys, subprocess
>>> subprocess.call(f'{sys.executable} -q')
>>> import os
>>> from test.libregrtest import setup
>>> setup.suppress_msvcrt_asserts(0)
>>> os.close(0)
>>>
0
----------
nosy: +eryksun
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue40826>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com