Skip to content

Commit 23afbc2

Browse files
Expose Py_NewInterpreterFromConfig() and PyInterpreterConfig in the public C-API.
1 parent f73abf8 commit 23afbc2

File tree

5 files changed

+17
-16
lines changed

5 files changed

+17
-16
lines changed

Include/cpython/initconfig.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ typedef struct {
252252
int allow_threads;
253253
int allow_daemon_threads;
254254
int check_multi_interp_extensions;
255-
} _PyInterpreterConfig;
255+
} PyInterpreterConfig;
256256

257257
#define _PyInterpreterConfig_INIT \
258258
{ \

Include/cpython/pylifecycle.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ PyAPI_FUNC(int) _Py_CoerceLegacyLocale(int warn);
6262
PyAPI_FUNC(int) _Py_LegacyLocaleDetected(int warn);
6363
PyAPI_FUNC(char *) _Py_SetLocaleFromEnv(int category);
6464

65-
PyAPI_FUNC(PyStatus) _Py_NewInterpreterFromConfig(
65+
PyAPI_FUNC(PyStatus) Py_NewInterpreterFromConfig(
6666
PyThreadState **tstate_p,
67-
const _PyInterpreterConfig *config);
67+
const PyInterpreterConfig *config);
6868

6969
typedef void (*atexit_datacallbackfunc)(void *);
7070
PyAPI_FUNC(int) _Py_AtExit(

Modules/_testcapimodule.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1538,15 +1538,15 @@ run_in_subinterp_with_config(PyObject *self, PyObject *args, PyObject *kwargs)
15381538

15391539
PyThreadState_Swap(NULL);
15401540

1541-
const _PyInterpreterConfig config = {
1541+
const PyInterpreterConfig config = {
15421542
.use_main_obmalloc = use_main_obmalloc,
15431543
.allow_fork = allow_fork,
15441544
.allow_exec = allow_exec,
15451545
.allow_threads = allow_threads,
15461546
.allow_daemon_threads = allow_daemon_threads,
15471547
.check_multi_interp_extensions = check_multi_interp_extensions,
15481548
};
1549-
PyStatus status = _Py_NewInterpreterFromConfig(&substate, &config);
1549+
PyStatus status = Py_NewInterpreterFromConfig(&substate, &config);
15501550
if (PyStatus_Exception(status)) {
15511551
/* Since no new thread state was created, there is no exception to
15521552
propagate; raise a fresh one after swapping in the old thread

Modules/_xxsubinterpretersmodule.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -513,12 +513,12 @@ interp_create(PyObject *self, PyObject *args, PyObject *kwds)
513513

514514
// Create and initialize the new interpreter.
515515
PyThreadState *save_tstate = _PyThreadState_GET();
516-
const _PyInterpreterConfig config = isolated
517-
? (_PyInterpreterConfig)_PyInterpreterConfig_INIT
518-
: (_PyInterpreterConfig)_PyInterpreterConfig_LEGACY_INIT;
516+
const PyInterpreterConfig config = isolated
517+
? (PyInterpreterConfig)_PyInterpreterConfig_INIT
518+
: (PyInterpreterConfig)_PyInterpreterConfig_LEGACY_INIT;
519519
// XXX Possible GILState issues?
520520
PyThreadState *tstate = NULL;
521-
PyStatus status = _Py_NewInterpreterFromConfig(&tstate, &config);
521+
PyStatus status = Py_NewInterpreterFromConfig(&tstate, &config);
522522
PyThreadState_Swap(save_tstate);
523523
if (PyStatus_Exception(status)) {
524524
/* Since no new thread state was created, there is no exception to

Python/pylifecycle.c

+8-7
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,8 @@ pycore_init_runtime(_PyRuntimeState *runtime,
546546

547547

548548
static PyStatus
549-
init_interp_settings(PyInterpreterState *interp, const _PyInterpreterConfig *config)
549+
init_interp_settings(PyInterpreterState *interp,
550+
const PyInterpreterConfig *config)
550551
{
551552
assert(interp->feature_flags == 0);
552553

@@ -631,7 +632,7 @@ pycore_create_interpreter(_PyRuntimeState *runtime,
631632
return status;
632633
}
633634

634-
const _PyInterpreterConfig config = _PyInterpreterConfig_LEGACY_INIT;
635+
const PyInterpreterConfig config = _PyInterpreterConfig_LEGACY_INIT;
635636
status = init_interp_settings(interp, &config);
636637
if (_PyStatus_EXCEPTION(status)) {
637638
return status;
@@ -1991,7 +1992,7 @@ Py_Finalize(void)
19911992
*/
19921993

19931994
static PyStatus
1994-
new_interpreter(PyThreadState **tstate_p, const _PyInterpreterConfig *config)
1995+
new_interpreter(PyThreadState **tstate_p, const PyInterpreterConfig *config)
19951996
{
19961997
PyStatus status;
19971998

@@ -2079,8 +2080,8 @@ new_interpreter(PyThreadState **tstate_p, const _PyInterpreterConfig *config)
20792080
}
20802081

20812082
PyStatus
2082-
_Py_NewInterpreterFromConfig(PyThreadState **tstate_p,
2083-
const _PyInterpreterConfig *config)
2083+
Py_NewInterpreterFromConfig(PyThreadState **tstate_p,
2084+
const PyInterpreterConfig *config)
20842085
{
20852086
return new_interpreter(tstate_p, config);
20862087
}
@@ -2089,8 +2090,8 @@ PyThreadState *
20892090
Py_NewInterpreter(void)
20902091
{
20912092
PyThreadState *tstate = NULL;
2092-
const _PyInterpreterConfig config = _PyInterpreterConfig_LEGACY_INIT;
2093-
PyStatus status = _Py_NewInterpreterFromConfig(&tstate, &config);
2093+
const PyInterpreterConfig config = _PyInterpreterConfig_LEGACY_INIT;
2094+
PyStatus status = new_interpreter(&tstate, &config);
20942095
if (_PyStatus_EXCEPTION(status)) {
20952096
Py_ExitStatusException(status);
20962097
}

0 commit comments

Comments
 (0)