]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-45434: Move _Py_BEGIN_SUPPRESS_IPH to pycore_fileutils.h (GH-28922)
authorVictor Stinner <vstinner@python.org>
Wed, 13 Oct 2021 13:03:35 +0000 (15:03 +0200)
committerGitHub <noreply@github.com>
Wed, 13 Oct 2021 13:03:35 +0000 (15:03 +0200)
Include/internal/pycore_fileutils.h
Include/pyport.h
Modules/_io/fileio.c
Modules/_io/winconsoleio.c
Modules/signalmodule.c
Modules/timemodule.c
PC/getpathp.c
PC/msvcrtmodule.c
Parser/myreadline.c
Python/traceback.c

index 8491ed9b5ffe208f8fc0a87235de826b2dab9e51..2316a978294e2091b84e17b41c7b4dc3cd613ea9 100644 (file)
@@ -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
index a8a2d6d0d9d922cd8e01ce7d90ebb84953baebf3..6e4e98020cb1fb906acd3699eb1ef635751f760f 100644 (file)
@@ -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
index b9856b3b63165709384f7ce68c145ceac8de1f83..dd215e89399442aefc9c8264882305e519e90d0e 100644 (file)
@@ -2,7 +2,8 @@
 
 #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
index 460f2d3fa071a892d4bbaed2d0214fa59957e604..4002d28fc9b353943c034229b2d90b75f1d5726f 100644 (file)
@@ -8,7 +8,8 @@
 
 #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
 
index 6568a4d5aa70efd4098df3d205c15dc8f4dc424b..09f4aed9d5ca9af77f2d9fc3538adbff382417a3 100644 (file)
@@ -7,6 +7,7 @@
 #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()
index 4639afa590a4fa1f2e348bd524e683daeab5fbf4..ca8d62d5cc9380500a3f50dbb59e96e341459256 100644 (file)
@@ -1,33 +1,28 @@
 /* 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);
 
index 79569bb554457c2ec3a36971609a1d9c119ad6f7..549353d78b116ac64e5a6695a399d0dc2d85741a 100644 (file)
@@ -80,9 +80,9 @@
 
 
 #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>
 
index 0591497871cadc29039dbafd4c5dec3f7755858b..1f78d99c790ff9cdb4e8757566081d4a1c288bb5 100644 (file)
@@ -17,6 +17,7 @@
 ***********************************************************/
 
 #include "Python.h"
+#include "pycore_fileutils.h"     // _Py_BEGIN_SUPPRESS_IPH
 #include "malloc.h"
 #include <io.h>
 #include <conio.h>
index e5e2fb1099d03366c4af579d9c06ce8518402415..b10d306255bb67847cc96a2c61e049d53366b9ae 100644 (file)
@@ -10,6 +10,7 @@
 */
 
 #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
index 3ea1db578b43a7e7d48e872235ea3ce54a06ae48..ffa7c3494eafc92552ae3ad854b638c3f7418740 100644 (file)
@@ -4,11 +4,12 @@
 #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()
@@ -17,7 +18,7 @@
 #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)