Skip to content

Commit 8cb8d5d

Browse files
bpo-37189: Export old PyRun_XXX() functions (GH-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. (cherry picked from commit 343ed0f) Co-authored-by: Victor Stinner <[email protected]>
1 parent 69610f8 commit 8cb8d5d

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

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
#ifndef Py_LIMITED_API
1111
PyAPI_FUNC(int) PyRun_SimpleStringFlags(const char *, PyCompilerFlags *);
12-
PyAPI_FUNC(int) PyRun_AnyFileFlags(FILE *, const char *, PyCompilerFlags *);
1312
PyAPI_FUNC(int) PyRun_AnyFileExFlags(
1413
FILE *fp,
1514
const char *filename, /* decoded from the filesystem encoding */
@@ -122,7 +121,7 @@ PyAPI_FUNC(struct symtable *) Py_SymtableString(
122121
PyAPI_FUNC(const char *) _Py_SourceAsString(
123122
PyObject *cmd,
124123
const char *funcname,
125-
const char *what,
124+
const char *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
#ifndef Py_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(const char *str, int s, PyObject *g, PyObject *l);
150+
PyAPI_FUNC(int) PyRun_AnyFile(FILE *fp, const char *name);
151+
PyAPI_FUNC(int) PyRun_AnyFileEx(FILE *fp, const char *name, int closeit);
152+
PyAPI_FUNC(int) PyRun_AnyFileFlags(FILE *, const char *, PyCompilerFlags *);
153+
PyAPI_FUNC(int) PyRun_SimpleString(const char *s);
154+
PyAPI_FUNC(int) PyRun_SimpleFile(FILE *f, const char *p);
155+
PyAPI_FUNC(int) PyRun_SimpleFileEx(FILE *f, const char *p, int c);
156+
PyAPI_FUNC(int) PyRun_InteractiveOne(FILE *f, const char *p);
157+
PyAPI_FUNC(int) PyRun_InteractiveLoop(FILE *f, const char *p);
158+
PyAPI_FUNC(PyObject *) PyRun_File(FILE *fp, const char *p, int s, PyObject *g, PyObject *l);
159+
PyAPI_FUNC(PyObject *) PyRun_FileEx(FILE *fp, const char *p, int s, PyObject *g, PyObject *l, int c);
160+
PyAPI_FUNC(PyObject *) PyRun_FileFlags(FILE *fp, const char *p, int s, PyObject *g, PyObject *l, PyCompilerFlags *flags);
161+
146162
/* Use macros for a bunch of old variants */
147163
#define PyRun_String(str, s, g, l) PyRun_StringFlags(str, s, g, l, NULL)
148164
#define PyRun_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)