]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-132781: Make NotShareableError a TypeError Subclass (gh-132973)
authorEric Snow <ericsnowcurrently@gmail.com>
Fri, 25 Apr 2025 21:10:43 +0000 (15:10 -0600)
committerGitHub <noreply@github.com>
Fri, 25 Apr 2025 21:10:43 +0000 (21:10 +0000)
It was a subclass of ValueError. However, shareability is a feature of types, not values.

Python/crossinterp_exceptions.h

index 39993648f275f45c6a23db1f64ac96f785f82dd1..857c4d1e379a0eeb4d86f82177bc398018b7de46 100644 (file)
@@ -46,14 +46,13 @@ static PyTypeObject _PyExc_InterpreterNotFoundError = {
 };
 PyObject *PyExc_InterpreterNotFoundError = (PyObject *)&_PyExc_InterpreterNotFoundError;
 
-/* NotShareableError extends ValueError */
+/* NotShareableError extends TypeError */
 
 static int
 _init_notshareableerror(exceptions_t *state)
 {
     const char *name = "interpreters.NotShareableError";
-    // XXX Inherit from TypeError.
-    PyObject *base = PyExc_ValueError;
+    PyObject *base = PyExc_TypeError;
     PyObject *ns = NULL;
     PyObject *exctype = PyErr_NewException(name, base, ns);
     if (exctype == NULL) {
@@ -94,7 +93,7 @@ _ensure_notshareableerror(PyThreadState *tstate,
         }
     }
     else {
-        exctype = PyExc_ValueError;
+        exctype = PyExc_TypeError;
     }
     _PyErr_SetObject(tstate, exctype, msgobj);
     // We have to set the context manually since _PyErr_SetObject() doesn't.