[issue34762] Change contextvars C API to use PyObject

Serhiy Storchaka report at bugs.python.org
Thu Sep 27 13:20:06 EDT 2018


Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:

Perhaps this change caused new compiler warnings:

In file included from ./Include/pytime.h:6:0,
                 from ./Include/Python.h:68,
                 from /home/serhiy/py/cpython/Modules/_asynciomodule.c:1:
/home/serhiy/py/cpython/Modules/_asynciomodule.c: In function ‘_asyncio_Task___init___impl’:
./Include/object.h:895:14: warning: assignment from incompatible pointer type [-Wincompatible-pointer-types]
         (op) = (op2);                           \
              ^
/home/serhiy/py/cpython/Modules/_asynciomodule.c:1954:5: note: in expansion of macro ‘Py_XSETREF’
     Py_XSETREF(self->task_context, PyContext_CopyCurrent());
     ^~~~~~~~~~
/home/serhiy/py/cpython/Modules/_decimal/_decimal.c: In function ‘init_current_context’:
/home/serhiy/py/cpython/Modules/_decimal/_decimal.c:1503:44: warning: passing argument 1 of ‘PyContextVar_Set’ from incompatible pointer type [-Wincompatible-pointer-types]
     PyContextToken *tok = PyContextVar_Set(current_context_var, tl_context);
                                            ^~~~~~~~~~~~~~~~~~~
In file included from ./Include/Python.h:116:0,
                 from /home/serhiy/py/cpython/Modules/_decimal/_decimal.c:29:
./Include/context.h:63:24: note: expected ‘PyObject * {aka struct _object *}’ but argument is of type ‘PyContextVar * {aka struct _pycontextvarobject *}’
 PyAPI_FUNC(PyObject *) PyContextVar_Set(PyObject *var, PyObject *value);
                        ^~~~~~~~~~~~~~~~
/home/serhiy/py/cpython/Modules/_decimal/_decimal.c:1503:27: warning: initialization from incompatible pointer type [-Wincompatible-pointer-types]
     PyContextToken *tok = PyContextVar_Set(current_context_var, tl_context);
                           ^~~~~~~~~~~~~~~~
/home/serhiy/py/cpython/Modules/_decimal/_decimal.c: In function ‘current_context’:
/home/serhiy/py/cpython/Modules/_decimal/_decimal.c:1517:26: warning: passing argument 1 of ‘PyContextVar_Get’ from incompatible pointer type [-Wincompatible-pointer-types]
     if (PyContextVar_Get(current_context_var, NULL, &tl_context) < 0) {
                          ^~~~~~~~~~~~~~~~~~~
In file included from ./Include/Python.h:116:0,
                 from /home/serhiy/py/cpython/Modules/_decimal/_decimal.c:29:
./Include/context.h:56:17: note: expected ‘PyObject * {aka struct _object *}’ but argument is of type ‘PyContextVar * {aka struct _pycontextvarobject *}’
 PyAPI_FUNC(int) PyContextVar_Get(
                 ^~~~~~~~~~~~~~~~
/home/serhiy/py/cpython/Modules/_decimal/_decimal.c: In function ‘PyDec_SetCurrentContext’:
/home/serhiy/py/cpython/Modules/_decimal/_decimal.c:1564:44: warning: passing argument 1 of ‘PyContextVar_Set’ from incompatible pointer type [-Wincompatible-pointer-types]
     PyContextToken *tok = PyContextVar_Set(current_context_var, v);
                                            ^~~~~~~~~~~~~~~~~~~
In file included from ./Include/Python.h:116:0,
                 from /home/serhiy/py/cpython/Modules/_decimal/_decimal.c:29:
./Include/context.h:63:24: note: expected ‘PyObject * {aka struct _object *}’ but argument is of type ‘PyContextVar * {aka struct _pycontextvarobject *}’
 PyAPI_FUNC(PyObject *) PyContextVar_Set(PyObject *var, PyObject *value);
                        ^~~~~~~~~~~~~~~~
/home/serhiy/py/cpython/Modules/_decimal/_decimal.c:1564:27: warning: initialization from incompatible pointer type [-Wincompatible-pointer-types]
     PyContextToken *tok = PyContextVar_Set(current_context_var, v);
                           ^~~~~~~~~~~~~~~~
/home/serhiy/py/cpython/Modules/_decimal/_decimal.c: In function ‘PyInit__decimal’:
/home/serhiy/py/cpython/Modules/_decimal/_decimal.c:5542:25: warning: assignment from incompatible pointer type [-Wincompatible-pointer-types]
     current_context_var = PyContextVar_New("decimal_context", NULL);
                         ^

----------
nosy: +serhiy.storchaka
status: closed -> open

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34762>
_______________________________________


More information about the Python-bugs-list mailing list