Saved and restored logging._handlerList at the same time as saving/restoring logging...
[python.git] / Include / pythonrun.h
blob5c78cce60514ec970da439fff87ad938bb629360
2 /* Interfaces to parse and execute pieces of python code */
4 #ifndef Py_PYTHONRUN_H
5 #define Py_PYTHONRUN_H
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
10 #define PyCF_MASK (CO_FUTURE_DIVISION)
11 #define PyCF_MASK_OBSOLETE (CO_GENERATOR_ALLOWED | CO_NESTED)
12 #define PyCF_SOURCE_IS_UTF8 0x0100
13 #define PyCF_DONT_IMPLY_DEDENT 0x0200
15 typedef struct {
16 int cf_flags; /* bitmask of CO_xxx flags relevant to future */
17 } PyCompilerFlags;
19 PyAPI_FUNC(void) Py_SetProgramName(char *);
20 PyAPI_FUNC(char *) Py_GetProgramName(void);
22 PyAPI_FUNC(void) Py_SetPythonHome(char *);
23 PyAPI_FUNC(char *) Py_GetPythonHome(void);
25 PyAPI_FUNC(void) Py_Initialize(void);
26 PyAPI_FUNC(void) Py_InitializeEx(int);
27 PyAPI_FUNC(void) Py_Finalize(void);
28 PyAPI_FUNC(int) Py_IsInitialized(void);
29 PyAPI_FUNC(PyThreadState *) Py_NewInterpreter(void);
30 PyAPI_FUNC(void) Py_EndInterpreter(PyThreadState *);
32 PyAPI_FUNC(int) PyRun_AnyFileFlags(FILE *, char *, PyCompilerFlags *);
33 PyAPI_FUNC(int) PyRun_AnyFileExFlags(FILE *, char *, int, PyCompilerFlags *);
34 PyAPI_FUNC(int) PyRun_SimpleStringFlags(const char *, PyCompilerFlags *);
35 PyAPI_FUNC(int) PyRun_SimpleFileExFlags(FILE *, const char *, int, PyCompilerFlags *);
36 PyAPI_FUNC(int) PyRun_InteractiveOneFlags(FILE *, const char *, PyCompilerFlags *);
37 PyAPI_FUNC(int) PyRun_InteractiveLoopFlags(FILE *, const char *, PyCompilerFlags *);
39 PyAPI_FUNC(struct _mod *) PyParser_ASTFromString(const char *, const char *,
40 int, PyCompilerFlags *flags,
41 PyArena *);
42 PyAPI_FUNC(struct _mod *) PyParser_ASTFromFile(FILE *, const char *, int,
43 char *, char *,
44 PyCompilerFlags *, int *,
45 PyArena *);
46 #define PyParser_SimpleParseString(S, B) \
47 PyParser_SimpleParseStringFlags(S, B, 0)
48 #define PyParser_SimpleParseFile(FP, S, B) \
49 PyParser_SimpleParseFileFlags(FP, S, B, 0)
50 PyAPI_FUNC(struct _node *) PyParser_SimpleParseStringFlags(const char *, int,
51 int);
52 PyAPI_FUNC(struct _node *) PyParser_SimpleParseFileFlags(FILE *, const char *,
53 int, int);
55 PyAPI_FUNC(PyObject *) PyRun_StringFlags(const char *, int, PyObject *,
56 PyObject *, PyCompilerFlags *);
58 PyAPI_FUNC(PyObject *) PyRun_FileExFlags(FILE *, const char *, int,
59 PyObject *, PyObject *, int,
60 PyCompilerFlags *);
62 #define Py_CompileString(str, p, s) Py_CompileStringFlags(str, p, s, NULL)
63 PyAPI_FUNC(PyObject *) Py_CompileStringFlags(const char *, const char *, int,
64 PyCompilerFlags *);
65 PyAPI_FUNC(struct symtable *) Py_SymtableString(const char *, const char *, int);
67 PyAPI_FUNC(void) PyErr_Print(void);
68 PyAPI_FUNC(void) PyErr_PrintEx(int);
69 PyAPI_FUNC(void) PyErr_Display(PyObject *, PyObject *, PyObject *);
71 PyAPI_FUNC(int) Py_AtExit(void (*func)(void));
73 PyAPI_FUNC(void) Py_Exit(int);
75 PyAPI_FUNC(int) Py_FdIsInteractive(FILE *, const char *);
77 /* Bootstrap */
78 PyAPI_FUNC(int) Py_Main(int argc, char **argv);
80 /* Use macros for a bunch of old variants */
81 #define PyRun_String(str, s, g, l) PyRun_StringFlags(str, s, g, l, NULL)
82 #define PyRun_AnyFile(fp, name) PyRun_AnyFileExFlags(fp, name, 0, NULL)
83 #define PyRun_AnyFileEx(fp, name, closeit) \
84 PyRun_AnyFileExFlags(fp, name, closeit, NULL)
85 #define PyRun_AnyFileFlags(fp, name, flags) \
86 PyRun_AnyFileExFlags(fp, name, 0, flags)
87 #define PyRun_SimpleString(s) PyRun_SimpleStringFlags(s, NULL)
88 #define PyRun_SimpleFile(f, p) PyRun_SimpleFileExFlags(f, p, 0, NULL)
89 #define PyRun_SimpleFileEx(f, p, c) PyRun_SimpleFileExFlags(f, p, c, NULL)
90 #define PyRun_InteractiveOne(f, p) PyRun_InteractiveOneFlags(f, p, NULL)
91 #define PyRun_InteractiveLoop(f, p) PyRun_InteractiveLoopFlags(f, p, NULL)
92 #define PyRun_File(fp, p, s, g, l) \
93 PyRun_FileExFlags(fp, p, s, g, l, 0, NULL)
94 #define PyRun_FileEx(fp, p, s, g, l, c) \
95 PyRun_FileExFlags(fp, p, s, g, l, c, NULL)
96 #define PyRun_FileFlags(fp, p, s, g, l, flags) \
97 PyRun_FileExFlags(fp, p, s, g, l, 0, flags)
99 /* In getpath.c */
100 PyAPI_FUNC(char *) Py_GetProgramFullPath(void);
101 PyAPI_FUNC(char *) Py_GetPrefix(void);
102 PyAPI_FUNC(char *) Py_GetExecPrefix(void);
103 PyAPI_FUNC(char *) Py_GetPath(void);
105 /* In their own files */
106 PyAPI_FUNC(const char *) Py_GetVersion(void);
107 PyAPI_FUNC(const char *) Py_GetPlatform(void);
108 PyAPI_FUNC(const char *) Py_GetCopyright(void);
109 PyAPI_FUNC(const char *) Py_GetCompiler(void);
110 PyAPI_FUNC(const char *) Py_GetBuildInfo(void);
111 PyAPI_FUNC(const char *) _Py_svnversion(void);
112 PyAPI_FUNC(const char *) Py_SubversionRevision(void);
113 PyAPI_FUNC(const char *) Py_SubversionShortBranch(void);
115 /* Internal -- various one-time initializations */
116 PyAPI_FUNC(PyObject *) _PyBuiltin_Init(void);
117 PyAPI_FUNC(PyObject *) _PySys_Init(void);
118 PyAPI_FUNC(void) _PyImport_Init(void);
119 PyAPI_FUNC(void) _PyExc_Init(void);
120 PyAPI_FUNC(void) _PyImportHooks_Init(void);
121 PyAPI_FUNC(int) _PyFrame_Init(void);
122 PyAPI_FUNC(int) _PyInt_Init(void);
123 PyAPI_FUNC(void) _PyFloat_Init(void);
125 /* Various internal finalizers */
126 PyAPI_FUNC(void) _PyExc_Fini(void);
127 PyAPI_FUNC(void) _PyImport_Fini(void);
128 PyAPI_FUNC(void) PyMethod_Fini(void);
129 PyAPI_FUNC(void) PyFrame_Fini(void);
130 PyAPI_FUNC(void) PyCFunction_Fini(void);
131 PyAPI_FUNC(void) PyTuple_Fini(void);
132 PyAPI_FUNC(void) PyList_Fini(void);
133 PyAPI_FUNC(void) PySet_Fini(void);
134 PyAPI_FUNC(void) PyString_Fini(void);
135 PyAPI_FUNC(void) PyInt_Fini(void);
136 PyAPI_FUNC(void) PyFloat_Fini(void);
137 PyAPI_FUNC(void) PyOS_FiniInterrupts(void);
139 /* Stuff with no proper home (yet) */
140 PyAPI_FUNC(char *) PyOS_Readline(FILE *, FILE *, char *);
141 PyAPI_DATA(int) (*PyOS_InputHook)(void);
142 PyAPI_DATA(char) *(*PyOS_ReadlineFunctionPointer)(FILE *, FILE *, char *);
143 PyAPI_DATA(PyThreadState*) _PyOS_ReadlineTState;
145 /* Stack size, in "pointers" (so we get extra safety margins
146 on 64-bit platforms). On a 32-bit platform, this translates
147 to a 8k margin. */
148 #define PYOS_STACK_MARGIN 2048
150 #if defined(WIN32) && !defined(MS_WIN64) && defined(_MSC_VER)
151 /* Enable stack checking under Microsoft C */
152 #define USE_STACKCHECK
153 #endif
155 #ifdef USE_STACKCHECK
156 /* Check that we aren't overflowing our stack */
157 PyAPI_FUNC(int) PyOS_CheckStack(void);
158 #endif
160 /* Signals */
161 typedef void (*PyOS_sighandler_t)(int);
162 PyAPI_FUNC(PyOS_sighandler_t) PyOS_getsig(int);
163 PyAPI_FUNC(PyOS_sighandler_t) PyOS_setsig(int, PyOS_sighandler_t);
166 #ifdef __cplusplus
168 #endif
169 #endif /* !Py_PYTHONRUN_H */