Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fe6e5e7

Browse filesBrowse files
authored
bpo-35134: Add Include/cpython/pythonrun.h file (GH-23701)
Py_CompileString() is now always declared as a function by Include/pythonrun.h. It is overriden with a macro in Include/cpython/pythonrun.h.
1 parent 815506d commit fe6e5e7
Copy full SHA for fe6e5e7

File tree

Expand file treeCollapse file tree

5 files changed

+129
-117
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+129
-117
lines changed

‎Include/cpython/pythonrun.h

Copy file name to clipboard
+117Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
#ifndef Py_CPYTHON_PYTHONRUN_H
2+
# error "this header file must not be included directly"
3+
#endif
4+
5+
PyAPI_FUNC(int) PyRun_SimpleStringFlags(const char *, PyCompilerFlags *);
6+
PyAPI_FUNC(int) PyRun_AnyFileExFlags(
7+
FILE *fp,
8+
const char *filename, /* decoded from the filesystem encoding */
9+
int closeit,
10+
PyCompilerFlags *flags);
11+
PyAPI_FUNC(int) PyRun_SimpleFileExFlags(
12+
FILE *fp,
13+
const char *filename, /* decoded from the filesystem encoding */
14+
int closeit,
15+
PyCompilerFlags *flags);
16+
PyAPI_FUNC(int) PyRun_InteractiveOneFlags(
17+
FILE *fp,
18+
const char *filename, /* decoded from the filesystem encoding */
19+
PyCompilerFlags *flags);
20+
PyAPI_FUNC(int) PyRun_InteractiveOneObject(
21+
FILE *fp,
22+
PyObject *filename,
23+
PyCompilerFlags *flags);
24+
PyAPI_FUNC(int) PyRun_InteractiveLoopFlags(
25+
FILE *fp,
26+
const char *filename, /* decoded from the filesystem encoding */
27+
PyCompilerFlags *flags);
28+
29+
30+
PyAPI_FUNC(PyObject *) PyRun_StringFlags(const char *, int, PyObject *,
31+
PyObject *, PyCompilerFlags *);
32+
33+
PyAPI_FUNC(PyObject *) PyRun_FileExFlags(
34+
FILE *fp,
35+
const char *filename, /* decoded from the filesystem encoding */
36+
int start,
37+
PyObject *globals,
38+
PyObject *locals,
39+
int closeit,
40+
PyCompilerFlags *flags);
41+
42+
43+
PyAPI_FUNC(PyObject *) Py_CompileStringExFlags(
44+
const char *str,
45+
const char *filename, /* decoded from the filesystem encoding */
46+
int start,
47+
PyCompilerFlags *flags,
48+
int optimize);
49+
PyAPI_FUNC(PyObject *) Py_CompileStringObject(
50+
const char *str,
51+
PyObject *filename, int start,
52+
PyCompilerFlags *flags,
53+
int optimize);
54+
55+
#define Py_CompileString(str, p, s) Py_CompileStringExFlags(str, p, s, NULL, -1)
56+
#define Py_CompileStringFlags(str, p, s, f) Py_CompileStringExFlags(str, p, s, f, -1)
57+
58+
59+
PyAPI_FUNC(const char *) _Py_SourceAsString(
60+
PyObject *cmd,
61+
const char *funcname,
62+
const char *what,
63+
PyCompilerFlags *cf,
64+
PyObject **cmd_copy);
65+
66+
PyAPI_FUNC(struct symtable *) Py_SymtableStringObject(
67+
const char *str,
68+
PyObject *filename,
69+
int start);
70+
71+
PyAPI_FUNC(struct symtable *) _Py_SymtableStringObjectFlags(
72+
const char *str,
73+
PyObject *filename,
74+
int start,
75+
PyCompilerFlags *flags);
76+
77+
78+
/* A function flavor is also exported by libpython. It is required when
79+
libpython is accessed directly rather than using header files which defines
80+
macros below. On Windows, for example, PyAPI_FUNC() uses dllexport to
81+
export functions in pythonXX.dll. */
82+
PyAPI_FUNC(PyObject *) PyRun_String(const char *str, int s, PyObject *g, PyObject *l);
83+
PyAPI_FUNC(int) PyRun_AnyFile(FILE *fp, const char *name);
84+
PyAPI_FUNC(int) PyRun_AnyFileEx(FILE *fp, const char *name, int closeit);
85+
PyAPI_FUNC(int) PyRun_AnyFileFlags(FILE *, const char *, PyCompilerFlags *);
86+
PyAPI_FUNC(int) PyRun_SimpleString(const char *s);
87+
PyAPI_FUNC(int) PyRun_SimpleFile(FILE *f, const char *p);
88+
PyAPI_FUNC(int) PyRun_SimpleFileEx(FILE *f, const char *p, int c);
89+
PyAPI_FUNC(int) PyRun_InteractiveOne(FILE *f, const char *p);
90+
PyAPI_FUNC(int) PyRun_InteractiveLoop(FILE *f, const char *p);
91+
PyAPI_FUNC(PyObject *) PyRun_File(FILE *fp, const char *p, int s, PyObject *g, PyObject *l);
92+
PyAPI_FUNC(PyObject *) PyRun_FileEx(FILE *fp, const char *p, int s, PyObject *g, PyObject *l, int c);
93+
PyAPI_FUNC(PyObject *) PyRun_FileFlags(FILE *fp, const char *p, int s, PyObject *g, PyObject *l, PyCompilerFlags *flags);
94+
95+
/* Use macros for a bunch of old variants */
96+
#define PyRun_String(str, s, g, l) PyRun_StringFlags(str, s, g, l, NULL)
97+
#define PyRun_AnyFile(fp, name) PyRun_AnyFileExFlags(fp, name, 0, NULL)
98+
#define PyRun_AnyFileEx(fp, name, closeit) \
99+
PyRun_AnyFileExFlags(fp, name, closeit, NULL)
100+
#define PyRun_AnyFileFlags(fp, name, flags) \
101+
PyRun_AnyFileExFlags(fp, name, 0, flags)
102+
#define PyRun_SimpleString(s) PyRun_SimpleStringFlags(s, NULL)
103+
#define PyRun_SimpleFile(f, p) PyRun_SimpleFileExFlags(f, p, 0, NULL)
104+
#define PyRun_SimpleFileEx(f, p, c) PyRun_SimpleFileExFlags(f, p, c, NULL)
105+
#define PyRun_InteractiveOne(f, p) PyRun_InteractiveOneFlags(f, p, NULL)
106+
#define PyRun_InteractiveLoop(f, p) PyRun_InteractiveLoopFlags(f, p, NULL)
107+
#define PyRun_File(fp, p, s, g, l) \
108+
PyRun_FileExFlags(fp, p, s, g, l, 0, NULL)
109+
#define PyRun_FileEx(fp, p, s, g, l, c) \
110+
PyRun_FileExFlags(fp, p, s, g, l, c, NULL)
111+
#define PyRun_FileFlags(fp, p, s, g, l, flags) \
112+
PyRun_FileExFlags(fp, p, s, g, l, 0, flags)
113+
114+
115+
/* Stuff with no proper home (yet) */
116+
PyAPI_FUNC(char *) PyOS_Readline(FILE *, FILE *, const char *);
117+
PyAPI_DATA(PyThreadState*) _PyOS_ReadlineTState;

‎Include/pythonrun.h

Copy file name to clipboardExpand all lines: Include/pythonrun.h
+7-117Lines changed: 7 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -7,137 +7,21 @@
77
extern "C" {
88
#endif
99

10-
#ifndef Py_LIMITED_API
11-
PyAPI_FUNC(int) PyRun_SimpleStringFlags(const char *, PyCompilerFlags *);
12-
PyAPI_FUNC(int) PyRun_AnyFileExFlags(
13-
FILE *fp,
14-
const char *filename, /* decoded from the filesystem encoding */
15-
int closeit,
16-
PyCompilerFlags *flags);
17-
PyAPI_FUNC(int) PyRun_SimpleFileExFlags(
18-
FILE *fp,
19-
const char *filename, /* decoded from the filesystem encoding */
20-
int closeit,
21-
PyCompilerFlags *flags);
22-
PyAPI_FUNC(int) PyRun_InteractiveOneFlags(
23-
FILE *fp,
24-
const char *filename, /* decoded from the filesystem encoding */
25-
PyCompilerFlags *flags);
26-
PyAPI_FUNC(int) PyRun_InteractiveOneObject(
27-
FILE *fp,
28-
PyObject *filename,
29-
PyCompilerFlags *flags);
30-
PyAPI_FUNC(int) PyRun_InteractiveLoopFlags(
31-
FILE *fp,
32-
const char *filename, /* decoded from the filesystem encoding */
33-
PyCompilerFlags *flags);
34-
35-
36-
PyAPI_FUNC(PyObject *) PyRun_StringFlags(const char *, int, PyObject *,
37-
PyObject *, PyCompilerFlags *);
38-
39-
PyAPI_FUNC(PyObject *) PyRun_FileExFlags(
40-
FILE *fp,
41-
const char *filename, /* decoded from the filesystem encoding */
42-
int start,
43-
PyObject *globals,
44-
PyObject *locals,
45-
int closeit,
46-
PyCompilerFlags *flags);
47-
#endif
48-
49-
#ifdef Py_LIMITED_API
5010
PyAPI_FUNC(PyObject *) Py_CompileString(const char *, const char *, int);
51-
#else
52-
#define Py_CompileString(str, p, s) Py_CompileStringExFlags(str, p, s, NULL, -1)
53-
#define Py_CompileStringFlags(str, p, s, f) Py_CompileStringExFlags(str, p, s, f, -1)
54-
PyAPI_FUNC(PyObject *) Py_CompileStringExFlags(
55-
const char *str,
56-
const char *filename, /* decoded from the filesystem encoding */
57-
int start,
58-
PyCompilerFlags *flags,
59-
int optimize);
60-
PyAPI_FUNC(PyObject *) Py_CompileStringObject(
61-
const char *str,
62-
PyObject *filename, int start,
63-
PyCompilerFlags *flags,
64-
int optimize);
65-
#endif
11+
6612
PyAPI_FUNC(struct symtable *) Py_SymtableString(
6713
const char *str,
6814
const char *filename, /* decoded from the filesystem encoding */
6915
int start);
70-
#ifndef Py_LIMITED_API
71-
PyAPI_FUNC(const char *) _Py_SourceAsString(
72-
PyObject *cmd,
73-
const char *funcname,
74-
const char *what,
75-
PyCompilerFlags *cf,
76-
PyObject **cmd_copy);
77-
78-
PyAPI_FUNC(struct symtable *) Py_SymtableStringObject(
79-
const char *str,
80-
PyObject *filename,
81-
int start);
82-
83-
PyAPI_FUNC(struct symtable *) _Py_SymtableStringObjectFlags(
84-
const char *str,
85-
PyObject *filename,
86-
int start,
87-
PyCompilerFlags *flags);
88-
#endif
8916

9017
PyAPI_FUNC(void) PyErr_Print(void);
9118
PyAPI_FUNC(void) PyErr_PrintEx(int);
9219
PyAPI_FUNC(void) PyErr_Display(PyObject *, PyObject *, PyObject *);
9320

94-
#ifndef Py_LIMITED_API
95-
/* A function flavor is also exported by libpython. It is required when
96-
libpython is accessed directly rather than using header files which defines
97-
macros below. On Windows, for example, PyAPI_FUNC() uses dllexport to
98-
export functions in pythonXX.dll. */
99-
PyAPI_FUNC(PyObject *) PyRun_String(const char *str, int s, PyObject *g, PyObject *l);
100-
PyAPI_FUNC(int) PyRun_AnyFile(FILE *fp, const char *name);
101-
PyAPI_FUNC(int) PyRun_AnyFileEx(FILE *fp, const char *name, int closeit);
102-
PyAPI_FUNC(int) PyRun_AnyFileFlags(FILE *, const char *, PyCompilerFlags *);
103-
PyAPI_FUNC(int) PyRun_SimpleString(const char *s);
104-
PyAPI_FUNC(int) PyRun_SimpleFile(FILE *f, const char *p);
105-
PyAPI_FUNC(int) PyRun_SimpleFileEx(FILE *f, const char *p, int c);
106-
PyAPI_FUNC(int) PyRun_InteractiveOne(FILE *f, const char *p);
107-
PyAPI_FUNC(int) PyRun_InteractiveLoop(FILE *f, const char *p);
108-
PyAPI_FUNC(PyObject *) PyRun_File(FILE *fp, const char *p, int s, PyObject *g, PyObject *l);
109-
PyAPI_FUNC(PyObject *) PyRun_FileEx(FILE *fp, const char *p, int s, PyObject *g, PyObject *l, int c);
110-
PyAPI_FUNC(PyObject *) PyRun_FileFlags(FILE *fp, const char *p, int s, PyObject *g, PyObject *l, PyCompilerFlags *flags);
111-
112-
/* Use macros for a bunch of old variants */
113-
#define PyRun_String(str, s, g, l) PyRun_StringFlags(str, s, g, l, NULL)
114-
#define PyRun_AnyFile(fp, name) PyRun_AnyFileExFlags(fp, name, 0, NULL)
115-
#define PyRun_AnyFileEx(fp, name, closeit) \
116-
PyRun_AnyFileExFlags(fp, name, closeit, NULL)
117-
#define PyRun_AnyFileFlags(fp, name, flags) \
118-
PyRun_AnyFileExFlags(fp, name, 0, flags)
119-
#define PyRun_SimpleString(s) PyRun_SimpleStringFlags(s, NULL)
120-
#define PyRun_SimpleFile(f, p) PyRun_SimpleFileExFlags(f, p, 0, NULL)
121-
#define PyRun_SimpleFileEx(f, p, c) PyRun_SimpleFileExFlags(f, p, c, NULL)
122-
#define PyRun_InteractiveOne(f, p) PyRun_InteractiveOneFlags(f, p, NULL)
123-
#define PyRun_InteractiveLoop(f, p) PyRun_InteractiveLoopFlags(f, p, NULL)
124-
#define PyRun_File(fp, p, s, g, l) \
125-
PyRun_FileExFlags(fp, p, s, g, l, 0, NULL)
126-
#define PyRun_FileEx(fp, p, s, g, l, c) \
127-
PyRun_FileExFlags(fp, p, s, g, l, c, NULL)
128-
#define PyRun_FileFlags(fp, p, s, g, l, flags) \
129-
PyRun_FileExFlags(fp, p, s, g, l, 0, flags)
130-
#endif
13121

13222
/* Stuff with no proper home (yet) */
133-
#ifndef Py_LIMITED_API
134-
PyAPI_FUNC(char *) PyOS_Readline(FILE *, FILE *, const char *);
135-
#endif
13623
PyAPI_DATA(int) (*PyOS_InputHook)(void);
13724
PyAPI_DATA(char) *(*PyOS_ReadlineFunctionPointer)(FILE *, FILE *, const char *);
138-
#ifndef Py_LIMITED_API
139-
PyAPI_DATA(PyThreadState*) _PyOS_ReadlineTState;
140-
#endif
14125

14226
/* Stack size, in "pointers" (so we get extra safety margins
14327
on 64-bit platforms). On a 32-bit platform, this translates
@@ -154,6 +38,12 @@ PyAPI_DATA(PyThreadState*) _PyOS_ReadlineTState;
15438
PyAPI_FUNC(int) PyOS_CheckStack(void);
15539
#endif
15640

41+
#ifndef Py_LIMITED_API
42+
# define Py_CPYTHON_PYTHONRUN_H
43+
# include "cpython/pythonrun.h"
44+
# undef Py_CPYTHON_PYTHONRUN_H
45+
#endif
46+
15747
#ifdef __cplusplus
15848
}
15949
#endif

‎Makefile.pre.in

Copy file name to clipboardExpand all lines: Makefile.pre.in
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,6 +1102,7 @@ PYTHON_HEADERS= \
11021102
$(srcdir)/Include/cpython/pylifecycle.h \
11031103
$(srcdir)/Include/cpython/pymem.h \
11041104
$(srcdir)/Include/cpython/pystate.h \
1105+
$(srcdir)/Include/cpython/pythonrun.h \
11051106
$(srcdir)/Include/cpython/sysmodule.h \
11061107
$(srcdir)/Include/cpython/traceback.h \
11071108
$(srcdir)/Include/cpython/tupleobject.h \

‎PCbuild/pythoncore.vcxproj

Copy file name to clipboardExpand all lines: PCbuild/pythoncore.vcxproj
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@
146146
<ClInclude Include="..\Include\cpython\pylifecycle.h" />
147147
<ClInclude Include="..\Include\cpython\pymem.h" />
148148
<ClInclude Include="..\Include\cpython\pystate.h" />
149+
<ClInclude Include="..\Include\cpython\pythonrun.h" />
149150
<ClInclude Include="..\Include\cpython\sysmodule.h" />
150151
<ClInclude Include="..\Include\cpython\traceback.h" />
151152
<ClInclude Include="..\Include\cpython\tupleobject.h" />

‎PCbuild/pythoncore.vcxproj.filters

Copy file name to clipboardExpand all lines: PCbuild/pythoncore.vcxproj.filters
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,9 @@
459459
<ClInclude Include="..\Include\cpython\interpreteridobject.h">
460460
<Filter>Include\cpython</Filter>
461461
</ClInclude>
462+
<ClInclude Include="..\Include\cpython\pythonrun.h">
463+
<Filter>Include\cpython</Filter>
464+
</ClInclude>
462465
<ClInclude Include="..\Include\cpython\sysmodule.h">
463466
<Filter>Include\cpython</Filter>
464467
</ClInclude>

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.