From d3222d5f1ed42d69cf0b7f19e50caf53703e4f08 Mon Sep 17 00:00:00 2001 From: Pablo Galindo Date: Wed, 2 Dec 2020 02:58:13 +0000 Subject: [PATCH 1/3] bpo-40939: Restore some stable API functions incorrectly deleted --- Python/pythonrun.c | 103 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) diff --git a/Python/pythonrun.c b/Python/pythonrun.c index bd49c40e9786c3..9228caf5161133 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -1371,6 +1371,109 @@ PyOS_CheckStack(void) #endif /* USE_STACKCHECK */ +/* Deprecated C API functions still provided for binary compatibility */ + +#undef PyRun_AnyFile +PyAPI_FUNC(int) +PyRun_AnyFile(FILE *fp, const char *name) +{ + return PyRun_AnyFileExFlags(fp, name, 0, NULL); +} + +#undef PyRun_AnyFileEx +PyAPI_FUNC(int) +PyRun_AnyFileEx(FILE *fp, const char *name, int closeit) +{ + return PyRun_AnyFileExFlags(fp, name, closeit, NULL); +} + +#undef PyRun_AnyFileFlags +PyAPI_FUNC(int) +PyRun_AnyFileFlags(FILE *fp, const char *name, PyCompilerFlags *flags) +{ + return PyRun_AnyFileExFlags(fp, name, 0, flags); +} + +#undef PyRun_File +PyAPI_FUNC(PyObject *) +PyRun_File(FILE *fp, const char *p, int s, PyObject *g, PyObject *l) +{ + return PyRun_FileExFlags(fp, p, s, g, l, 0, NULL); +} + +#undef PyRun_FileEx +PyAPI_FUNC(PyObject *) +PyRun_FileEx(FILE *fp, const char *p, int s, PyObject *g, PyObject *l, int c) +{ + return PyRun_FileExFlags(fp, p, s, g, l, c, NULL); +} + +#undef PyRun_FileFlags +PyAPI_FUNC(PyObject *) +PyRun_FileFlags(FILE *fp, const char *p, int s, PyObject *g, PyObject *l, + PyCompilerFlags *flags) +{ + return PyRun_FileExFlags(fp, p, s, g, l, 0, flags); +} + +#undef PyRun_SimpleFile +PyAPI_FUNC(int) +PyRun_SimpleFile(FILE *f, const char *p) +{ + return PyRun_SimpleFileExFlags(f, p, 0, NULL); +} + +#undef PyRun_SimpleFileEx +PyAPI_FUNC(int) +PyRun_SimpleFileEx(FILE *f, const char *p, int c) +{ + return PyRun_SimpleFileExFlags(f, p, c, NULL); +} + + +#undef PyRun_String +PyAPI_FUNC(PyObject *) +PyRun_String(const char *str, int s, PyObject *g, PyObject *l) +{ + return PyRun_StringFlags(str, s, g, l, NULL); +} + +#undef PyRun_SimpleString +PyAPI_FUNC(int) +PyRun_SimpleString(const char *s) +{ + return PyRun_SimpleStringFlags(s, NULL); +} + +#undef Py_CompileString +PyAPI_FUNC(PyObject *) +Py_CompileString(const char *str, const char *p, int s) +{ + return Py_CompileStringExFlags(str, p, s, NULL, -1); +} + +#undef Py_CompileStringFlags +PyAPI_FUNC(PyObject *) +Py_CompileStringFlags(const char *str, const char *p, int s, + PyCompilerFlags *flags) +{ + return Py_CompileStringExFlags(str, p, s, flags, -1); +} + +#undef PyRun_InteractiveOne +PyAPI_FUNC(int) +PyRun_InteractiveOne(FILE *f, const char *p) +{ + return PyRun_InteractiveOneFlags(f, p, NULL); +} + +#undef PyRun_InteractiveLoop +PyAPI_FUNC(int) +PyRun_InteractiveLoop(FILE *f, const char *p) +{ + return PyRun_InteractiveLoopFlags(f, p, NULL); +} + #ifdef __cplusplus } #endif From 4989ebeb40e363140ec3cd19a1192fadd9e0bea8 Mon Sep 17 00:00:00 2001 From: Pablo Galindo Date: Wed, 2 Dec 2020 04:33:23 +0000 Subject: [PATCH 2/3] fixup! bpo-40939: Restore some stable API functions incorrectly deleted --- Python/pythonrun.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 9228caf5161133..8e738b7e9c39a5 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -1236,12 +1236,6 @@ Py_CompileStringExFlags(const char *str, const char *filename_str, int start, } /* For use in Py_LIMITED_API */ -#undef Py_CompileString -PyObject * -PyCompileString(const char *str, const char *filename, int start) -{ - return Py_CompileStringFlags(str, filename, start, NULL); -} const char * _Py_SourceAsString(PyObject *cmd, const char *funcname, const char *what, PyCompilerFlags *cf, PyObject **cmd_copy) From e27e2185287e6740c9a1c972075dee916345a452 Mon Sep 17 00:00:00 2001 From: Pablo Galindo Date: Wed, 2 Dec 2020 04:35:45 +0000 Subject: [PATCH 3/3] fixup! fixup! bpo-40939: Restore some stable API functions incorrectly deleted --- Python/pythonrun.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 8e738b7e9c39a5..6181a38defcc0d 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -1235,8 +1235,6 @@ Py_CompileStringExFlags(const char *str, const char *filename_str, int start, return co; } -/* For use in Py_LIMITED_API */ - const char * _Py_SourceAsString(PyObject *cmd, const char *funcname, const char *what, PyCompilerFlags *cf, PyObject **cmd_copy) {