PyAPI: support retrieving the exception when running a string

- Optionally get the error as a single line.
- Support access the error as an allocated string.
- PyC_ExceptionBuffer_Simple was always printing to the `stdout` while
  PyC_ExceptionBuffer didn't, now either print to the output.

Without this, callers are unable to do anything with the error string.
This commit is contained in:
2021-04-12 21:39:56 +10:00
parent 8d9fd0427d
commit f5060bc901
8 changed files with 106 additions and 44 deletions

View File

@@ -733,7 +733,6 @@ PyObject *PyC_ExceptionBuffer_Simple(void)
PyErr_Restore(error_type, error_value, error_traceback);
PyErr_Print();
PyErr_Clear();
return string_io_buf;
}