| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -549,7 +549,9 @@ subprocess_fork_exec(PyObject* self, PyObject *args) | |||
| 549 | 549 | int need_to_reenable_gc = 0; | |
| 550 | 550 | char *const *exec_array, *const *argv = NULL, *const *envp = NULL; | |
| 551 | 551 | Py_ssize_t arg_num; | |
| 552 | + #ifdef WITH_THREAD | ||
| 552 | 553 | int import_lock_held = 0; | |
| 554 | + #endif | ||
| 553 | 555 | ||
| 554 | 556 | if (!PyArg_ParseTuple( | |
| 555 | 557 | args, "OOpOOOiiiiiiiiiiO:fork_exec", | |
@@ -644,8 +646,10 @@ subprocess_fork_exec(PyObject* self, PyObject *args) | |||
| 644 | 646 | preexec_fn_args_tuple = PyTuple_New(0); | |
| 645 | 647 | if (!preexec_fn_args_tuple) | |
| 646 | 648 | goto cleanup; | |
| 649 | + #ifdef WITH_THREAD | ||
| 647 | 650 | _PyImport_AcquireLock(); | |
| 648 | 651 | import_lock_held = 1; | |
| 652 | + #endif | ||
| 649 | 653 | } | |
| 650 | 654 | ||
| 651 | 655 | if (cwd_obj != Py_None) { | |
@@ -688,12 +692,14 @@ subprocess_fork_exec(PyObject* self, PyObject *args) | |||
| 688 | 692 | /* Capture the errno exception before errno can be clobbered. */ | |
| 689 | 693 | PyErr_SetFromErrno(PyExc_OSError); | |
| 690 | 694 | } | |
| 691 | - if (preexec_fn != Py_None && | ||
| 692 | - _PyImport_ReleaseLock() < 0 && !PyErr_Occurred()) { | ||
| 695 | + #ifdef WITH_THREAD | ||
| 696 | + if (preexec_fn != Py_None | ||
| 697 | + && _PyImport_ReleaseLock() < 0 && !PyErr_Occurred()) { | ||
| 693 | 698 | PyErr_SetString(PyExc_RuntimeError, | |
| 694 | 699 | "not holding the import lock"); | |
| 695 | 700 | } | |
| 696 | 701 | import_lock_held = 0; | |
| 702 | + #endif | ||
| 697 | 703 | ||
| 698 | 704 | /* Parent process */ | |
| 699 | 705 | if (envp) | |
@@ -716,8 +722,10 @@ subprocess_fork_exec(PyObject* self, PyObject *args) | |||
| 716 | 722 | return PyLong_FromPid(pid); | |
| 717 | 723 | ||
| 718 | 724 | cleanup: | |
| 725 | + #ifdef WITH_THREAD | ||
| 719 | 726 | if (import_lock_held) | |
| 720 | 727 | _PyImport_ReleaseLock(); | |
| 728 | + #endif | ||
| 721 | 729 | if (envp) | |
| 722 | 730 | _Py_FreeCharPArray(envp); | |
| 723 | 731 | if (argv) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -719,8 +719,10 @@ sock_call_ex(PySocketSockObject *s, | |||
| 719 | 719 | int deadline_initialized = 0; | |
| 720 | 720 | int res; | |
| 721 | 721 | ||
| 722 | + #ifdef WITH_THREAD | ||
| 722 | 723 | /* sock_call() must be called with the GIL held. */ | |
| 723 | 724 | assert(PyGILState_Check()); | |
| 725 | + #endif | ||
| 724 | 726 | ||
| 725 | 727 | /* outer loop to retry select() when select() is interrupted by a signal | |
| 726 | 728 | or to retry select()+sock_func() on false positive (see above) */ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -986,8 +986,10 @@ _Py_open_impl(const char *pathname, int flags, int gil_held) | |||
| 986 | 986 | int | |
| 987 | 987 | _Py_open(const char *pathname, int flags) | |
| 988 | 988 | { | |
| 989 | + #ifdef WITH_THREAD | ||
| 989 | 990 | /* _Py_open() must be called with the GIL held. */ | |
| 990 | 991 | assert(PyGILState_Check()); | |
| 992 | + #endif | ||
| 991 | 993 | return _Py_open_impl(pathname, flags, 1); | |
| 992 | 994 | } | |
| 993 | 995 | ||
@@ -1080,7 +1082,9 @@ _Py_fopen_obj(PyObject *path, const char *mode) | |||
| 1080 | 1082 | wchar_t wmode[10]; | |
| 1081 | 1083 | int usize; | |
| 1082 | 1084 | ||
| 1085 | + #ifdef WITH_THREAD | ||
| 1083 | 1086 | assert(PyGILState_Check()); | |
| 1087 | + #endif | ||
| 1084 | 1088 | ||
| 1085 | 1089 | if (!PyUnicode_Check(path)) { | |
| 1086 | 1090 | PyErr_Format(PyExc_TypeError, | |
@@ -1108,7 +1112,9 @@ _Py_fopen_obj(PyObject *path, const char *mode) | |||
| 1108 | 1112 | PyObject *bytes; | |
| 1109 | 1113 | char *path_bytes; | |
| 1110 | 1114 | ||
| 1115 | + #ifdef WITH_THREAD | ||
| 1111 | 1116 | assert(PyGILState_Check()); | |
| 1117 | + #endif | ||
| 1112 | 1118 | ||
| 1113 | 1119 | if (!PyUnicode_FSConverter(path, &bytes)) | |
| 1114 | 1120 | return NULL; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments