Skip to content

Commit 24cb7de

Browse files
author
Yury Selivanov
authored
[3.7] bpo-34762: Update PyContext* refs to PyObject* in asyncio and decimal (GH-9610)
1 parent 273fc22 commit 24cb7de

2 files changed

Lines changed: 11 additions & 12 deletions

File tree

Modules/_asynciomodule.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ typedef enum {
5959
PyObject_HEAD \
6060
PyObject *prefix##_loop; \
6161
PyObject *prefix##_callback0; \
62-
PyContext *prefix##_context0; \
62+
PyObject *prefix##_context0; \
6363
PyObject *prefix##_callbacks; \
6464
PyObject *prefix##_exception; \
6565
PyObject *prefix##_result; \
@@ -78,7 +78,7 @@ typedef struct {
7878
FutureObj_HEAD(task)
7979
PyObject *task_fut_waiter;
8080
PyObject *task_coro;
81-
PyContext *task_context;
81+
PyObject *task_context;
8282
int task_must_cancel;
8383
int task_log_destroy_pending;
8484
} TaskObj;
@@ -337,7 +337,7 @@ get_event_loop(void)
337337

338338

339339
static int
340-
call_soon(PyObject *loop, PyObject *func, PyObject *arg, PyContext *ctx)
340+
call_soon(PyObject *loop, PyObject *func, PyObject *arg, PyObject *ctx)
341341
{
342342
PyObject *handle;
343343
PyObject *stack[3];
@@ -448,7 +448,7 @@ future_schedule_callbacks(FutureObj *fut)
448448
PyObject *cb = PyTuple_GET_ITEM(cb_tup, 0);
449449
PyObject *ctx = PyTuple_GET_ITEM(cb_tup, 1);
450450

451-
if (call_soon(fut->fut_loop, cb, (PyObject *)fut, (PyContext *)ctx)) {
451+
if (call_soon(fut->fut_loop, cb, (PyObject *)fut, ctx)) {
452452
/* If an error occurs in pure-Python implementation,
453453
all callbacks are cleared. */
454454
Py_CLEAR(fut->fut_callbacks);
@@ -616,7 +616,7 @@ future_get_result(FutureObj *fut, PyObject **result)
616616
}
617617

618618
static PyObject *
619-
future_add_done_callback(FutureObj *fut, PyObject *arg, PyContext *ctx)
619+
future_add_done_callback(FutureObj *fut, PyObject *arg, PyObject *ctx)
620620
{
621621
if (!future_is_alive(fut)) {
622622
PyErr_SetString(PyExc_RuntimeError, "uninitialized Future object");
@@ -903,16 +903,15 @@ _asyncio_Future_add_done_callback_impl(FutureObj *self, PyObject *fn,
903903
/*[clinic end generated code: output=7ce635bbc9554c1e input=15ab0693a96e9533]*/
904904
{
905905
if (context == NULL) {
906-
context = (PyObject *)PyContext_CopyCurrent();
906+
context = PyContext_CopyCurrent();
907907
if (context == NULL) {
908908
return NULL;
909909
}
910-
PyObject *res = future_add_done_callback(
911-
self, fn, (PyContext *)context);
910+
PyObject *res = future_add_done_callback(self, fn, context);
912911
Py_DECREF(context);
913912
return res;
914913
}
915-
return future_add_done_callback(self, fn, (PyContext *)context);
914+
return future_add_done_callback(self, fn, context);
916915
}
917916

918917
/*[clinic input]

Modules/_decimal/_decimal.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ incr_false(void)
122122
}
123123

124124

125-
static PyContextVar *current_context_var;
125+
static PyObject *current_context_var;
126126

127127
/* Template for creating new thread contexts, calling Context() without
128128
* arguments and initializing the module_context on first access. */
@@ -1500,7 +1500,7 @@ init_current_context(void)
15001500
}
15011501
CTX(tl_context)->status = 0;
15021502

1503-
PyContextToken *tok = PyContextVar_Set(current_context_var, tl_context);
1503+
PyObject *tok = PyContextVar_Set(current_context_var, tl_context);
15041504
if (tok == NULL) {
15051505
Py_DECREF(tl_context);
15061506
return NULL;
@@ -1561,7 +1561,7 @@ PyDec_SetCurrentContext(PyObject *self UNUSED, PyObject *v)
15611561
Py_INCREF(v);
15621562
}
15631563

1564-
PyContextToken *tok = PyContextVar_Set(current_context_var, v);
1564+
PyObject *tok = PyContextVar_Set(current_context_var, v);
15651565
Py_DECREF(v);
15661566
if (tok == NULL) {
15671567
return NULL;

0 commit comments

Comments
 (0)