Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9cc8a20

Browse files
committed
Moved PyEval_{Acquire,Release}Thread() to within the same #ifdef
WITH_THREAD as PyEval_InitThreads(). Removed use of Py_SuppressPrintingFlag.
1 parent 4c12570 commit 9cc8a20

1 file changed

Lines changed: 23 additions & 21 deletions

File tree

Python/ceval.c

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,28 @@ PyEval_InitThreads()
129129
main_thread = get_thread_ident();
130130
}
131131

132+
void
133+
PyEval_AcquireThread(tstate)
134+
PyThreadState *tstate;
135+
{
136+
if (tstate == NULL)
137+
Py_FatalError("PyEval_AcquireThread: NULL new thread state");
138+
acquire_lock(interpreter_lock, 1);
139+
if (PyThreadState_Swap(tstate) != NULL)
140+
Py_FatalError(
141+
"PyEval_AcquireThread: non-NULL old thread state");
142+
}
143+
144+
void
145+
PyEval_ReleaseThread(tstate)
146+
PyThreadState *tstate;
147+
{
148+
if (tstate == NULL)
149+
Py_FatalError("PyEval_ReleaseThread: NULL thread state");
150+
if (PyThreadState_Swap(NULL) != tstate)
151+
Py_FatalError("PyEval_ReleaseThread: wrong thread state");
152+
release_lock(interpreter_lock);
153+
}
132154
#endif
133155

134156
/* Functions save_thread and restore_thread are always defined so
@@ -167,25 +189,6 @@ PyEval_RestoreThread(tstate)
167189
#endif
168190
}
169191

170-
#ifdef WITH_THREAD
171-
void
172-
PyEval_AcquireThread(tstate)
173-
PyThreadState *tstate;
174-
{
175-
acquire_lock(interpreter_lock, 1);
176-
if (PyThreadState_Swap(tstate) != NULL)
177-
Py_FatalError("PyEval_AcquireThread: non-NULL old state");
178-
}
179-
180-
void
181-
PyEval_ReleaseThread(tstate)
182-
PyThreadState *tstate;
183-
{
184-
if (PyThreadState_Swap(NULL) != tstate)
185-
Py_FatalError("PyEval_ReleaseThread: wrong thread state");
186-
release_lock(interpreter_lock);
187-
}
188-
#endif
189192

190193
/* Mechanism whereby asynchronously executing callbacks (e.g. UNIX
191194
signal handlers or Mac I/O completion routines) can schedule calls
@@ -1000,8 +1003,7 @@ eval_code2(co, globals, locals,
10001003
/* Before printing, also assign to '_' */
10011004
if (v != Py_None &&
10021005
(err = PyDict_SetItemString(
1003-
f->f_builtins, "_", v)) == 0 &&
1004-
!Py_SuppressPrintingFlag) {
1006+
f->f_builtins, "_", v)) == 0) {
10051007
err = Py_FlushLine();
10061008
if (err == 0) {
10071009
x = PySys_GetObject("stdout");

0 commit comments

Comments
 (0)