Skip to content

Commit c6b7bb4

Browse files
Statically initialize PyInterpreterState.dlopen_flags.
1 parent 54458c4 commit c6b7bb4

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

Include/internal/pycore_runtime_init.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,22 @@ extern "C" {
3232
._main_interpreter = _PyInterpreterState_INIT, \
3333
}
3434

35+
#ifdef HAVE_DLOPEN
36+
# include <dlfcn.h>
37+
# if HAVE_DECL_RTLD_NOW
38+
# define _Py_DLOPEN_FLAGS RTLD_NOW
39+
# else
40+
# define _Py_DLOPEN_FLAGS RTLD_LAZY
41+
# endif
42+
#else
43+
# define _Py_DLOPEN_FLAGS 0
44+
#endif
45+
3546
#define _PyInterpreterState_INIT \
3647
{ \
3748
._static = 1, \
3849
.id_refcount = -1, \
50+
.dlopenflags = _Py_DLOPEN_FLAGS, \
3951
.ceval = { \
4052
.recursion_limit = Py_DEFAULT_RECURSION_LIMIT, \
4153
}, \

Python/pystate.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -290,14 +290,6 @@ init_interpreter(PyInterpreterState *interp,
290290
_PyGC_InitState(&interp->gc);
291291
PyConfig_InitPythonConfig(&interp->config);
292292
_PyType_InitCache(interp);
293-
interp->eval_frame = NULL;
294-
#ifdef HAVE_DLOPEN
295-
#if HAVE_DECL_RTLD_NOW
296-
interp->dlopenflags = RTLD_NOW;
297-
#else
298-
interp->dlopenflags = RTLD_LAZY;
299-
#endif
300-
#endif
301293

302294
interp->_initialized = 1;
303295
}

0 commit comments

Comments
 (0)