Skip to content

Commit 343ed0f

Browse files
authored
bpo-37189: Export old PyRun_XXX() functions (#14142)
Many PyRun_XXX() functions like PyRun_String() were no longer exported in libpython38.dll by mistake. Export them again to fix the ABI compatibiliy.
1 parent dbdc991 commit 343ed0f

2 files changed

Lines changed: 21 additions & 2 deletions

File tree

‎Include/pythonrun.h‎

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ extern "C" {
99

1010
#ifndefPy_LIMITED_API
1111
PyAPI_FUNC(int) PyRun_SimpleStringFlags(constchar*, PyCompilerFlags*);
12-
PyAPI_FUNC(int) PyRun_AnyFileFlags(FILE*, constchar*, PyCompilerFlags*);
1312
PyAPI_FUNC(int) PyRun_AnyFileExFlags(
1413
FILE*fp,
1514
constchar*filename, /* decoded from the filesystem encoding */
@@ -122,7 +121,7 @@ PyAPI_FUNC(struct symtable *) Py_SymtableString(
122121
PyAPI_FUNC(constchar*) _Py_SourceAsString(
123122
PyObject*cmd,
124123
constchar*funcname,
125-
constchar*what,
124+
constchar*what,
126125
PyCompilerFlags*cf,
127126
PyObject**cmd_copy);
128127

@@ -143,6 +142,23 @@ PyAPI_FUNC(void) PyErr_PrintEx(int);
143142
PyAPI_FUNC(void) PyErr_Display(PyObject*, PyObject*, PyObject*);
144143

145144
#ifndefPy_LIMITED_API
145+
/* A function flavor is also exported by libpython. It is required when
146+
libpython is accessed directly rather than using header files which defines
147+
macros below. On Windows, for example, PyAPI_FUNC() uses dllexport to
148+
export functions in pythonXX.dll. */
149+
PyAPI_FUNC(PyObject*) PyRun_String(constchar*str, ints, PyObject*g, PyObject*l);
150+
PyAPI_FUNC(int) PyRun_AnyFile(FILE*fp, constchar*name);
151+
PyAPI_FUNC(int) PyRun_AnyFileEx(FILE*fp, constchar*name, intcloseit);
152+
PyAPI_FUNC(int) PyRun_AnyFileFlags(FILE*, constchar*, PyCompilerFlags*);
153+
PyAPI_FUNC(int) PyRun_SimpleString(constchar*s);
154+
PyAPI_FUNC(int) PyRun_SimpleFile(FILE*f, constchar*p);
155+
PyAPI_FUNC(int) PyRun_SimpleFileEx(FILE*f, constchar*p, intc);
156+
PyAPI_FUNC(int) PyRun_InteractiveOne(FILE*f, constchar*p);
157+
PyAPI_FUNC(int) PyRun_InteractiveLoop(FILE*f, constchar*p);
158+
PyAPI_FUNC(PyObject*) PyRun_File(FILE*fp, constchar*p, ints, PyObject*g, PyObject*l);
159+
PyAPI_FUNC(PyObject*) PyRun_FileEx(FILE*fp, constchar*p, ints, PyObject*g, PyObject*l, intc);
160+
PyAPI_FUNC(PyObject*) PyRun_FileFlags(FILE*fp, constchar*p, ints, PyObject*g, PyObject*l, PyCompilerFlags*flags);
161+
146162
/* Use macros for a bunch of old variants */
147163
#definePyRun_String(str, s, g, l) PyRun_StringFlags(str, s, g, l, NULL)
148164
#definePyRun_AnyFile(fp, name) PyRun_AnyFileExFlags(fp, name, 0, NULL)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Many ``PyRun_XXX()`` functions like :c:func:`PyRun_String` were no longer
2+
exported in ``libpython38.dll`` by mistake. Export them again to fix the ABI
3+
compatibiliy.

0 commit comments

Comments
 (0)