Open erlend-aasland opened 2 years ago
cc @ericsnowcurrently
Hello!
I have just written my first extended python module. Thank you for the documentation, it was a good help! A minor thing I found in the example code, that I think, should be different.
Under 1. Extending Python with C or C++
: 1.1. A Simple Example
, 1.2. Intermezzo: Errors and Exceptions
, and 1.3. Back to the Example
.
static PyObject *
spam_system(PyObject *self, PyObject *args)
{
const char *command;
int sts;
if (!PyArg_ParseTuple(args, "s", &command))
return NULL;
sts = system(command);
return PyLong_FromLong(sts);
}
Should return NULL;
not better be return Py_None;
?
should
return NULL;
not better bereturn Py_None;
?
Take a look at the immediately following section (1.2 Intermezzo: Errors and Exceptions), where this is explained.
thank you! and sorry if this is just because I not understood everything.
Quoting Petr in issue gh-93078:
Originally posted by @encukou in https://github.com/python/cpython/issues/93078#issuecomment-1135579802