Mailing List Archive

bpo-43239: Export PyCFunction_New with PyAPI_FUNC (GH-24551)
https://github.com/python/cpython/commit/7bb1cafa4e3d648669212ea4c6d11d6eafc6da23
commit: 7bb1cafa4e3d648669212ea4c6d11d6eafc6da23
branch: master
author: Petr Viktorin <encukou@gmail.com>
committer: encukou <encukou@gmail.com>
date: 2021-02-23T13:23:56+01:00
summary:

bpo-43239: Export PyCFunction_New with PyAPI_FUNC (GH-24551)

files:
A Misc/NEWS.d/next/C API/2021-02-16-17-30-16.bpo-43239.FQqOGz.rst
M Include/methodobject.h

diff --git a/Include/methodobject.h b/Include/methodobject.h
index 5d06d7691ba32..7aa4e41ccca1f 100644
--- a/Include/methodobject.h
+++ b/Include/methodobject.h
@@ -41,7 +41,13 @@ struct PyMethodDef {
};
typedef struct PyMethodDef PyMethodDef;

+/* PyCFunction_New is declared as a function for stable ABI (declaration is
+ * needed for e.g. GCC with -fvisibility=hidden), but redefined as a macro
+ * that calls PyCFunction_NewEx. */
+PyAPI_FUNC(PyObject *) PyCFunction_New(PyMethodDef *, PyObject *);
#define PyCFunction_New(ML, SELF) PyCFunction_NewEx((ML), (SELF), NULL)
+
+/* PyCFunction_NewEx is similar: on 3.9+, this calls PyCMethod_New. */
PyAPI_FUNC(PyObject *) PyCFunction_NewEx(PyMethodDef *, PyObject *,
PyObject *);

diff --git a/Misc/NEWS.d/next/C API/2021-02-16-17-30-16.bpo-43239.FQqOGz.rst b/Misc/NEWS.d/next/C API/2021-02-16-17-30-16.bpo-43239.FQqOGz.rst
new file mode 100644
index 0000000000000..cded580ae4bc2
--- /dev/null
+++ b/Misc/NEWS.d/next/C API/2021-02-16-17-30-16.bpo-43239.FQqOGz.rst
@@ -0,0 +1,2 @@
+The :c:func:`PyCFunction_New` function is now exported in the ABI when
+compiled with ``-fvisibility=hidden``.

_______________________________________________
Python-checkins mailing list
Python-checkins@python.org
https://mail.python.org/mailman/listinfo/python-checkins