Problem using new Python type: "cannot add type to string"
zptang at hotmail.com
Sat Sep 22 03:55:24 CEST 2001
I created a new Python type (extension in C), and tried to call a
function with an object of the new type as the argument:
PyObject *arglist = PyTuple_New(1);
PyTuple_SetItem(arglist, 0, myObj); /* myObj is an object of the new
However, the PyObject_CallObject() failed with the error message
saying that: "cannot add type <my new type name> to string". It seems
that the error was generated when string_concat() in
Objects/stringobject.c is invoked. The function tested on the type of
the second argument and outputted error whenever the argument is not a
I would like to know why does this problem appear. Is there any
methods in the new type that I forgot to implement? (BTW, I did
implemented the tp_str, tp_repr, and tp_print in my new type).
More information about the Python-list