From f83f803c1e07fbf429e0b9a510c7a3a61837dcd1 Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Fri, 16 Apr 2021 15:41:57 +0200 Subject: [PATCH 1/3] bpo-43868: Remove PyOS_ReadlineFunctionPointer from the stable ABI list The inclusion of PyOS_ReadlineFunctionPointer in python3dll.c was a mistake. According to PEP 384: > functions expecting FILE* are not part of the ABI, to avoid depending > on a specific version of the Microsoft C runtime DLL on Windows. --- Include/cpython/pythonrun.h | 1 + Include/pythonrun.h | 1 - PC/python3dll.c | 1 - 3 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Include/cpython/pythonrun.h b/Include/cpython/pythonrun.h index ffca0e457d58b58..2e72d0820d34f54 100644 --- a/Include/cpython/pythonrun.h +++ b/Include/cpython/pythonrun.h @@ -118,3 +118,4 @@ PyAPI_FUNC(PyObject *) PyRun_FileFlags(FILE *fp, const char *p, int s, PyObject /* Stuff with no proper home (yet) */ PyAPI_FUNC(char *) PyOS_Readline(FILE *, FILE *, const char *); PyAPI_DATA(PyThreadState*) _PyOS_ReadlineTState; +PyAPI_DATA(char) *(*PyOS_ReadlineFunctionPointer)(FILE *, FILE *, const char *); diff --git a/Include/pythonrun.h b/Include/pythonrun.h index b87bc738902420d..b0a2fc3002d37d0 100644 --- a/Include/pythonrun.h +++ b/Include/pythonrun.h @@ -16,7 +16,6 @@ PyAPI_FUNC(void) PyErr_Display(PyObject *, PyObject *, PyObject *); /* Stuff with no proper home (yet) */ PyAPI_DATA(int) (*PyOS_InputHook)(void); -PyAPI_DATA(char) *(*PyOS_ReadlineFunctionPointer)(FILE *, FILE *, const char *); /* Stack size, in "pointers" (so we get extra safety margins on 64-bit platforms). On a 32-bit platform, this translates diff --git a/PC/python3dll.c b/PC/python3dll.c index 195c6531fdf8874..e5a21ed7c022e79 100644 --- a/PC/python3dll.c +++ b/PC/python3dll.c @@ -808,7 +808,6 @@ EXPORT_DATA(PyODictIter_Type) EXPORT_DATA(PyODictKeys_Type) EXPORT_DATA(PyODictValues_Type) EXPORT_DATA(PyOS_InputHook) -EXPORT_DATA(PyOS_ReadlineFunctionPointer) EXPORT_DATA(PyProperty_Type) EXPORT_DATA(PyRange_Type) EXPORT_DATA(PyRangeIter_Type) From 12c85b90ca78d6ae7b93286b0f3d3c1d2de36dad Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Fri, 16 Apr 2021 18:16:05 +0200 Subject: [PATCH 2/3] Add a NEWS blurb --- .../NEWS.d/next/C API/2021-04-16-18-15-56.bpo-43868.twQ7KH.rst | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 Misc/NEWS.d/next/C API/2021-04-16-18-15-56.bpo-43868.twQ7KH.rst diff --git a/Misc/NEWS.d/next/C API/2021-04-16-18-15-56.bpo-43868.twQ7KH.rst b/Misc/NEWS.d/next/C API/2021-04-16-18-15-56.bpo-43868.twQ7KH.rst new file mode 100644 index 000000000000000..1d6fc099325344a --- /dev/null +++ b/Misc/NEWS.d/next/C API/2021-04-16-18-15-56.bpo-43868.twQ7KH.rst @@ -0,0 +1,3 @@ +:c:func:`PyOS_ReadlineFunctionPointer` is no longer exported by +``python3.dll`` on Windows. Like any function that takes ``FILE*``, it is +not part of the stable ABI. From 42c9f3c90f9d247f50bbc0e948308ca5e791e329 Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Tue, 20 Apr 2021 13:43:32 +0200 Subject: [PATCH 3/3] Add whatsnew entry and fix up blurb --- Doc/whatsnew/3.10.rst | 6 ++++++ .../next/C API/2021-04-16-18-15-56.bpo-43868.twQ7KH.rst | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Doc/whatsnew/3.10.rst b/Doc/whatsnew/3.10.rst index 6623adfbf4f3d32..bb4bd3099e8329f 100644 --- a/Doc/whatsnew/3.10.rst +++ b/Doc/whatsnew/3.10.rst @@ -1697,6 +1697,12 @@ Removed Use Python :mod:`symtable` module instead. (Contributed by Victor Stinner in :issue:`43244`.) +* Remove :c:func:`PyOS_ReadlineFunctionPointer` from the limited C API headers + and from ``python3.dll``, the library that provides the stable ABI on + Windows. Since the function takes a ``FILE*`` argument, its ABI stability + cannot be guaranteed. + (Contributed by Petr Viktorin in :issue:`43868`.) + * Remove ``ast.h``, ``asdl.h``, and ``Python-ast.h`` header files. These functions were undocumented and excluded from the limited C API. Most names defined by these header files were not prefixed by ``Py`` and so diff --git a/Misc/NEWS.d/next/C API/2021-04-16-18-15-56.bpo-43868.twQ7KH.rst b/Misc/NEWS.d/next/C API/2021-04-16-18-15-56.bpo-43868.twQ7KH.rst index 1d6fc099325344a..50888b8b37ab846 100644 --- a/Misc/NEWS.d/next/C API/2021-04-16-18-15-56.bpo-43868.twQ7KH.rst +++ b/Misc/NEWS.d/next/C API/2021-04-16-18-15-56.bpo-43868.twQ7KH.rst @@ -1,3 +1,3 @@ -:c:func:`PyOS_ReadlineFunctionPointer` is no longer exported by -``python3.dll`` on Windows. Like any function that takes ``FILE*``, it is -not part of the stable ABI. +:c:func:`PyOS_ReadlineFunctionPointer` is no longer exported by limited C API +headers and by ``python3.dll`` on Windows. Like any function that takes +``FILE*``, it is not part of the stable ABI.