I am attempting to capture output of an error, whose output is produced by PrErr_Print()
However, no output is appearing. Here is what I have tried, via this thread:
Redirect Embedded Python IO to a console created with AllocConsole
PyObject* sys = PyImport_ImportModule("sys");
PyObject* io = PyImport_ImportModule("io");
PyObject* pystdout = PyObject_CallMethod(io, "open", "ss", "CONOUT$", "wt");
PyObject_SetAttrString(sys, "stderr", pystdout);
if (PyErr_Occurred()) {
printf("Could not redirect python stderr to stdout\n");
PyErr_Print();
extensions_destroy();
return 0;
}
And the creation of the console
/**
* Enable debug console
*/
void debug_enable( void ) {
AllocConsole();
freopen("CONOUT$", "w", stdout);
freopen("CONOUT$", "w", stderr);
printf("Debug mode enabled.\n");
}
I have also attempted to redirect python stderr to it's stdout to no avail.