My application embeds python. The application extends the embedded python by adding it's own function:
PyObject *ReadDPoint(PyObject *self, PyObject *args)
Then the application runs different python scripts(modules) which invoke the ReadDPoint extension function. The task is to determine the module name inside the invoked ReadDPoint function, name of the module from which the function is called. I expected that the solution is like one of these:
PyObject *module_name = PyObject_GetAttrString(self, "__name__")
or
char *module_name = PyModule_GetName(self)
But I with a great surprise have found out that inside the extension function ReadDpoint self is equal to NULL, and referring to it leads to crash. Is there a way to determine the module name inside the C function? Thank you!