Skip to content

Commit 46bd5ed

Browse files
authored
bpo-40939: Restore some stable API functions incorrectly deleted (GH-23606)
1 parent e483d28 commit 46bd5ed

File tree

1 file changed

+103
-8
lines changed

1 file changed

+103
-8
lines changed

Python/pythonrun.c

Lines changed: 103 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,14 +1235,6 @@ Py_CompileStringExFlags(const char *str, const char *filename_str, int start,
12351235
return co;
12361236
}
12371237

1238-
/* For use in Py_LIMITED_API */
1239-
#undef Py_CompileString
1240-
PyObject *
1241-
PyCompileString(const char *str, const char *filename, int start)
1242-
{
1243-
return Py_CompileStringFlags(str, filename, start, NULL);
1244-
}
1245-
12461238
const char *
12471239
_Py_SourceAsString(PyObject *cmd, const char *funcname, const char *what, PyCompilerFlags *cf, PyObject **cmd_copy)
12481240
{
@@ -1371,6 +1363,109 @@ PyOS_CheckStack(void)
13711363

13721364
#endif /* USE_STACKCHECK */
13731365

1366+
/* Deprecated C API functions still provided for binary compatibility */
1367+
1368+
#undef PyRun_AnyFile
1369+
PyAPI_FUNC(int)
1370+
PyRun_AnyFile(FILE *fp, const char *name)
1371+
{
1372+
return PyRun_AnyFileExFlags(fp, name, 0, NULL);
1373+
}
1374+
1375+
#undef PyRun_AnyFileEx
1376+
PyAPI_FUNC(int)
1377+
PyRun_AnyFileEx(FILE *fp, const char *name, int closeit)
1378+
{
1379+
return PyRun_AnyFileExFlags(fp, name, closeit, NULL);
1380+
}
1381+
1382+
#undef PyRun_AnyFileFlags
1383+
PyAPI_FUNC(int)
1384+
PyRun_AnyFileFlags(FILE *fp, const char *name, PyCompilerFlags *flags)
1385+
{
1386+
return PyRun_AnyFileExFlags(fp, name, 0, flags);
1387+
}
1388+
1389+
#undef PyRun_File
1390+
PyAPI_FUNC(PyObject *)
1391+
PyRun_File(FILE *fp, const char *p, int s, PyObject *g, PyObject *l)
1392+
{
1393+
return PyRun_FileExFlags(fp, p, s, g, l, 0, NULL);
1394+
}
1395+
1396+
#undef PyRun_FileEx
1397+
PyAPI_FUNC(PyObject *)
1398+
PyRun_FileEx(FILE *fp, const char *p, int s, PyObject *g, PyObject *l, int c)
1399+
{
1400+
return PyRun_FileExFlags(fp, p, s, g, l, c, NULL);
1401+
}
1402+
1403+
#undef PyRun_FileFlags
1404+
PyAPI_FUNC(PyObject *)
1405+
PyRun_FileFlags(FILE *fp, const char *p, int s, PyObject *g, PyObject *l,
1406+
PyCompilerFlags *flags)
1407+
{
1408+
return PyRun_FileExFlags(fp, p, s, g, l, 0, flags);
1409+
}
1410+
1411+
#undef PyRun_SimpleFile
1412+
PyAPI_FUNC(int)
1413+
PyRun_SimpleFile(FILE *f, const char *p)
1414+
{
1415+
return PyRun_SimpleFileExFlags(f, p, 0, NULL);
1416+
}
1417+
1418+
#undef PyRun_SimpleFileEx
1419+
PyAPI_FUNC(int)
1420+
PyRun_SimpleFileEx(FILE *f, const char *p, int c)
1421+
{
1422+
return PyRun_SimpleFileExFlags(f, p, c, NULL);
1423+
}
1424+
1425+
1426+
#undef PyRun_String
1427+
PyAPI_FUNC(PyObject *)
1428+
PyRun_String(const char *str, int s, PyObject *g, PyObject *l)
1429+
{
1430+
return PyRun_StringFlags(str, s, g, l, NULL);
1431+
}
1432+
1433+
#undef PyRun_SimpleString
1434+
PyAPI_FUNC(int)
1435+
PyRun_SimpleString(const char *s)
1436+
{
1437+
return PyRun_SimpleStringFlags(s, NULL);
1438+
}
1439+
1440+
#undef Py_CompileString
1441+
PyAPI_FUNC(PyObject *)
1442+
Py_CompileString(const char *str, const char *p, int s)
1443+
{
1444+
return Py_CompileStringExFlags(str, p, s, NULL, -1);
1445+
}
1446+
1447+
#undef Py_CompileStringFlags
1448+
PyAPI_FUNC(PyObject *)
1449+
Py_CompileStringFlags(const char *str, const char *p, int s,
1450+
PyCompilerFlags *flags)
1451+
{
1452+
return Py_CompileStringExFlags(str, p, s, flags, -1);
1453+
}
1454+
1455+
#undef PyRun_InteractiveOne
1456+
PyAPI_FUNC(int)
1457+
PyRun_InteractiveOne(FILE *f, const char *p)
1458+
{
1459+
return PyRun_InteractiveOneFlags(f, p, NULL);
1460+
}
1461+
1462+
#undef PyRun_InteractiveLoop
1463+
PyAPI_FUNC(int)
1464+
PyRun_InteractiveLoop(FILE *f, const char *p)
1465+
{
1466+
return PyRun_InteractiveLoopFlags(f, p, NULL);
1467+
}
1468+
13741469
#ifdef __cplusplus
13751470
}
13761471
#endif

0 commit comments

Comments
 (0)