Since Python 3.10, Py_REFCNT() can no longer be used as an l-value. See https://docs.python.org/3.10/whatsnew/3.10.html#id2 for details. --- a/_ruamel_yaml.c +++ b/_ruamel_yaml.c @@ -23877,9 +23877,9 @@ { PyObject *etype, *eval, *etb; PyErr_Fetch(&etype, &eval, &etb); - ++Py_REFCNT(o); + Py_SET_REFCNT(o, Py_REFCNT(o) + 1); __pyx_pw_12_ruamel_yaml_7CParser_3__dealloc__(o); - --Py_REFCNT(o); + Py_SET_REFCNT(o, Py_REFCNT(o) - 1); PyErr_Restore(etype, eval, etb); } Py_CLEAR(p->stream); @@ -24050,9 +24050,9 @@ { PyObject *etype, *eval, *etb; PyErr_Fetch(&etype, &eval, &etb); - ++Py_REFCNT(o); + Py_SET_REFCNT(o, Py_REFCNT(o) + 1); __pyx_pw_12_ruamel_yaml_8CEmitter_3__dealloc__(o); - --Py_REFCNT(o); + Py_SET_REFCNT(o, Py_REFCNT(o) - 1); PyErr_Restore(etype, eval, etb); } Py_CLEAR(p->stream); --- a/_ruamel_yaml.h +++ b/_ruamel_yaml.h @@ -12,6 +12,10 @@ #define PyString_GET_SIZE PyBytes_GET_SIZE #define PyString_FromStringAndSize PyBytes_FromStringAndSize +#if PY_VERSION_HEX < 0x030900A4 +# define Py_SET_REFCNT(obj, refcnt) ((Py_REFCNT(obj) = (refcnt)), (void)0) +#endif + #endif #ifdef _MSC_VER /* MS Visual C++ 6.0 */