[Python-checkins] bpo-40170: Always define PyExceptionClass_Name() as a function (GH-24553)
vstinner
webhook-mailer at python.org
Wed Feb 17 05:51:34 EST 2021
https://github.com/python/cpython/commit/cd80f430daa7dfe7feeb431ed34f88db5f64aa30
commit: cd80f430daa7dfe7feeb431ed34f88db5f64aa30
branch: master
author: Erlend Egeberg Aasland <erlend.aasland at innova.no>
committer: vstinner <vstinner at python.org>
date: 2021-02-17T11:51:08+01:00
summary:
bpo-40170: Always define PyExceptionClass_Name() as a function (GH-24553)
Remove macro variant of PyExceptionClass_Name().
files:
A Misc/NEWS.d/next/C API/2021-02-16-22-29-39.bpo-40170.ahHmOo.rst
M Include/cpython/pyerrors.h
M Objects/exceptions.c
diff --git a/Include/cpython/pyerrors.h b/Include/cpython/pyerrors.h
index c2500d927bf7f..6711e8be68ffe 100644
--- a/Include/cpython/pyerrors.h
+++ b/Include/cpython/pyerrors.h
@@ -78,10 +78,6 @@ PyAPI_FUNC(void) _PyErr_GetExcInfo(PyThreadState *, PyObject **, PyObject **, Py
PyAPI_FUNC(void) _PyErr_ChainExceptions(PyObject *, PyObject *, PyObject *);
-/* */
-
-#define PyExceptionClass_Name(x) (((PyTypeObject*)(x))->tp_name)
-
/* Convenience functions */
#ifdef MS_WINDOWS
diff --git a/Misc/NEWS.d/next/C API/2021-02-16-22-29-39.bpo-40170.ahHmOo.rst b/Misc/NEWS.d/next/C API/2021-02-16-22-29-39.bpo-40170.ahHmOo.rst
new file mode 100644
index 0000000000000..348fcce98e631
--- /dev/null
+++ b/Misc/NEWS.d/next/C API/2021-02-16-22-29-39.bpo-40170.ahHmOo.rst
@@ -0,0 +1,3 @@
+:c:func:`PyExceptionClass_Name` is now always declared as a function, in
+order to hide implementation details. The macro accessed
+:c:member:`PyTypeObject.tp_name` directly. Patch by Erlend E. Aasland.
diff --git a/Objects/exceptions.c b/Objects/exceptions.c
index d4824938a0f50..62cec9a90f580 100644
--- a/Objects/exceptions.c
+++ b/Objects/exceptions.c
@@ -364,8 +364,6 @@ PyException_SetContext(PyObject *self, PyObject *context)
Py_XSETREF(_PyBaseExceptionObject_cast(self)->context, context);
}
-#undef PyExceptionClass_Name
-
const char *
PyExceptionClass_Name(PyObject *ob)
{
More information about the Python-checkins
mailing list