#include <stdbool.h>
#include "Python.h"
#include "pycore_ast.h"
#include "pycore_audit.h"
#include "pycore_ceval.h"
#include "pycore_compile.h"
#include "pycore_interp.h"
#include "pycore_object.h"
#include "pycore_parser.h"
#include "pycore_pyerrors.h"
#include "pycore_pylifecycle.h"
#include "pycore_pystate.h"
#include "pycore_pythonrun.h"
#include "pycore_sysmodule.h"
#include "pycore_traceback.h"
#include "errcode.h"
#include "marshal.h"
#ifdef MS_WINDOWS
# include "malloc.h"
#endif
#ifdef MS_WINDOWS
# undef BYTE
# include "windows.h"
#endif
static void flush_io(void);
static PyObject *run_mod(mod_ty, PyObject *, PyObject *, PyObject *,
PyCompilerFlags *, PyArena *, PyObject*, int);
static PyObject *run_pyc_file(FILE *, PyObject *, PyObject *,
PyCompilerFlags *);
static int PyRun_InteractiveOneObjectEx(FILE *, PyObject *, PyCompilerFlags *);
static PyObject* pyrun_file(FILE *fp, PyObject *filename, int start,
PyObject *globals, PyObject *locals, int closeit,
PyCompilerFlags *flags);
static PyObject *
_PyRun_StringFlagsWithName(const char *str, PyObject* name, int start,
PyObject *globals, PyObject *locals, PyCompilerFlags *flags,
int generate_new_source);
int
_PyRun_AnyFileObject(FILE *fp, PyObject *filename, int closeit,
PyCompilerFlags *flags)
{ … }
int
PyRun_AnyFileExFlags(FILE *fp, const char *filename, int closeit,
PyCompilerFlags *flags)
{ … }
int
_PyRun_InteractiveLoopObject(FILE *fp, PyObject *filename, PyCompilerFlags *flags)
{ … }
int
PyRun_InteractiveLoopFlags(FILE *fp, const char *filename, PyCompilerFlags *flags)
{ … }
static int
pyrun_one_parse_ast(FILE *fp, PyObject *filename,
PyCompilerFlags *flags, PyArena *arena,
mod_ty *pmod, PyObject** interactive_src)
{ … }
static int
PyRun_InteractiveOneObjectEx(FILE *fp, PyObject *filename,
PyCompilerFlags *flags)
{ … }
int
PyRun_InteractiveOneObject(FILE *fp, PyObject *filename, PyCompilerFlags *flags)
{ … }
int
PyRun_InteractiveOneFlags(FILE *fp, const char *filename_str, PyCompilerFlags *flags)
{ … }
static int
maybe_pyc_file(FILE *fp, PyObject *filename, int closeit)
{ … }
static int
set_main_loader(PyObject *d, PyObject *filename, const char *loader_name)
{ … }
int
_PyRun_SimpleFileObject(FILE *fp, PyObject *filename, int closeit,
PyCompilerFlags *flags)
{ … }
int
PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit,
PyCompilerFlags *flags)
{ … }
int
_PyRun_SimpleStringFlagsWithName(const char *command, const char* name, PyCompilerFlags *flags) { … }
int
PyRun_SimpleStringFlags(const char *command, PyCompilerFlags *flags)
{ … }
static int
parse_exit_code(PyObject *code, int *exitcode_p)
{ … }
int
_Py_HandleSystemExit(int *exitcode_p)
{ … }
static void
handle_system_exit(void)
{ … }
static void
_PyErr_PrintEx(PyThreadState *tstate, int set_sys_last_vars)
{ … }
void
_PyErr_Print(PyThreadState *tstate)
{ … }
void
PyErr_PrintEx(int set_sys_last_vars)
{ … }
void
PyErr_Print(void)
{ … }
struct exception_print_context
{ … };
static int
print_exception_invalid_type(struct exception_print_context *ctx,
PyObject *value)
{ … }
static int
print_exception_traceback(struct exception_print_context *ctx, PyObject *value)
{ … }
static int
print_exception_file_and_line(struct exception_print_context *ctx,
PyObject **value_p)
{ … }
static int
print_exception_message(struct exception_print_context *ctx, PyObject *type,
PyObject *value)
{ … }
static int
print_exception(struct exception_print_context *ctx, PyObject *value)
{ … }
static const char cause_message[] = …;
static const char context_message[] = …;
static int
print_exception_recursive(struct exception_print_context*, PyObject*);
static int
print_chained(struct exception_print_context* ctx, PyObject *value,
const char * message, const char *tag)
{ … }
static bool
print_exception_seen_lookup(struct exception_print_context *ctx,
PyObject *value)
{ … }
static int
print_exception_cause_and_context(struct exception_print_context *ctx,
PyObject *value)
{ … }
static int
print_exception_recursive(struct exception_print_context *ctx, PyObject *value)
{ … }
void
_PyErr_Display(PyObject *file, PyObject *unused, PyObject *value, PyObject *tb)
{ … }
void
PyErr_Display(PyObject *unused, PyObject *value, PyObject *tb)
{ … }
void _PyErr_DisplayException(PyObject *file, PyObject *exc)
{ … }
void PyErr_DisplayException(PyObject *exc)
{ … }
static PyObject *
_PyRun_StringFlagsWithName(const char *str, PyObject* name, int start,
PyObject *globals, PyObject *locals, PyCompilerFlags *flags,
int generate_new_source)
{ … }
PyObject *
PyRun_StringFlags(const char *str, int start, PyObject *globals,
PyObject *locals, PyCompilerFlags *flags) { … }
static PyObject *
pyrun_file(FILE *fp, PyObject *filename, int start, PyObject *globals,
PyObject *locals, int closeit, PyCompilerFlags *flags)
{ … }
PyObject *
PyRun_FileExFlags(FILE *fp, const char *filename, int start, PyObject *globals,
PyObject *locals, int closeit, PyCompilerFlags *flags)
{ … }
static void
flush_io_stream(PyThreadState *tstate, PyObject *name)
{ … }
static void
flush_io(void)
{ … }
static PyObject *
run_eval_code_obj(PyThreadState *tstate, PyCodeObject *co, PyObject *globals, PyObject *locals)
{ … }
static PyObject *
run_mod(mod_ty mod, PyObject *filename, PyObject *globals, PyObject *locals,
PyCompilerFlags *flags, PyArena *arena, PyObject* interactive_src,
int generate_new_source)
{ … }
static PyObject *
run_pyc_file(FILE *fp, PyObject *globals, PyObject *locals,
PyCompilerFlags *flags)
{ … }
PyObject *
Py_CompileStringObject(const char *str, PyObject *filename, int start,
PyCompilerFlags *flags, int optimize)
{ … }
PyObject *
Py_CompileStringExFlags(const char *str, const char *filename_str, int start,
PyCompilerFlags *flags, int optimize)
{ … }
const char *
_Py_SourceAsString(PyObject *cmd, const char *funcname, const char *what, PyCompilerFlags *cf, PyObject **cmd_copy)
{ … }
#if defined(USE_STACKCHECK)
#if defined(WIN32) && defined(_MSC_VER)
#include <malloc.h>
#include <excpt.h>
int
PyOS_CheckStack(void)
{
__try {
alloca(PYOS_STACK_MARGIN * sizeof(void*));
return 0;
} __except (GetExceptionCode() == STATUS_STACK_OVERFLOW ?
EXCEPTION_EXECUTE_HANDLER :
EXCEPTION_CONTINUE_SEARCH) {
int errcode = _resetstkoflw();
if (errcode == 0)
{
Py_FatalError("Could not reset the stack!");
}
}
return 1;
}
#endif
#endif
#undef PyRun_AnyFile
PyAPI_FUNC(int)
PyRun_AnyFile(FILE *fp, const char *name)
{ … }
#undef PyRun_AnyFileEx
PyAPI_FUNC(int)
PyRun_AnyFileEx(FILE *fp, const char *name, int closeit)
{ … }
#undef PyRun_AnyFileFlags
PyAPI_FUNC(int)
PyRun_AnyFileFlags(FILE *fp, const char *name, PyCompilerFlags *flags)
{ … }
#undef PyRun_File
PyAPI_FUNC(PyObject *)
PyRun_File(FILE *fp, const char *p, int s, PyObject *g, PyObject *l)
{ … }
#undef PyRun_FileEx
PyAPI_FUNC(PyObject *)
PyRun_FileEx(FILE *fp, const char *p, int s, PyObject *g, PyObject *l, int c)
{ … }
#undef PyRun_FileFlags
PyAPI_FUNC(PyObject *)
PyRun_FileFlags(FILE *fp, const char *p, int s, PyObject *g, PyObject *l,
PyCompilerFlags *flags)
{ … }
#undef PyRun_SimpleFile
PyAPI_FUNC(int)
PyRun_SimpleFile(FILE *f, const char *p)
{ … }
#undef PyRun_SimpleFileEx
PyAPI_FUNC(int)
PyRun_SimpleFileEx(FILE *f, const char *p, int c)
{ … }
#undef PyRun_String
PyAPI_FUNC(PyObject *)
PyRun_String(const char *str, int s, PyObject *g, PyObject *l)
{ … }
#undef PyRun_SimpleString
PyAPI_FUNC(int)
PyRun_SimpleString(const char *s)
{ … }
#undef Py_CompileString
PyAPI_FUNC(PyObject *)
Py_CompileString(const char *str, const char *p, int s)
{ … }
#undef Py_CompileStringFlags
PyAPI_FUNC(PyObject *)
Py_CompileStringFlags(const char *str, const char *p, int s,
PyCompilerFlags *flags)
{ … }
#undef PyRun_InteractiveOne
PyAPI_FUNC(int)
PyRun_InteractiveOne(FILE *f, const char *p)
{ … }
#undef PyRun_InteractiveLoop
PyAPI_FUNC(int)
PyRun_InteractiveLoop(FILE *f, const char *p)
{ … }