Skip to content

Commit 072aab6

Browse files
committed
gh-142873: Do not check for PyContextVar_CheckExact twice in PyContextVar_Set
1 parent 248eb3e commit 072aab6

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

Python/context.c

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -343,12 +343,6 @@ PyContextVar_Set(PyObject *ovar, PyObject *val)
343343
ENSURE_ContextVar(ovar, NULL)
344344
PyContextVar *var = (PyContextVar *)ovar;
345345

346-
if (!PyContextVar_CheckExact(var)) {
347-
PyErr_SetString(
348-
PyExc_TypeError, "an instance of ContextVar was expected");
349-
return NULL;
350-
}
351-
352346
PyContext *ctx = context_get();
353347
if (ctx == NULL) {
354348
return NULL;
@@ -1025,11 +1019,7 @@ static PyObject *
10251019
_contextvars_ContextVar_get_impl(PyContextVar *self, PyObject *default_value)
10261020
/*[clinic end generated code: output=0746bd0aa2ced7bf input=da66664d5d0af4ad]*/
10271021
{
1028-
if (!PyContextVar_CheckExact(self)) {
1029-
PyErr_SetString(
1030-
PyExc_TypeError, "an instance of ContextVar was expected");
1031-
return NULL;
1032-
}
1022+
ENSURE_ContextVar(self, NULL)
10331023

10341024
PyObject *val;
10351025
if (PyContextVar_Get((PyObject *)self, default_value, &val) < 0) {

0 commit comments

Comments
 (0)