Commit b1542583 authored by Victor Stinner's avatar Victor Stinner Committed by GitHub

bpo-38205: Py_UNREACHABLE() calls Py_FatalError() (GH-16290)

parent bc2256ea
...@@ -101,31 +101,26 @@ ...@@ -101,31 +101,26 @@
#endif #endif
#if defined(RANDALL_WAS_HERE) #if defined(RANDALL_WAS_HERE)
#define Py_UNREACHABLE() do { \ #define Py_UNREACHABLE() \
fputs( \ Py_FatalError( \
"ERROR:\n\n" \ "If you're seeing this, the code is in what I thought was\n" \
"If you're seeing this, the code is in what I thought was\n" \ "an unreachable state.\n\n" \
"an unreachable state.\n\n" \ "I could give you advice for what to do, but honestly, why\n" \
"I could give you advice for what to do, but honestly, why\n" \ "should you trust me? I clearly screwed this up. I'm writing\n" \
"should you trust me? I clearly screwed this up. I'm writing\n" \ "a message that should never appear, yet I know it will\n" \
"a message that should never appear, yet I know it will\n" \ "probably appear someday.\n\n" \
"probably appear someday.\n\n" \ "On a deep level, I know I'm not up to this task.\n" \
"On a deep level, I know I'm not up to this task.\n" \ "I'm so sorry.\n" \
"I'm so sorry.\n\n" \ "https://xkcd.com/2200")
"https://xkcd.com/2200\n", stderr); \
abort(); \
} while(0)
#elif defined(Py_DEBUG) #elif defined(Py_DEBUG)
#define Py_UNREACHABLE() do { \ #define Py_UNREACHABLE() \
fputs( \ Py_FatalError( \
"ERROR:\n\n" \ "We've reached an unreachable state. Anything is possible.\n" \
"We've reached an unreachable state. Anything is possible.\n" \ "The limits were in our heads all along. Follow your dreams.\n" \
"The limits were in our heads all along. Follow your dreams.\n\n" \ "https://xkcd.com/2200")
"https://xkcd.com/2200\n", stderr); \
abort(); \
} while(0)
#else #else
#define Py_UNREACHABLE() abort() #define Py_UNREACHABLE() \
Py_FatalError("Unreachable C code path reached")
#endif #endif
#endif /* Py_PYMACRO_H */ #endif /* Py_PYMACRO_H */
The :c:func:`Py_UNREACHABLE` macro now calls :c:func:`Py_FatalError`.
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