diff options
author | Guido van Rossum <guido@python.org> | 1998-02-06 22:27:24 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1998-02-06 22:27:24 (GMT) |
commit | a61691e4e9e43da90fa2a5fa1c6764fe49e4dcdb (patch) | |
tree | e7e8c840a6a41755511628355a1ddfc52c6fbdab /Python/pythonrun.c | |
parent | 31c4ed75fc840122f06cb9976725941a4b1151cc (diff) | |
download | cpython-a61691e4e9e43da90fa2a5fa1c6764fe49e4dcdb.zip cpython-a61691e4e9e43da90fa2a5fa1c6764fe49e4dcdb.tar.gz cpython-a61691e4e9e43da90fa2a5fa1c6764fe49e4dcdb.tar.bz2 |
Ehm, three unrelated changes.
- Add Py_FrozenFlag, intended to suppress error messages fron
getpath.c in frozen binaries.
- Add Py_GetPythonHome() and Py_SetPythonHome(), intended to allow
embedders to force a different PYTHONHOME.
- Add new interface PyErr_PrintEx(flag); same as PyErr_Print() but
flag determines whether sys.last_* are set or not. PyErr_Print()
now simply calls PyErr_PrintEx(1).
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r-- | Python/pythonrun.c | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 1007860..4cd0e3f 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -77,6 +77,7 @@ int Py_VerboseFlag; /* Needed by import.c */ int Py_InteractiveFlag; /* Needed by Py_FdIsInteractive() below */ int Py_NoSiteFlag; /* Suppress 'import site' */ int Py_UseClassExceptionsFlag = 1; /* Needed by bltinmodule.c */ +int Py_FrozenFlag; /* Needed by getpath.c */ static int initialized = 0; @@ -367,6 +368,24 @@ Py_GetProgramName() return progname; } +static char *default_home = NULL; + +void +Py_SetPythonHome(home) + char *home; +{ + default_home = home; +} + +char * +Py_GetPythonHome() +{ + char *home = default_home; + if (home == NULL) + home = getenv("PYTHONHOME"); + return home; +} + /* Create __main__ module */ static void @@ -641,6 +660,13 @@ finally: void PyErr_Print() { + PyErr_PrintEx(1); +} + +void +PyErr_PrintEx(set_sys_last_vars) + int set_sys_last_vars; +{ int err = 0; PyObject *exception, *v, *tb, *f; PyErr_Fetch(&exception, &v, &tb); @@ -679,9 +705,11 @@ PyErr_Print() Py_Exit(1); } } - PySys_SetObject("last_type", exception); - PySys_SetObject("last_value", v); - PySys_SetObject("last_traceback", tb); + if (set_sys_last_vars) { + PySys_SetObject("last_type", exception); + PySys_SetObject("last_value", v); + PySys_SetObject("last_traceback", tb); + } f = PySys_GetObject("stderr"); if (f == NULL) fprintf(stderr, "lost sys.stderr\n"); |