Eryk Sun <eryk...@gmail.com> added the comment:
> The purpose of _Py_BEGIN_SUPPRESS_IPH is to suppress such popup, no? That macro suppresses the CRT's invalid parameter handler, which by default terminates abnormally with a fastfail (status code 0xC0000409), even in a release build. In a debug build, we still have message boxes from failed asserts that call _CrtDbgReportW. For example, the following stack trace shows _CrtDbgReportW called from _get_osfhandle: Call Site win32u!NtUserWaitMessage user32!DialogBox2 user32!InternalDialogBox user32!SoftModalMessageBox user32!MessageBoxWorker user32!MessageBoxTimeoutW user32!MessageBoxW ucrtbased!__acrt_MessageBoxW ucrtbased!__crt_char_traits<wchar_t>::message_box<HWND__ * __ptr64, wchar_t const * __ptr64 const & __ptr64, wchar_t const * __ptr64 const & __ptr64, unsigned int const & __ptr64> ucrtbased!common_show_message_box<wchar_t> ucrtbased!__acrt_show_wide_message_box ucrtbased!common_message_window<wchar_t> ucrtbased!__acrt_MessageWindowW ucrtbased!_VCrtDbgReportW ucrtbased!_CrtDbgReportW ucrtbased!_get_osfhandle python310_d!PyOS_StdioReadline _get_osfhandle validates that the fd is open via _VALIDATE_CLEAR_OSSERR_RETURN(_osfile(fh) & FOPEN, EBADF, -1); which uses the following macro: #define _VALIDATE_CLEAR_OSSERR_RETURN(expr, errorcode, retexpr) \ { \ int _Expr_val=!!(expr); \ _ASSERT_EXPR((_Expr_val), _CRT_WIDE(#expr)); \ if (!(_Expr_val)) \ { \ _doserrno = 0L; \ errno = errorcode; \ _INVALID_PARAMETER(_CRT_WIDE(#expr)); \ return retexpr; \ } \ } In a debug build, _ASSERT_EXPR expands as: #define _ASSERT_EXPR(expr, msg) \ (void)( \ (!!(expr)) || \ (1 != _CrtDbgReportW(_CRT_ASSERT, _CRT_WIDE(__FILE__), __LINE__, NULL, L"%ls", msg)) || \ (_CrtDbgBreak(), 0) \ ) which is where _CrtDbgReportW gets called. By default it reports the assertion failure with a message box. The suppression of this in libregrtest either ignores this report or sends it to stderr: for m in [msvcrt.CRT_WARN, msvcrt.CRT_ERROR, msvcrt.CRT_ASSERT]: if verbose: msvcrt.CrtSetReportMode(m, msvcrt.CRTDBG_MODE_FILE) msvcrt.CrtSetReportFile(m, msvcrt.CRTDBG_FILE_STDERR) else: msvcrt.CrtSetReportMode(m, 0) msvcrt.CrtSetReportMode and msvcrt.CrtSetReportFile only exist in a debug build. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue40826> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com