8000 gh-99633: _contextvars: Call non-tstate variants · rhansen/cpython@a132a50 · GitHub
[go: up one dir, main page]

Skip to content

Commit a132a50

Browse files
committed
pythongh-99633: _contextvars: Call non-tstate variants
This will make it easier to refactor `_PyContext_Enter` and `_PyContext_Exit` for a planned feature.
1 parent e464632 commit a132a50

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

Python/context.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,8 @@ static int
198198
_PyContext_Enter(PyThreadState *ts, PyContext *ctx)
199199
{
200200
if (ctx->ctx_entered) {
201-
_PyErr_Format(ts, PyExc_RuntimeError,
202-
"cannot enter context: %R is already entered", ctx);
201+
PyErr_Format(PyExc_RuntimeError,
202+
"cannot enter context: %R is already entered", ctx);
203203
return -1;
204204
}
205205

@@ -702,25 +702,23 @@ _contextvars_Context_copy_impl(PyContext *self)
702702

703703

704704
static PyObject *
705-
context_run(PyContext *self, PyObject *const *args,
705+
context_run(PyObject *self, PyObject *const *args,
706706
Py_ssize_t nargs, PyObject *kwnames)
707707
{
708-
PyThreadState *ts = _PyThreadState_GET();
709-
710708
if (nargs < 1) {
711-
_PyErr_SetString(ts, PyExc_TypeError,
712-
"run() missing 1 required positional argument");
709+
PyErr_SetString(PyExc_TypeError,
710+
"run() missing 1 required positional argument");
713711
return NULL;
714712
}
715713

716-
if (_PyContext_Enter(ts, self)) {
714+
if (PyContext_Enter(self)) {
717715
return NULL;
718716
}
719717

720-
PyObject *call_result = _PyObject_VectorcallTstate(
721-
ts, args[0], args + 1, nargs - 1, kwnames);
718+
PyObject *call_result =
719+
PyObject_Vectorcall(args[0], args + 1, nargs - 1, kwnames);
722720

723-
if (_PyContext_Exit(ts, self)) {
721+
if (PyContext_Exit(self)) {
724722
Py_XDECREF(call_result);
725723
return NULL;
726724
}

0 commit comments

Comments
 (0)
0