Skip to content

Commit 2ec6f1b

Browse files
authored
Implement error messages for atexit callbacks
Added error handling for unsupported Python versions in atexit functions.
1 parent e301e1e commit 2ec6f1b

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/sage/cpython/atexit.pyx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ cdef extern from *:
173173
174174
// Dummy function for Python 3.14+ (never called)
175175
static atexit_callback_struct** get_atexit_callbacks_array(PyObject *self) {
176+
PyErr_SetString(PyExc_RuntimeError, "Python >= 3.14 has no atexit array");
176177
return NULL;
177178
}
178179
#else
@@ -186,6 +187,7 @@ cdef extern from *:
186187
187188
// Dummy function for Python < 3.14 (never called)
188189
static PyObject* get_atexit_callbacks_list(PyObject *self) {
190+
PyErr_SetString(PyExc_RuntimeError, "Python < 3.14 has no atexit list");
189191
return NULL;
190192
}
191193
#endif

0 commit comments

Comments
 (0)