diff options
author | Victor Stinner <vstinner@python.org> | 2021-10-13 13:03:35 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-13 13:03:35 (GMT) |
commit | 97308dfcdc0696e0b116c37386e2ff4d72e6c3f4 (patch) | |
tree | a827f813979840eb28c66d5b74ab6f653fe51207 /Include | |
parent | 7cdc2a0f4b785327ad9d55312409a06e554df3d5 (diff) | |
download | cpython-97308dfcdc0696e0b116c37386e2ff4d72e6c3f4.zip cpython-97308dfcdc0696e0b116c37386e2ff4d72e6c3f4.tar.gz cpython-97308dfcdc0696e0b116c37386e2ff4d72e6c3f4.tar.bz2 |
bpo-45434: Move _Py_BEGIN_SUPPRESS_IPH to pycore_fileutils.h (GH-28922)
Diffstat (limited to 'Include')
-rw-r--r-- | Include/internal/pycore_fileutils.h | 19 | ||||
-rw-r--r-- | Include/pyport.h | 20 |
2 files changed, 19 insertions, 20 deletions
diff --git a/Include/internal/pycore_fileutils.h b/Include/internal/pycore_fileutils.h index 8491ed9..2316a97 100644 --- a/Include/internal/pycore_fileutils.h +++ b/Include/internal/pycore_fileutils.h @@ -80,6 +80,25 @@ extern int _Py_add_relfile(wchar_t *dirname, const wchar_t *relfile, size_t bufsize); +// Macros to protect CRT calls against instant termination when passed an +// invalid parameter (bpo-23524). IPH stands for Invalid Parameter Handler. +// Usage: +// +// _Py_BEGIN_SUPPRESS_IPH +// ... +// _Py_END_SUPPRESS_IPH +#if defined _MSC_VER && _MSC_VER >= 1900 + extern _invalid_parameter_handler _Py_silent_invalid_parameter_handler; +# define _Py_BEGIN_SUPPRESS_IPH \ + { _invalid_parameter_handler _Py_old_handler = \ + _set_thread_local_invalid_parameter_handler(_Py_silent_invalid_parameter_handler); +# define _Py_END_SUPPRESS_IPH \ + _set_thread_local_invalid_parameter_handler(_Py_old_handler); } +#else +# define _Py_BEGIN_SUPPRESS_IPH +# define _Py_END_SUPPRESS_IPH +#endif /* _MSC_VER >= 1900 */ + #ifdef __cplusplus } #endif diff --git a/Include/pyport.h b/Include/pyport.h index a8a2d6d..6e4e980 100644 --- a/Include/pyport.h +++ b/Include/pyport.h @@ -712,26 +712,6 @@ extern char * _getpty(int *, int, mode_t, int); # define PY_LITTLE_ENDIAN 1 #endif -#ifdef Py_BUILD_CORE -/* - * Macros to protect CRT calls against instant termination when passed an - * invalid parameter (issue23524). - */ -#if defined _MSC_VER && _MSC_VER >= 1900 - -extern _invalid_parameter_handler _Py_silent_invalid_parameter_handler; -#define _Py_BEGIN_SUPPRESS_IPH { _invalid_parameter_handler _Py_old_handler = \ - _set_thread_local_invalid_parameter_handler(_Py_silent_invalid_parameter_handler); -#define _Py_END_SUPPRESS_IPH _set_thread_local_invalid_parameter_handler(_Py_old_handler); } - -#else - -#define _Py_BEGIN_SUPPRESS_IPH -#define _Py_END_SUPPRESS_IPH - -#endif /* _MSC_VER >= 1900 */ -#endif /* Py_BUILD_CORE */ - #ifdef __ANDROID__ /* The Android langinfo.h header is not used. */ # undef HAVE_LANGINFO_H |