How to catch a usefull error message ?

Gregory Ewing greg.ewing at canterbury.ac.nz
Thu Apr 25 03:00:29 EDT 2019


Vincent Vande Vyvre wrote:
> But the "return 0" is a common case for an "Foo_init()"
> 
> see: 
> https://docs.python.org/3.5//extending/newtypes.html#adding-data-and-methods-to-the-basic-example

Look carefully at the init function from that example:

     static int
     Noddy_init(Noddy *self, PyObject *args, PyObject *kwds)
     {
         PyObject *first=NULL, *last=NULL, *tmp;

         static char *kwlist[] = {"first", "last", "number", NULL};

         if (! PyArg_ParseTupleAndKeywords(args, kwds, "|OOi", kwlist,
                                       &first, &last,
                                       &self->number))
             return -1;
             ^^^^^^^^^

See that?

-- 
Greg



More information about the Python-list mailing list