diff -r 03739fa3fc5c pypy/module/cpyext/pyobject.py --- a/pypy/module/cpyext/pyobject.py Tue Apr 03 06:06:40 2018 +0300 +++ b/pypy/module/cpyext/pyobject.py Tue Apr 03 07:51:49 2018 +0200 @@ -60,7 +60,7 @@ def _cpyext_attach_pyobj(self, space, py_obj): self._cpy_ref = py_obj - rawrefcount.create_link_pyobj(self, py_obj) + rawrefcount.create_link_pypy(self, py_obj) cls._cpyext_attach_pyobj = _cpyext_attach_pyobj add_direct_pyobj_storage(W_BaseCPyObject) diff -r 03739fa3fc5c pypy/module/cpyext/typeobject.py --- a/pypy/module/cpyext/typeobject.py Tue Apr 03 06:06:40 2018 +0300 +++ b/pypy/module/cpyext/typeobject.py Tue Apr 03 07:51:49 2018 +0200 @@ -517,6 +517,10 @@ self.w_doc = space.newtext( rffi.charp2str(cts.cast('char*', pto.c_tp_doc))) + def _cpyext_attach_pyobj(self, space, py_obj): + self._cpy_ref = py_obj + rawrefcount.create_link_pyobj(self, py_obj) + @bootstrap_function def init_typeobject(space): make_typedescr(space.w_type.layout.typedef,