Py_FindMethod is gone in python3. What should i use instead?

I am trying to port the avl module for Python that I found on sourceforge to python3. I managed to get rid of most of the errors, but I did not find clear information on what to do with

Py_LOCAL(PyObject *) avl_tree_getattr(avl_tree_Object * self, char *name) { return Py_FindMethod(avl_tree_methods, (PyObject *) self, name); } 

There are several suggestions for mailing lists to just use PyObject_GenericGetAttr instead, but I have to admit that I don’t know the internal elements of python enough to see how I can apply it in this particular case.

Any clues?

+5
source share
1 answer

as you said, PyObject_GenericGetAttr seems to be the solution to the problem.

In Pascal, it looks like this: Result := PyObject_GenericGetAttr(obj, PyString_FromString(key))

Wed https://github.com/pyscripter/python4delphi/commit/da1179cd5bb5dc033f7e02fac90db2b4859c4edd#diff-3e36d1a884559dd32bbdd327290b89abR173

In C, it could be something like:

 'return PyObject_GenericGetAttr((PyObject *) self, PyString_FromString(name))' 
0
source

Source: https://habr.com/ru/post/1380550/


All Articles