bpo-34762: Fix contextvars C API to use PyObject* pointer types. (GH-9473)
(cherry picked from commit 2ec872b31e25cee1f983fe07991fb53f3fd1cbac)
Co-authored-by: Yury Selivanov <yury@magic.io>
diff --git a/Include/context.h b/Include/context.h
index 8b9f129..9581285 100644
--- a/Include/context.h
+++ b/Include/context.h
@@ -22,19 +22,19 @@
#define PyContextToken_CheckExact(o) (Py_TYPE(o) == &PyContextToken_Type)
-PyAPI_FUNC(PyContext *) PyContext_New(void);
-PyAPI_FUNC(PyContext *) PyContext_Copy(PyContext *);
-PyAPI_FUNC(PyContext *) PyContext_CopyCurrent(void);
+PyAPI_FUNC(PyObject *) PyContext_New(void);
+PyAPI_FUNC(PyObject *) PyContext_Copy(PyObject *);
+PyAPI_FUNC(PyObject *) PyContext_CopyCurrent(void);
-PyAPI_FUNC(int) PyContext_Enter(PyContext *);
-PyAPI_FUNC(int) PyContext_Exit(PyContext *);
+PyAPI_FUNC(int) PyContext_Enter(PyObject *);
+PyAPI_FUNC(int) PyContext_Exit(PyObject *);
/* Create a new context variable.
default_value can be NULL.
*/
-PyAPI_FUNC(PyContextVar *) PyContextVar_New(
+PyAPI_FUNC(PyObject *) PyContextVar_New(
const char *name, PyObject *default_value);
@@ -54,21 +54,19 @@
'*value' will be a new ref, if not NULL.
*/
PyAPI_FUNC(int) PyContextVar_Get(
- PyContextVar *var, PyObject *default_value, PyObject **value);
+ PyObject *var, PyObject *default_value, PyObject **value);
/* Set a new value for the variable.
Returns NULL if an error occurs.
*/
-PyAPI_FUNC(PyContextToken *) PyContextVar_Set(
- PyContextVar *var, PyObject *value);
+PyAPI_FUNC(PyObject *) PyContextVar_Set(PyObject *var, PyObject *value);
/* Reset a variable to its previous value.
Returns 0 on success, -1 on error.
*/
-PyAPI_FUNC(int) PyContextVar_Reset(
- PyContextVar *var, PyContextToken *token);
+PyAPI_FUNC(int) PyContextVar_Reset(PyObject *var, PyObject *token);
/* This method is exposed only for CPython tests. Don not use it. */