Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cfc8831

Browse files
authored
Define _Py_NO_RETURN for Microsoft C compiler (GH-8606)
1 parent fc96437 commit cfc8831

3 files changed

Lines changed: 8 additions & 6 deletions

File tree

Include/pyerrors.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,15 @@ PyAPI_FUNC(void) PyErr_SetExcInfo(PyObject *, PyObject *, PyObject *);
9797
(defined(__GNUC_MAJOR__) && \
9898
((__GNUC_MAJOR__ >= 3) || \
9999
(__GNUC_MAJOR__ == 2) && (__GNUC_MINOR__ >= 5)))
100-
#define _Py_NO_RETURN __attribute__((__noreturn__))
100+
# define _Py_NO_RETURN __attribute__((__noreturn__))
101+
#elif defined(_MSC_VER)
102+
# define _Py_NO_RETURN __declspec(noreturn)
101103
#else
102-
#define _Py_NO_RETURN
104+
# define _Py_NO_RETURN
103105
#endif
104106

105107
/* Defined in Python/pylifecycle.c */
106-
PyAPI_FUNC(void) Py_FatalError(const char *message) _Py_NO_RETURN;
108+
PyAPI_FUNC(void) _Py_NO_RETURN Py_FatalError(const char *message);
107109

108110
#if defined(Py_DEBUG) || defined(Py_LIMITED_API)
109111
#define _PyErr_OCCURRED() PyErr_Occurred()

Include/pylifecycle.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ PyAPI_FUNC(void) Py_InitializeEx(int);
8686
#ifndef Py_LIMITED_API
8787
PyAPI_FUNC(_PyInitError) _Py_InitializeFromConfig(
8888
const _PyCoreConfig *config);
89-
PyAPI_FUNC(void) _Py_FatalInitError(_PyInitError err) _Py_NO_RETURN;
89+
PyAPI_FUNC(void) _Py_NO_RETURN _Py_FatalInitError(_PyInitError err);
9090
#endif
9191
PyAPI_FUNC(void) Py_Finalize(void);
9292
PyAPI_FUNC(int) Py_FinalizeEx(void);
@@ -105,7 +105,7 @@ PyAPI_FUNC(void) _Py_PyAtExit(void (*func)(PyObject *), PyObject *);
105105
#endif
106106
PyAPI_FUNC(int) Py_AtExit(void (*func)(void));
107107

108-
PyAPI_FUNC(void) Py_Exit(int) _Py_NO_RETURN;
108+
PyAPI_FUNC(void) _Py_NO_RETURN Py_Exit(int);
109109

110110
/* Restore signals that the interpreter has called SIG_IGN on to SIG_DFL. */
111111
#ifndef Py_LIMITED_API

Python/pylifecycle.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2212,7 +2212,7 @@ call_ll_exitfuncs(void)
22122212
fflush(stderr);
22132213
}
22142214

2215-
void
2215+
void _Py_NO_RETURN
22162216
Py_Exit(int sts)
22172217
{
22182218
if (Py_FinalizeEx() < 0) {

0 commit comments

Comments
 (0)