Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Include/internal/pycore_ceval.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ struct _ceval_runtime_state;

extern void _Py_FinishPendingCalls(PyThreadState *tstate);
extern void _PyEval_InitRuntimeState(struct _ceval_runtime_state *);
extern int _PyEval_InitState(struct _ceval_state *ceval);
extern void _PyEval_InitState(struct _ceval_state *, PyThread_type_lock);
extern void _PyEval_FiniState(struct _ceval_state *ceval);
PyAPI_FUNC(void) _PyEval_SignalReceived(PyInterpreterState *interp);
PyAPI_FUNC(int) _PyEval_AddPendingCall(
Expand Down
11 changes: 3 additions & 8 deletions Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -747,24 +747,19 @@ _PyEval_InitRuntimeState(struct _ceval_runtime_state *ceval)
#endif
}

int
_PyEval_InitState(struct _ceval_state *ceval)
void

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get the point of this change.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's so I can call it in a void function.

_PyEval_InitState(struct _ceval_state *ceval, PyThread_type_lock pending_lock)
{
ceval->recursion_limit = Py_DEFAULT_RECURSION_LIMIT;

struct _pending_calls *pending = &ceval->pending;
assert(pending->lock == NULL);

pending->lock = PyThread_allocate_lock();
if (pending->lock == NULL) {
return -1;
}
pending->lock = pending_lock;

#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
_gil_initialize(&ceval->gil);
#endif

return 0;
}

void
Expand Down
4 changes: 3 additions & 1 deletion Python/pystate.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,12 @@ PyInterpreterState_New(void)
_PyRuntimeState *runtime = &_PyRuntime;
interp->runtime = runtime;

if (_PyEval_InitState(&interp->ceval) < 0) {
PyThread_type_lock pending_lock = PyThread_allocate_lock();
if (pending_lock == NULL) {
goto out_of_memory;
}

_PyEval_InitState(&interp->ceval, pending_lock);
_PyGC_InitState(&interp->gc);
PyConfig_InitPythonConfig(&interp->config);
_PyType_InitCache(interp);
Expand Down