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
# 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
#define PY_SSIZE_T_CLEAN
#include "Python.h"
-#include "pycore_object.h"
+#include "pycore_fileutils.h" // _Py_BEGIN_SUPPRESS_IPH
+#include "pycore_object.h" // _PyObject_GC_UNTRACK()
#include "structmember.h" // PyMemberDef
#include <stdbool.h>
#ifdef HAVE_SYS_TYPES_H
#define PY_SSIZE_T_CLEAN
#include "Python.h"
-#include "pycore_object.h"
+#include "pycore_fileutils.h" // _Py_BEGIN_SUPPRESS_IPH
+#include "pycore_object.h" // _PyObject_GC_UNTRACK()
#ifdef MS_WINDOWS
#include "pycore_atomic.h" // _Py_atomic_int
#include "pycore_call.h" // _PyObject_Call()
#include "pycore_ceval.h" // _PyEval_SignalReceived()
+#include "pycore_fileutils.h" // _Py_BEGIN_SUPPRESS_IPH
#include "pycore_frame.h" // InterpreterFrame
#include "pycore_moduleobject.h" // _PyModule_GetState()
#include "pycore_pyerrors.h" // _PyErr_SetString()
/* Time module */
#include "Python.h"
+#include "pycore_fileutils.h" // _Py_BEGIN_SUPPRESS_IPH
#include <ctype.h>
#ifdef HAVE_SYS_TIMES_H
-#include <sys/times.h>
+# include <sys/times.h>
#endif
-
#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
+# include <sys/types.h>
#endif
-
#if defined(HAVE_SYS_RESOURCE_H)
-#include <sys/resource.h>
+# include <sys/resource.h>
#endif
-
#ifdef QUICKWIN
-#include <io.h>
+# include <io.h>
#endif
-
#if defined(HAVE_PTHREAD_H)
# include <pthread.h>
#endif
-
#if defined(_AIX)
# include <sys/thread.h>
#endif
-
#if defined(__WATCOMC__) && !defined(__QNX__)
# include <i86.h>
#else
#endif /* !__WATCOMC__ || __QNX__ */
#ifdef _Py_MEMORY_SANITIZER
-# include <sanitizer/msan_interface.h>
+# include <sanitizer/msan_interface.h>
#endif
#ifdef _MSC_VER
-#define _Py_timezone _timezone
-#define _Py_daylight _daylight
-#define _Py_tzname _tzname
+# define _Py_timezone _timezone
+# define _Py_daylight _daylight
+# define _Py_tzname _tzname
#else
-#define _Py_timezone timezone
-#define _Py_daylight daylight
-#define _Py_tzname tzname
+# define _Py_timezone timezone
+# define _Py_daylight daylight
+# define _Py_tzname tzname
#endif
#if defined(__APPLE__ ) && defined(__has_builtin)
# define HAVE_CLOCK_GETTIME_RUNTIME 1
#endif
+
#define SEC_TO_NS (1000 * 1000 * 1000)
+
/* Forward declarations */
static int pysleep(_PyTime_t timeout);
#include "Python.h"
+#include "pycore_fileutils.h" // _Py_add_relfile()
#include "pycore_initconfig.h" // PyStatus
#include "pycore_pathconfig.h" // _PyPathConfig
-#include "pycore_fileutils.h" // _Py_add_relfile()
#include "osdefs.h" // SEP, ALTSEP
#include <wchar.h>
***********************************************************/
#include "Python.h"
+#include "pycore_fileutils.h" // _Py_BEGIN_SUPPRESS_IPH
#include "malloc.h"
#include <io.h>
#include <conio.h>
*/
#include "Python.h"
+#include "pycore_fileutils.h" // _Py_BEGIN_SUPPRESS_IPH
#include "pycore_pystate.h" // _PyThreadState_GET()
#ifdef MS_WINDOWS
# define WIN32_LEAN_AND_MEAN
#include "Python.h"
#include "code.h" // PyCode_Addr2Line etc
-#include "pycore_interp.h" // PyInterpreterState.gc
#include "frameobject.h" // PyFrame_GetBack()
#include "pycore_ast.h" // asdl_seq_*
#include "pycore_compile.h" // _PyAST_Optimize
+#include "pycore_fileutils.h" // _Py_BEGIN_SUPPRESS_IPH
#include "pycore_frame.h" // _PyFrame_GetCode()
+#include "pycore_interp.h" // PyInterpreterState.gc
#include "pycore_parser.h" // _PyParser_ASTFromString
#include "pycore_pyarena.h" // _PyArena_Free()
#include "pycore_pyerrors.h" // _PyErr_Fetch()
#include "structmember.h" // PyMemberDef
#include "osdefs.h" // SEP
#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
+# include <fcntl.h>
#endif
#define OFF(x) offsetof(PyTracebackObject, x)