Skip to content

Commit 2a4903f

Browse files
authored
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()
1 parent 17c68b8 commit 2a4903f

File tree

4 files changed

+6
-20
lines changed

4 files changed

+6
-20
lines changed

Include/cpython/object.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ _PyObject_DebugTypeStats(FILE *out);
443443
NDEBUG against a Python built with NDEBUG defined.
444444
445445
msg, expr and function can be NULL. */
446-
PyAPI_FUNC(void) _PyObject_AssertFailed(
446+
PyAPI_FUNC(void) _Py_NO_RETURN _PyObject_AssertFailed(
447447
PyObject *obj,
448448
const char *expr,
449449
const char *msg,

Modules/faulthandler.c

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,24 +1065,10 @@ faulthandler_sigsegv(PyObject *self, PyObject *args)
10651065
Py_RETURN_NONE;
10661066
}
10671067

1068-
static void
1068+
static void _Py_NO_RETURN
10691069
faulthandler_fatal_error_thread(void *plock)
10701070
{
1071-
#ifndef __clang__
1072-
PyThread_type_lock *lock = (PyThread_type_lock *)plock;
1073-
#endif
1074-
10751071
Py_FatalError("in new thread");
1076-
1077-
#ifndef __clang__
1078-
/* Issue #28152: Py_FatalError() is declared with
1079-
__attribute__((__noreturn__)). GCC emits a warning without
1080-
"PyThread_release_lock()" (compiler bug?), but Clang is smarter and
1081-
emits a warning on the return. */
1082-
1083-
/* notify the caller that we are done */
1084-
PyThread_release_lock(lock);
1085-
#endif
10861072
}
10871073

10881074
static PyObject *

Objects/object.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1646,7 +1646,7 @@ none_repr(PyObject *op)
16461646
}
16471647

16481648
/* ARGUSED */
1649-
static void
1649+
static void _Py_NO_RETURN
16501650
none_dealloc(PyObject* ignore)
16511651
{
16521652
/* 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)
17841784
Py_RETURN_NOTIMPLEMENTED;
17851785
}
17861786

1787-
static void
1787+
static void _Py_NO_RETURN
17881788
notimplemented_dealloc(PyObject* ignore)
17891789
{
17901790
/* This should never get called, but we also don't want to SEGV if
@@ -2225,7 +2225,7 @@ _PyTrash_thread_destroy_chain(void)
22252225
}
22262226

22272227

2228-
void
2228+
void _Py_NO_RETURN
22292229
_PyObject_AssertFailed(PyObject *obj, const char *expr, const char *msg,
22302230
const char *file, int line, const char *function)
22312231
{

Objects/setobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2529,7 +2529,7 @@ dummy_repr(PyObject *op)
25292529
return PyUnicode_FromString("<dummy key>");
25302530
}
25312531

2532-
static void
2532+
static void _Py_NO_RETURN
25332533
dummy_dealloc(PyObject* ignore)
25342534
{
25352535
Py_FatalError("deallocating <dummy key>");

0 commit comments

Comments
 (0)