Skip to content

Commit 994269c

Browse files
authored
bpo-34762: Update PyContext* to PyObject* in asyncio and decimal (GH-9609)
This fixes various compiler warnings.
1 parent 3f22811 commit 994269c

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

Modules/_asynciomodule.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ typedef enum {
6161
PyObject_HEAD \
6262
PyObject *prefix##_loop; \
6363
PyObject *prefix##_callback0; \
64-
PyContext *prefix##_context0; \
64+
PyObject *prefix##_context0; \
6565
PyObject *prefix##_callbacks; \
6666
PyObject *prefix##_exception; \
6767
PyObject *prefix##_result; \
@@ -81,7 +81,7 @@ typedef struct {
8181
PyObject *task_fut_waiter;
8282
PyObject *task_coro;
8383
PyObject *task_name;
84-
PyContext *task_context;
84+
PyObject *task_context;
8585
int task_must_cancel;
8686
int task_log_destroy_pending;
8787
} TaskObj;
@@ -340,7 +340,7 @@ get_event_loop(void)
340340

341341

342342
static int
343-
call_soon(PyObject *loop, PyObject *func, PyObject *arg, PyContext *ctx)
343+
call_soon(PyObject *loop, PyObject *func, PyObject *arg, PyObject *ctx)
344344
{
345345
PyObject *handle;
346346
PyObject *stack[3];
@@ -451,7 +451,7 @@ future_schedule_callbacks(FutureObj *fut)
451451
PyObject *cb = PyTuple_GET_ITEM(cb_tup, 0);
452452
PyObject *ctx = PyTuple_GET_ITEM(cb_tup, 1);
453453

454-
if (call_soon(fut->fut_loop, cb, (PyObject *)fut, (PyContext *)ctx)) {
454+
if (call_soon(fut->fut_loop, cb, (PyObject *)fut, ctx)) {
455455
/* If an error occurs in pure-Python implementation,
456456
all callbacks are cleared. */
457457
Py_CLEAR(fut->fut_callbacks);
@@ -619,7 +619,7 @@ future_get_result(FutureObj *fut, PyObject **result)
619619
}
620620

621621
static PyObject *
622-
future_add_done_callback(FutureObj *fut, PyObject *arg, PyContext *ctx)
622+
future_add_done_callback(FutureObj *fut, PyObject *arg, PyObject *ctx)
623623
{
624624
if (!future_is_alive(fut)) {
625625
PyErr_SetString(PyExc_RuntimeError, "uninitialized Future object");
@@ -906,16 +906,15 @@ _asyncio_Future_add_done_callback_impl(FutureObj *self, PyObject *fn,
906906
/*[clinic end generated code: output=7ce635bbc9554c1e input=15ab0693a96e9533]*/
907907
{
908908
if (context == NULL) {
909-
context = (PyObject *)PyContext_CopyCurrent();
909+
context = PyContext_CopyCurrent();
910910
if (context == NULL) {
911911
return NULL;
912912
}
913-
PyObject *res = future_add_done_callback(
914-
self, fn, (PyContext *)context);
913+
PyObject *res = future_add_done_callback(self, fn, context);
915914
Py_DECREF(context);
916915
return res;
917916
}
918-
return future_add_done_callback(self, fn, (PyContext *)context);
917+
return future_add_done_callback(self, fn, context);
919918
}
920919

921920
/*[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)