[Python-checkins] bpo-38205: Py_UNREACHABLE() calls Py_FatalError() (GH-16290)
Victor Stinner
webhook-mailer at python.org
Fri Sep 20 17:10:20 EDT 2019
https://github.com/python/cpython/commit/b1542583bee204130934c2b90684041e29378250
commit: b1542583bee204130934c2b90684041e29378250
branch: master
author: Victor Stinner <vstinner at redhat.com>
committer: GitHub <noreply at github.com>
date: 2019-09-20T23:10:16+02:00
summary:
bpo-38205: Py_UNREACHABLE() calls Py_FatalError() (GH-16290)
files:
A Misc/NEWS.d/next/C API/2019-09-19-18-26-29.bpo-38205.Db1OJL.rst
M Include/pymacro.h
diff --git a/Include/pymacro.h b/Include/pymacro.h
index ae09063e10d8..c080fb164e35 100644
--- a/Include/pymacro.h
+++ b/Include/pymacro.h
@@ -101,31 +101,26 @@
#endif
#if defined(RANDALL_WAS_HERE)
-#define Py_UNREACHABLE() do { \
- fputs( \
- "ERROR:\n\n" \
- "If you're seeing this, the code is in what I thought was\n" \
- "an unreachable state.\n\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" \
- "a message that should never appear, yet I know it will\n" \
- "probably appear someday.\n\n" \
- "On a deep level, I know I'm not up to this task.\n" \
- "I'm so sorry.\n\n" \
- "https://xkcd.com/2200\n", stderr); \
- abort(); \
- } while(0)
+#define Py_UNREACHABLE() \
+ Py_FatalError( \
+ "If you're seeing this, the code is in what I thought was\n" \
+ "an unreachable state.\n\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" \
+ "a message that should never appear, yet I know it will\n" \
+ "probably appear someday.\n\n" \
+ "On a deep level, I know I'm not up to this task.\n" \
+ "I'm so sorry.\n" \
+ "https://xkcd.com/2200")
#elif defined(Py_DEBUG)
-#define Py_UNREACHABLE() do { \
- fputs( \
- "ERROR:\n\n" \
- "We've reached an unreachable state. Anything is possible.\n" \
- "The limits were in our heads all along. Follow your dreams.\n\n" \
- "https://xkcd.com/2200\n", stderr); \
- abort(); \
- } while(0)
+#define Py_UNREACHABLE() \
+ Py_FatalError( \
+ "We've reached an unreachable state. Anything is possible.\n" \
+ "The limits were in our heads all along. Follow your dreams.\n" \
+ "https://xkcd.com/2200")
#else
-#define Py_UNREACHABLE() abort()
+#define Py_UNREACHABLE() \
+ Py_FatalError("Unreachable C code path reached")
#endif
#endif /* Py_PYMACRO_H */
diff --git a/Misc/NEWS.d/next/C API/2019-09-19-18-26-29.bpo-38205.Db1OJL.rst b/Misc/NEWS.d/next/C API/2019-09-19-18-26-29.bpo-38205.Db1OJL.rst
new file mode 100644
index 000000000000..1818e54d461a
--- /dev/null
+++ b/Misc/NEWS.d/next/C API/2019-09-19-18-26-29.bpo-38205.Db1OJL.rst
@@ -0,0 +1 @@
+The :c:func:`Py_UNREACHABLE` macro now calls :c:func:`Py_FatalError`.
More information about the Python-checkins
mailing list