Message370696
> 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 |
|
Date |
User |
Action |
Args |
2020-06-04 07:08:46 | eryksun | set | recipients:
+ eryksun, db3l, vstinner, benjamin.peterson, stutzbach, serhiy.storchaka, JelleZijlstra, corona10, remi.lapeyre |
2020-06-04 07:08:46 | eryksun | set | messageid: <1591254526.92.0.63229542297.issue40826@roundup.psfhosted.org> |
2020-06-04 07:08:46 | eryksun | link | issue40826 messages |
2020-06-04 07:08:46 | eryksun | create | |
|