diff options
author | Victor Stinner <vstinner@python.org> | 2020-01-30 12:09:11 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-30 12:09:11 (GMT) |
commit | 2a4903fcce54c25807d362dbbbcfb32d0b494f9f (patch) | |
tree | 9ed04fc7af4e5926778b0764be5078a1f6338b64 | |
parent | 17c68b8107e348aeaaa05f7ac5072cacff916022 (diff) | |
download | cpython-2a4903fcce54c25807d362dbbbcfb32d0b494f9f.zip cpython-2a4903fcce54c25807d362dbbbcfb32d0b494f9f.tar.gz cpython-2a4903fcce54c25807d362dbbbcfb32d0b494f9f.tar.bz2 |
bpo-38631: Add _Py_NO_RETURN to functions calling Py_FatalError() (GH-18278)
Add _Py_NO_RETURN to functions calling Py_FatalError():
* _PyObject_AssertFailed()
* dummy_dealloc()
* faulthandler_fatal_error_thread()
* none_dealloc()
* notimplemented_dealloc()
-rw-r--r-- | Include/cpython/object.h | 2 | ||||
-rw-r--r-- | Modules/faulthandler.c | 16 | ||||
-rw-r--r-- | Objects/object.c | 6 | ||||
-rw-r--r-- | Objects/setobject.c | 2 |
4 files changed, 6 insertions, 20 deletions
diff --git a/Include/cpython/object.h b/Include/cpython/object.h index 75e5599..dc8fd6f 100644 --- a/Include/cpython/object.h +++ b/Include/cpython/object.h @@ -443,7 +443,7 @@ _PyObject_DebugTypeStats(FILE *out); NDEBUG against a Python built with NDEBUG defined. msg, expr and function can be NULL. */ -PyAPI_FUNC(void) _PyObject_AssertFailed( +PyAPI_FUNC(void) _Py_NO_RETURN _PyObject_AssertFailed( PyObject *obj, const char *expr, const char *msg, diff --git a/Modules/faulthandler.c b/Modules/faulthandler.c index b19401e..555e1af 100644 --- a/Modules/faulthandler.c +++ b/Modules/faulthandler.c @@ -1065,24 +1065,10 @@ faulthandler_sigsegv(PyObject *self, PyObject *args) Py_RETURN_NONE; } -static void +static void _Py_NO_RETURN faulthandler_fatal_error_thread(void *plock) { -#ifndef __clang__ - PyThread_type_lock *lock = (PyThread_type_lock *)plock; -#endif - Py_FatalError("in new thread"); - -#ifndef __clang__ - /* Issue #28152: Py_FatalError() is declared with - __attribute__((__noreturn__)). GCC emits a warning without - "PyThread_release_lock()" (compiler bug?), but Clang is smarter and - emits a warning on the return. */ - - /* notify the caller that we are done */ - PyThread_release_lock(lock); -#endif } static PyObject * diff --git a/Objects/object.c b/Objects/object.c index c5d28e5..67a6386 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -1646,7 +1646,7 @@ none_repr(PyObject *op) } /* ARGUSED */ -static void +static void _Py_NO_RETURN none_dealloc(PyObject* ignore) { /* This should never get called, but we also don't want to SEGV if @@ -1784,7 +1784,7 @@ notimplemented_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) Py_RETURN_NOTIMPLEMENTED; } -static void +static void _Py_NO_RETURN notimplemented_dealloc(PyObject* ignore) { /* This should never get called, but we also don't want to SEGV if @@ -2225,7 +2225,7 @@ _PyTrash_thread_destroy_chain(void) } -void +void _Py_NO_RETURN _PyObject_AssertFailed(PyObject *obj, const char *expr, const char *msg, const char *file, int line, const char *function) { diff --git a/Objects/setobject.c b/Objects/setobject.c index 924885d..bb7c0b8 100644 --- a/Objects/setobject.c +++ b/Objects/setobject.c @@ -2529,7 +2529,7 @@ dummy_repr(PyObject *op) return PyUnicode_FromString("<dummy key>"); } -static void +static void _Py_NO_RETURN dummy_dealloc(PyObject* ignore) { Py_FatalError("deallocating <dummy key>"); |