| OLD | NEW |
| 1 | 1 |
| 2 /* Python interpreter top-level routines, including init/exit */ | 2 /* Python interpreter top-level routines, including init/exit */ |
| 3 | 3 |
| 4 #include "Python.h" | 4 #include "Python.h" |
| 5 | 5 |
| 6 #include "Python-ast.h" | 6 #include "Python-ast.h" |
| 7 #undef Yield /* undefine macro conflicting with winbase.h */ | 7 #undef Yield /* undefine macro conflicting with winbase.h */ |
| 8 #include "grammar.h" | 8 #include "grammar.h" |
| 9 #include "node.h" | 9 #include "node.h" |
| 10 #include "token.h" | 10 #include "token.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 static void initsigs(void); | 66 static void initsigs(void); |
| 67 static void call_py_exitfuncs(void); | 67 static void call_py_exitfuncs(void); |
| 68 static void wait_for_thread_shutdown(void); | 68 static void wait_for_thread_shutdown(void); |
| 69 static void call_ll_exitfuncs(void); | 69 static void call_ll_exitfuncs(void); |
| 70 extern int _PyUnicode_Init(void); | 70 extern int _PyUnicode_Init(void); |
| 71 extern void _PyUnicode_Fini(void); | 71 extern void _PyUnicode_Fini(void); |
| 72 extern int _PyLong_Init(void); | 72 extern int _PyLong_Init(void); |
| 73 extern void PyLong_Fini(void); | 73 extern void PyLong_Fini(void); |
| 74 extern int _PyFaulthandler_Init(void); | 74 extern int _PyFaulthandler_Init(void); |
| 75 extern void _PyFaulthandler_Fini(void); | 75 extern void _PyFaulthandler_Fini(void); |
| 76 extern void _Py_InitRndHashSeed(void); |
| 76 | 77 |
| 77 #ifdef WITH_THREAD | 78 #ifdef WITH_THREAD |
| 78 extern void _PyGILState_Init(PyInterpreterState *, PyThreadState *); | 79 extern void _PyGILState_Init(PyInterpreterState *, PyThreadState *); |
| 79 extern void _PyGILState_Fini(void); | 80 extern void _PyGILState_Fini(void); |
| 80 #endif /* WITH_THREAD */ | 81 #endif /* WITH_THREAD */ |
| 81 | 82 |
| 82 int Py_DebugFlag; /* Needed by parser.c */ | 83 int Py_DebugFlag; /* Needed by parser.c */ |
| 83 int Py_VerboseFlag; /* Needed by import.c */ | 84 int Py_VerboseFlag; /* Needed by import.c */ |
| 84 int Py_QuietFlag; /* Needed by sysmodule.c */ | 85 int Py_QuietFlag; /* Needed by sysmodule.c */ |
| 85 int Py_InteractiveFlag; /* Needed by Py_FdIsInteractive() below */ | 86 int Py_InteractiveFlag; /* Needed by Py_FdIsInteractive() below */ |
| 86 int Py_InspectFlag; /* Needed to determine whether to exit at SystemExit */ | 87 int Py_InspectFlag; /* Needed to determine whether to exit at SystemExit */ |
| 87 int Py_NoSiteFlag; /* Suppress 'import site' */ | 88 int Py_NoSiteFlag; /* Suppress 'import site' */ |
| 88 int Py_BytesWarningFlag; /* Warn on str(bytes) and str(buffer) */ | 89 int Py_BytesWarningFlag; /* Warn on str(bytes) and str(buffer) */ |
| 89 int Py_DontWriteBytecodeFlag; /* Suppress writing bytecode files (*.py[co]) */ | 90 int Py_DontWriteBytecodeFlag; /* Suppress writing bytecode files (*.py[co]) */ |
| 90 int Py_UseClassExceptionsFlag = 1; /* Needed by bltinmodule.c: deprecated */ | 91 int Py_UseClassExceptionsFlag = 1; /* Needed by bltinmodule.c: deprecated */ |
| 91 int Py_FrozenFlag; /* Needed by getpath.c */ | 92 int Py_FrozenFlag; /* Needed by getpath.c */ |
| 92 int Py_IgnoreEnvironmentFlag; /* e.g. PYTHONPATH, PYTHONHOME */ | 93 int Py_IgnoreEnvironmentFlag; /* e.g. PYTHONPATH, PYTHONHOME */ |
| 93 int Py_NoUserSiteDirectory = 0; /* for -s and site.py */ | 94 int Py_NoUserSiteDirectory = 0; /* for -s and site.py */ |
| 94 int Py_UnbufferedStdioFlag = 0; /* Unbuffered binary std{in,out,err} */ | 95 int Py_UnbufferedStdioFlag = 0; /* Unbuffered binary std{in,out,err} */ |
| 96 int Py_NoRandomHashFlag = 0; /* Don't use randomized hashes */ |
| 95 | 97 |
| 96 PyThreadState *_Py_Finalizing = NULL; | 98 PyThreadState *_Py_Finalizing = NULL; |
| 99 |
| 97 | 100 |
| 98 /* PyModule_GetWarningsModule is no longer necessary as of 2.6 | 101 /* PyModule_GetWarningsModule is no longer necessary as of 2.6 |
| 99 since _warnings is builtin. This API should not be used. */ | 102 since _warnings is builtin. This API should not be used. */ |
| 100 PyObject * | 103 PyObject * |
| 101 PyModule_GetWarningsModule(void) | 104 PyModule_GetWarningsModule(void) |
| 102 { | 105 { |
| 103 return PyImport_ImportModule("warnings"); | 106 return PyImport_ImportModule("warnings"); |
| 104 } | 107 } |
| 105 | 108 |
| 106 static int initialized = 0; | 109 static int initialized = 0; |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 #endif | 214 #endif |
| 212 | 215 |
| 213 if ((p = Py_GETENV("PYTHONDEBUG")) && *p != '\0') | 216 if ((p = Py_GETENV("PYTHONDEBUG")) && *p != '\0') |
| 214 Py_DebugFlag = add_flag(Py_DebugFlag, p); | 217 Py_DebugFlag = add_flag(Py_DebugFlag, p); |
| 215 if ((p = Py_GETENV("PYTHONVERBOSE")) && *p != '\0') | 218 if ((p = Py_GETENV("PYTHONVERBOSE")) && *p != '\0') |
| 216 Py_VerboseFlag = add_flag(Py_VerboseFlag, p); | 219 Py_VerboseFlag = add_flag(Py_VerboseFlag, p); |
| 217 if ((p = Py_GETENV("PYTHONOPTIMIZE")) && *p != '\0') | 220 if ((p = Py_GETENV("PYTHONOPTIMIZE")) && *p != '\0') |
| 218 Py_OptimizeFlag = add_flag(Py_OptimizeFlag, p); | 221 Py_OptimizeFlag = add_flag(Py_OptimizeFlag, p); |
| 219 if ((p = Py_GETENV("PYTHONDONTWRITEBYTECODE")) && *p != '\0') | 222 if ((p = Py_GETENV("PYTHONDONTWRITEBYTECODE")) && *p != '\0') |
| 220 Py_DontWriteBytecodeFlag = add_flag(Py_DontWriteBytecodeFlag, p); | 223 Py_DontWriteBytecodeFlag = add_flag(Py_DontWriteBytecodeFlag, p); |
| 224 if ((p = Py_GETENV("PYTHONNORANDOMHASH")) && *p != '\0') |
| 225 Py_NoRandomHashFlag = add_flag(Py_NoRandomHashFlag, p); |
| 226 |
| 227 if (!Py_NoRandomHashFlag) { |
| 228 _Py_InitRndHashSeed(); |
| 229 } |
| 221 | 230 |
| 222 interp = PyInterpreterState_New(); | 231 interp = PyInterpreterState_New(); |
| 223 if (interp == NULL) | 232 if (interp == NULL) |
| 224 Py_FatalError("Py_Initialize: can't make first interpreter"); | 233 Py_FatalError("Py_Initialize: can't make first interpreter"); |
| 225 | 234 |
| 226 tstate = PyThreadState_New(interp); | 235 tstate = PyThreadState_New(interp); |
| 227 if (tstate == NULL) | 236 if (tstate == NULL) |
| 228 Py_FatalError("Py_Initialize: can't make first thread"); | 237 Py_FatalError("Py_Initialize: can't make first thread"); |
| 229 (void) PyThreadState_Swap(tstate); | 238 (void) PyThreadState_Swap(tstate); |
| 230 | 239 |
| (...skipping 2330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2561 #undef PyRun_InteractiveLoop | 2570 #undef PyRun_InteractiveLoop |
| 2562 PyAPI_FUNC(int) | 2571 PyAPI_FUNC(int) |
| 2563 PyRun_InteractiveLoop(FILE *f, const char *p) | 2572 PyRun_InteractiveLoop(FILE *f, const char *p) |
| 2564 { | 2573 { |
| 2565 return PyRun_InteractiveLoopFlags(f, p, NULL); | 2574 return PyRun_InteractiveLoopFlags(f, p, NULL); |
| 2566 } | 2575 } |
| 2567 | 2576 |
| 2568 #ifdef __cplusplus | 2577 #ifdef __cplusplus |
| 2569 } | 2578 } |
| 2570 #endif | 2579 #endif |
| OLD | NEW |