My application has python built in. The application extends the built-in python by adding its own function:
PyObject *ReadDPoint(PyObject *self, PyObject *args)
Then the application runs various python scripts (modules) that call the ReadDPoint extension function. The task is to determine the module name inside the called ReadDPoint function, the name of the module from which the function is called. I expected the solution to be similar to one of the following:
PyObject *module_name = PyObject_GetAttrString(self, "__name__")
or
char *module_name = PyModule_GetName(self)
But I was very surprised to find that inside the extension function ReadDpoint self is NULL, and accessing it will fail. Is there a way to determine the module name inside a C function? Thank!
source
share