]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-40170: Always define PyExceptionClass_Name() as a function (GH-24553)
authorErlend Egeberg Aasland <erlend.aasland@innova.no>
Wed, 17 Feb 2021 10:51:08 +0000 (11:51 +0100)
committerGitHub <noreply@github.com>
Wed, 17 Feb 2021 10:51:08 +0000 (11:51 +0100)
Remove macro variant of PyExceptionClass_Name().

Include/cpython/pyerrors.h
Misc/NEWS.d/next/C API/2021-02-16-22-29-39.bpo-40170.ahHmOo.rst [new file with mode: 0644]
Objects/exceptions.c

index c2500d927bf7f078ec4b5422092687ec8cf0cdd6..6711e8be68ffeb229a44ad54bd3dfe6f5c34b689 100644 (file)
@@ -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 (file)
index 0000000..348fcce
--- /dev/null
@@ -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.
index d4824938a0f50716588860acbd8ba457c144fa30..62cec9a90f5804a991c700dd0132f467778dd64a 100644 (file)
@@ -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)
 {