[Python-checkins] Define _Py_NO_RETURN for Microsoft C compiler (GH-8606)

Victor Stinner webhook-mailer at python.org
Wed Aug 1 10:41:30 EDT 2018


https://github.com/python/cpython/commit/cfc8831f5ed607048679427f7d76d6cb4f8a2e8a
commit: cfc8831f5ed607048679427f7d76d6cb4f8a2e8a
branch: master
author: Victor Stinner <vstinner at redhat.com>
committer: GitHub <noreply at github.com>
date: 2018-08-01T16:41:25+02:00
summary:

Define _Py_NO_RETURN for Microsoft C compiler (GH-8606)

files:
M Include/pyerrors.h
M Include/pylifecycle.h
M Python/pylifecycle.c

diff --git a/Include/pyerrors.h b/Include/pyerrors.h
index 416d750d9b1f..4e2995469f3c 100644
--- a/Include/pyerrors.h
+++ b/Include/pyerrors.h
@@ -97,13 +97,15 @@ PyAPI_FUNC(void) PyErr_SetExcInfo(PyObject *, PyObject *, PyObject *);
     (defined(__GNUC_MAJOR__) && \
      ((__GNUC_MAJOR__ >= 3) || \
       (__GNUC_MAJOR__ == 2) && (__GNUC_MINOR__ >= 5)))
-#define _Py_NO_RETURN __attribute__((__noreturn__))
+#  define _Py_NO_RETURN __attribute__((__noreturn__))
+#elif defined(_MSC_VER)
+#  define _Py_NO_RETURN __declspec(noreturn)
 #else
-#define _Py_NO_RETURN
+#  define _Py_NO_RETURN
 #endif
 
 /* Defined in Python/pylifecycle.c */
-PyAPI_FUNC(void) Py_FatalError(const char *message) _Py_NO_RETURN;
+PyAPI_FUNC(void) _Py_NO_RETURN Py_FatalError(const char *message);
 
 #if defined(Py_DEBUG) || defined(Py_LIMITED_API)
 #define _PyErr_OCCURRED() PyErr_Occurred()
diff --git a/Include/pylifecycle.h b/Include/pylifecycle.h
index 78f01eef1166..c58c7ec95d9d 100644
--- a/Include/pylifecycle.h
+++ b/Include/pylifecycle.h
@@ -86,7 +86,7 @@ PyAPI_FUNC(void) Py_InitializeEx(int);
 #ifndef Py_LIMITED_API
 PyAPI_FUNC(_PyInitError) _Py_InitializeFromConfig(
     const _PyCoreConfig *config);
-PyAPI_FUNC(void) _Py_FatalInitError(_PyInitError err) _Py_NO_RETURN;
+PyAPI_FUNC(void) _Py_NO_RETURN _Py_FatalInitError(_PyInitError err);
 #endif
 PyAPI_FUNC(void) Py_Finalize(void);
 PyAPI_FUNC(int) Py_FinalizeEx(void);
@@ -105,7 +105,7 @@ PyAPI_FUNC(void) _Py_PyAtExit(void (*func)(PyObject *), PyObject *);
 #endif
 PyAPI_FUNC(int) Py_AtExit(void (*func)(void));
 
-PyAPI_FUNC(void) Py_Exit(int) _Py_NO_RETURN;
+PyAPI_FUNC(void) _Py_NO_RETURN Py_Exit(int);
 
 /* Restore signals that the interpreter has called SIG_IGN on to SIG_DFL. */
 #ifndef Py_LIMITED_API
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index 0729a5f83b52..63f461ab0432 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -2212,7 +2212,7 @@ call_ll_exitfuncs(void)
     fflush(stderr);
 }
 
-void
+void _Py_NO_RETURN
 Py_Exit(int sts)
 {
     if (Py_FinalizeEx() < 0) {



More information about the Python-checkins mailing list