diff --git a/{{ cookiecutter.format }}/src/bootstrap/main.c b/{{ cookiecutter.format }}/src/bootstrap/main.c index 48aa5a7..fcddc86 100644 --- a/{{ cookiecutter.format }}/src/bootstrap/main.c +++ b/{{ cookiecutter.format }}/src/bootstrap/main.c @@ -237,8 +237,17 @@ int main(int argc, char *argv[]) { debug_log("Could not determine exit code\n"); ret = -10; } - else { + } else if (PyLong_Check(systemExit_code)) { + // SystemExit with error code ret = (int) PyLong_AsLong(systemExit_code); + } else { + // Convert exit code to a string. This is required by runpy._error + ret = -11; + printf("---------------------------------------------------------------------------\n"); + printf("Application quit abnormally!\n"); + + // Display exit message in the crash dialog. + PyObject_Print(systemExit_code, stdout, Py_PRINT_RAW); } } else { ret = -6;