From e61a447d0e0753621e8fc347e99dfc87884d68ab Mon Sep 17 00:00:00 2001 From: sobolevn Date: Wed, 17 Dec 2025 19:41:36 +0300 Subject: [PATCH] gh-142873: Do not check for `PyContextVar_CheckExact` twice in `PyContextVar_Set` (#142874) --- Python/context.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/Python/context.c b/Python/context.c index 620e78ab1f9e..606ce4b1c8f6 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; @@ -1025,12 +1019,6 @@ static PyObject * _contextvars_ContextVar_get_impl(PyContextVar *self, PyObject *default_value) /*[clinic end generated code: output=0746bd0aa2ced7bf input=da66664d5d0af4ad]*/ { - 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; -- 2.47.3