Le 12/04/17 à 11:47, Peter Otten a écrit :
Vincent Vande Vyvre wrote:


No, no warning.


For the truth, this code is copy-pasted from the doc.

https://docs.python.org/3.5//extending/newtypes.html#adding-data-and-methods-to-the-basic-example
But the example expects objects (the big O), not strings. Following the
example you need

      if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|", kwlist, &name))
          return -1;

and also

static PyMemberDef Test_members[] = {
      {"name", T_OBJECT_EX, offsetof(Test, name), 0,
       "The object name"},
      {NULL}  /* Sentinel */
};

If you want a string instead of an object you must not apply Py_INCREF(),
you probably have to manage its lifetime yourself.


I've just installed a new venv with the 3.6.1 and tested your changes.

And now, that's all right.

I see the devil is into the details ...


Many thanks Peter


Vincent

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to