From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Wed, 17 Dec 2025 18:28:37 +0000 (+0100) Subject: [3.14] gh-142873: Do not check for `PyContextVar_CheckExact` twice in `PyContextVar_S... X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=338bdb24156ddf5d6f9af9dee444f7c2644bd28f;p=thirdparty%2FPython%2Fcpython.git [3.14] gh-142873: Do not check for `PyContextVar_CheckExact` twice in `PyContextVar_Set` (GH-142874) (#142893) gh-142873: Do not check for `PyContextVar_CheckExact` twice in `PyContextVar_Set` (GH-142874) (cherry picked from commit e61a447d0e0753621e8fc347e99dfc87884d68ab) Co-authored-by: sobolevn --- diff --git a/Python/context.c b/Python/context.c index d1f8b7c24821..56a35dc731ad 100644 --- a/Python/context.c +++ b/Python/context.c @@ -343,12 +343,6 @@ PyContextVar_Set(PyObject *ovar, PyObject *val) ENSURE_ContextVar(ovar, NULL) PyContextVar *var = (PyContextVar *)ovar; - if (!PyContextVar_CheckExact(var)) { - PyErr_SetString( - PyExc_TypeError, "an instance of ContextVar was expected"); - return NULL; - } - PyContext *ctx = context_get(); if (ctx == NULL) { return NULL; @@ -1024,12 +1018,6 @@ static PyObject * _contextvars_ContextVar_get_impl(PyContextVar *self, PyObject *default_value) /*[clinic end generated code: output=0746bd0aa2ced7bf input=30aa2ab9e433e401]*/ { - if (!PyContextVar_CheckExact(self)) { - PyErr_SetString( - PyExc_TypeError, "an instance of ContextVar was expected"); - return NULL; - } - PyObject *val; if (PyContextVar_Get((PyObject *)self, default_value, &val) < 0) { return NULL;