LEFT | RIGHT |
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 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
782 | 782 |
783 void | 783 void |
784 Py_EndInterpreter(PyThreadState *tstate) | 784 Py_EndInterpreter(PyThreadState *tstate) |
785 { | 785 { |
786 PyInterpreterState *interp = tstate->interp; | 786 PyInterpreterState *interp = tstate->interp; |
787 | 787 |
788 if (tstate != PyThreadState_GET()) | 788 if (tstate != PyThreadState_GET()) |
789 Py_FatalError("Py_EndInterpreter: thread is not current"); | 789 Py_FatalError("Py_EndInterpreter: thread is not current"); |
790 if (tstate->frame != NULL) | 790 if (tstate->frame != NULL) |
791 Py_FatalError("Py_EndInterpreter: thread still has a frame"); | 791 Py_FatalError("Py_EndInterpreter: thread still has a frame"); |
| 792 |
| 793 wait_for_thread_shutdown(); |
| 794 |
792 if (tstate != interp->tstate_head || tstate->next != NULL) | 795 if (tstate != interp->tstate_head || tstate->next != NULL) |
793 Py_FatalError("Py_EndInterpreter: not the last thread"); | 796 Py_FatalError("Py_EndInterpreter: not the last thread"); |
794 | 797 |
795 PyImport_Cleanup(); | 798 PyImport_Cleanup(); |
796 PyInterpreterState_Clear(interp); | 799 PyInterpreterState_Clear(interp); |
797 PyThreadState_Swap(NULL); | 800 PyThreadState_Swap(NULL); |
798 PyInterpreterState_Delete(interp); | 801 PyInterpreterState_Delete(interp); |
799 } | 802 } |
800 | 803 |
801 #ifdef MS_WINDOWS | 804 #ifdef MS_WINDOWS |
(...skipping 1286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2088 PyCompilerFlags flags; | 2091 PyCompilerFlags flags; |
2089 PyArena *arena; | 2092 PyArena *arena; |
2090 | 2093 |
2091 arena = PyArena_New(); | 2094 arena = PyArena_New(); |
2092 if (arena == NULL) | 2095 if (arena == NULL) |
2093 return NULL; | 2096 return NULL; |
2094 | 2097 |
2095 flags.cf_flags = 0; | 2098 flags.cf_flags = 0; |
2096 mod = PyParser_ASTFromStringObject(str, filename, start, &flags, arena); | 2099 mod = PyParser_ASTFromStringObject(str, filename, start, &flags, arena); |
2097 if (mod == NULL) { | 2100 if (mod == NULL) { |
2098 Py_DECREF(filename); | |
2099 PyArena_Free(arena); | 2101 PyArena_Free(arena); |
2100 return NULL; | 2102 return NULL; |
2101 } | 2103 } |
2102 st = PySymtable_BuildObject(mod, filename, 0); | 2104 st = PySymtable_BuildObject(mod, filename, 0); |
2103 Py_DECREF(filename); | |
2104 PyArena_Free(arena); | 2105 PyArena_Free(arena); |
2105 return st; | 2106 return st; |
2106 } | 2107 } |
2107 | 2108 |
2108 struct symtable * | 2109 struct symtable * |
2109 Py_SymtableString(const char *str, const char *filename_str, int start) | 2110 Py_SymtableString(const char *str, const char *filename_str, int start) |
2110 { | 2111 { |
2111 PyObject *filename; | 2112 PyObject *filename; |
2112 struct symtable *st; | 2113 struct symtable *st; |
2113 | 2114 |
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2802 #undef PyRun_InteractiveLoop | 2803 #undef PyRun_InteractiveLoop |
2803 PyAPI_FUNC(int) | 2804 PyAPI_FUNC(int) |
2804 PyRun_InteractiveLoop(FILE *f, const char *p) | 2805 PyRun_InteractiveLoop(FILE *f, const char *p) |
2805 { | 2806 { |
2806 return PyRun_InteractiveLoopFlags(f, p, NULL); | 2807 return PyRun_InteractiveLoopFlags(f, p, NULL); |
2807 } | 2808 } |
2808 | 2809 |
2809 #ifdef __cplusplus | 2810 #ifdef __cplusplus |
2810 } | 2811 } |
2811 #endif | 2812 #endif |
LEFT | RIGHT |