@@ -93,11 +93,14 @@ inline void precheck_interpreter() {
93
93
}
94
94
}
95
95
96
+ PYBIND11_NAMESPACE_END (detail)
97
+
96
98
#if PY_VERSION_HEX >= PYBIND11_PYCONFIG_SUPPORT_PY_VERSION_HEX
97
99
inline void initialize_interpreter (PyConfig *config,
98
100
int argc = 0 ,
99
101
const char *const *argv = nullptr ,
100
102
bool add_program_dir_to_path = true ) {
103
+ detail::precheck_interpreter ();
101
104
PyStatus status = PyConfig_SetBytesArgv (config, argc, const_cast <char *const *>(argv));
102
105
if (PyStatus_Exception (status) != 0 ) {
103
106
// A failure here indicates a character-encoding failure or the python
@@ -125,6 +128,7 @@ inline void initialize_interpreter_pre_pyconfig(bool init_signal_handlers,
125
128
int argc,
126
129
const char *const *argv,
127
130
bool add_program_dir_to_path) {
131
+ detail::precheck_interpreter ();
128
132
Py_InitializeEx (init_signal_handlers ? 1 : 0 );
129
133
# if defined(WITH_THREAD) && PY_VERSION_HEX < 0x03070000
130
134
PyEval_InitThreads ();
@@ -161,8 +165,6 @@ inline void initialize_interpreter_pre_pyconfig(bool init_signal_handlers,
161
165
}
162
166
#endif
163
167
164
- PYBIND11_NAMESPACE_END (detail)
165
-
166
168
/* * \rst
167
169
Initialize the Python interpreter. No other pybind11 or CPython API functions can be
168
170
called before this is done; with the exception of `PYBIND11_EMBEDDED_MODULE`. The
@@ -186,17 +188,15 @@ inline void initialize_interpreter(bool init_signal_handlers = true,
186
188
int argc = 0 ,
187
189
const char *const *argv = nullptr ,
188
190
bool add_program_dir_to_path = true ) {
189
- detail::precheck_interpreter ();
190
191
#if PY_VERSION_HEX < PYBIND11_PYCONFIG_SUPPORT_PY_VERSION_HEX
191
- detail::initialize_interpreter_pre_pyconfig (
192
- init_signal_handlers, argc, argv, add_program_dir_to_path);
192
+ initialize_interpreter_pre_pyconfig (init_signal_handlers, argc, argv, add_program_dir_to_path);
193
193
#else
194
194
PyConfig config;
195
195
PyConfig_InitIsolatedConfig (&config);
196
196
config.isolated = 0 ;
197
197
config.use_environment = 1 ;
198
198
config.install_signal_handlers = init_signal_handlers ? 1 : 0 ;
199
- detail:: initialize_interpreter (&config, argc, argv, add_program_dir_to_path);
199
+ initialize_interpreter (&config, argc, argv, add_program_dir_to_path);
200
200
#endif
201
201
}
202
202
@@ -289,8 +289,7 @@ class scoped_interpreter {
289
289
int argc = 0 ,
290
290
const char *const *argv = nullptr ,
291
291
bool add_program_dir_to_path = true ) {
292
- detail::precheck_interpreter ();
293
- detail::initialize_interpreter (config, argc, argv, add_program_dir_to_path);
292
+ initialize_interpreter (config, argc, argv, add_program_dir_to_path);
294
293
}
295
294
#endif
296
295
0 commit comments