Commit bc7d9616 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Convert Py_FatalError to a macro to get line numbers

Was tired of seeing bare "unimplemented" error messages and having
to track down where they were coming from -- especially tricky
when trying to add fork() support and the errors were in the child.
parent f454bb8d
......@@ -34,7 +34,15 @@ PyAPI_DATA(int) Py_HashRandomizationFlag;
PYTHONPATH and PYTHONHOME from the environment */
#define Py_GETENV(s) (Py_IgnoreEnvironmentFlag ? NULL : getenv(s))
PyAPI_FUNC(void) Py_FatalError(const char *message) __attribute__((__noreturn__));
// Pyston change: make Py_FatalError a macro so that it can access linenumber info, similar to assert:
//PyAPI_FUNC(void) Py_FatalError(const char *message) __attribute__((__noreturn__));
#define _STRINGIFY(N) #N
#define STRINGIFY(N) _STRINGIFY(N)
#define Py_FatalError(message) \
do { \
fprintf(stderr, __FILE__ ":" STRINGIFY(__LINE__) ": %s: Fatal Python error: %s\n", __PRETTY_FUNCTION__, message); \
abort(); \
} while (0)
#ifdef __cplusplus
}
......
......@@ -132,13 +132,6 @@ extern "C" void PyBuffer_Release(Py_buffer* view) {
view->obj = NULL;
}
// Not sure why we need another declaration here:
extern "C" void Py_FatalError(const char* msg) __attribute__((__noreturn__));
extern "C" void Py_FatalError(const char* msg) {
fprintf(stderr, "\nFatal Python error: %s\n", msg);
abort();
}
extern "C" void _PyErr_BadInternalCall(const char* filename, int lineno) {
Py_FatalError("unimplemented");
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment