cpython/Include/internal
Eric Snow f32369480d
gh-98608: Change _Py_NewInterpreter() to _Py_NewInterpreterFromConfig() (gh-98609)
(see https://github.com/python/cpython/issues/98608)

This change does the following:

1. change the argument to a new `_PyInterpreterConfig` struct
2. rename the function to `_Py_NewInterpreterFromConfig()`, inspired by `Py_InitializeFromConfig()` (takes a `_PyInterpreterConfig`  instead of `isolated_subinterpreter`)
3. split up the boolean `isolated_subinterpreter` into the corresponding multiple granular settings
   * allow_fork
   * allow_subprocess
   * allow_threads
4. add `PyInterpreterState.feature_flags` to store those settings
5. add a function for checking if a feature is enabled on an opaque `PyInterpreterState *`
6. drop `PyConfig._isolated_interpreter`

The existing default (see `Py_NewInterpeter()` and `Py_Initialize*()`) allows fork, subprocess, and threads and the optional "isolated" interpreter (see the `_xxsubinterpreters` module) disables all three.  None of that changes here; the defaults are preserved.

Note that the given `_PyInterpreterConfig` will not be used outside `_Py_NewInterpreterFromConfig()`, nor preserved.  This contrasts with how `PyConfig` is currently preserved, used, and even modified outside `Py_InitializeFromConfig()`.  I'd rather just avoid that mess from the start for `_PyInterpreterConfig`.  We can preserve it later if we find an actual need.

This change allows us to follow up with a number of improvements (e.g. stop disallowing subprocess and support disallowing exec instead).

(Note that this PR adds "private" symbols.  We'll probably make them public, and add docs, in a separate change.)
2022-10-26 11:16:30 -06:00
..
pycore_abstract.h bpo-45636: Simplify BINARY_OP (GH-29565) 2021-11-16 05:53:57 -08:00
pycore_asdl.h gh-87347: Add parenthesis around macro arguments (#93915) 2022-06-20 16:04:52 +02:00
pycore_ast.h bpo-45292: [PEP-654] add except* (GH-29581) 2021-12-14 16:48:15 +00:00
pycore_ast_state.h gh-95185: Check recursion depth in the AST constructor (#95186) 2022-07-24 15:58:52 +01:00
pycore_atomic.h Fix typo in internal/pycore_atomic.h (GH-95939) 2022-08-13 11:40:41 +08:00
pycore_atomic_funcs.h bpo-39465: Add pycore_atomic_funcs.h header (GH-20766) 2020-12-23 03:41:08 +01:00
pycore_bitutils.h bpo-29882: Fix portability bug introduced in GH-30774 (#30794) 2022-01-23 09:59:34 +00:00
pycore_blocks_output_buffer.h bpo-44458: Ensure BUFFER_BLOCK_SIZE symbol is statically allocated. (GH-26808) 2021-06-21 23:36:36 -07:00
pycore_bytes_methods.h bpo-35081: Move bytes_methods.h to the internal C API (GH-18492) 2020-02-12 22:32:34 +01:00
pycore_bytesobject.h bpo-47070: Add _PyBytes_Repeat() (GH-31999) 2022-03-28 04:43:45 -04:00
pycore_call.h GH-90230: Add stats to breakdown the origin of calls to `PyEval_EvalFrame` (GH-93284) 2022-05-27 16:31:41 +01:00
pycore_ceval.h GH-91079: Decouple C stack overflow checks from Python recursion checks. (GH-96510) 2022-10-05 01:34:03 +01:00
pycore_code.h GH-90997: Improve inline cache performance for MSVC (GH-96781) 2022-09-14 17:05:04 -07:00
pycore_compile.h gh-93678: add _testinternalcapi.optimize_cfg() and test utils for compiler optimization unit tests (GH-96007) 2022-08-24 11:02:53 +01:00
pycore_condvar.h bpo-46315: Add ifdef HAVE_ feature checks for WASI compatibility (GH-30507) 2022-01-13 09:46:04 +01:00
pycore_context.h bpo-46417: Clear more static types (GH-30796) 2022-01-22 18:55:48 +01:00
pycore_descrobject.h gh-93911: Specialize `LOAD_ATTR_PROPERTY` (GH-93912) 2022-06-17 23:13:17 +08:00
pycore_dict.h GH-91052: Add C API for watching dictionaries (GH-31787) 2022-10-07 01:08:00 +01:00
pycore_dtoa.h bpo-45412: Add _PY_SHORT_FLOAT_REPR macro (GH-31171) 2022-02-23 18:16:23 +01:00
pycore_emscripten_signal.h bpo-47176: Interrupt handling for wasm32-emscripten builds without pthreads (GH-32209) 2022-04-03 22:58:52 +02:00
pycore_exceptions.h bpo-46417: Factorize _PyExc_InitTypes() code (GH-30804) 2022-01-22 21:48:56 +01:00
pycore_fileutils.h bpo-46362: Ensure ntpath.abspath() uses the Windows API correctly (GH-30571) 2022-01-13 23:35:42 +00:00
pycore_floatobject.h gh-90667: Add specializations of Py_DECREF when types are known (GH-30872) 2022-04-19 19:02:19 +01:00
pycore_format.h bpo-45995: add "z" format specifer to coerce negative 0 to zero (GH-30049) 2022-04-11 15:34:18 +01:00
pycore_frame.h GH-96569: Add two NULL checks to avoid undefined behavior. (GH-96585) 2022-09-06 16:45:43 +01:00
pycore_function.h bpo-45316: Move private functions to internal C API (GH-31579) 2022-02-25 16:07:14 +01:00
pycore_gc.h gh-97922: Run the GC only on eval breaker (#97920) 2022-10-08 07:57:09 -07:00
pycore_genobject.h bpo-45316: Move private functions to internal C API (GH-31579) 2022-02-25 16:07:14 +01:00
pycore_getopt.h bpo-36763: Cleanup precmdline in _PyCoreConfig_Read() (GH-13371) 2019-05-17 03:15:12 +02:00
pycore_gil.h bpo-38353: Cleanup includes in the internal C API (GH-16548) 2019-10-02 23:51:20 +02:00
pycore_global_objects.h GH-96075: move interned dict under runtime state (GH-96077) 2022-08-22 12:05:21 -07:00
pycore_global_strings.h gh-91058: Add error suggestions to 'import from' import errors (#98305) 2022-10-25 23:56:59 +01:00
pycore_hamt.h gh-87347: Add parenthesis around PyXXX_Check() arguments (#92815) 2022-06-16 13:49:43 +02:00
pycore_hashtable.h gh-87347: Add parenthesis around macro arguments (#93915) 2022-06-20 16:04:52 +02:00
pycore_import.h bpo-45395: Make custom frozen modules additions instead of replacements. (gh-28778) 2021-10-28 15:04:33 -06:00
pycore_initconfig.h gh-96512: Move int_max_str_digits setting to PyConfig (#96944) 2022-10-03 13:55:45 -07:00
pycore_interp.h gh-98608: Change _Py_NewInterpreter() to _Py_NewInterpreterFromConfig() (gh-98609) 2022-10-26 11:16:30 -06:00
pycore_interpreteridobject.h bpo-35081: Move interpreteridobject.h to Include/internal/ (GH-28969) 2021-10-15 11:56:34 +02:00
pycore_list.h gh-91247: Use memcpy for list and tuple repeat (#91482) 2022-07-25 22:10:23 -04:00
pycore_long.h gh-95778: Correctly pre-check for int-to-str conversion (#96537) 2022-09-04 09:21:18 -07:00
pycore_moduleobject.h bpo-45459: Use type names in the internal C API (GH-31669) 2022-03-03 23:08:07 +01:00
pycore_namespace.h bpo-45482: Rename namespaceobject.h to pycore_namespace.h (GH-28975) 2021-10-15 15:21:21 +02:00
pycore_object.h GH-95245: Move weakreflist into the pre-header. (GH-95996) 2022-08-16 13:57:18 +01:00
pycore_opcode.h gh-97669: Create Tools/build/ directory (#97963) 2022-10-17 12:01:00 +02:00
pycore_parser.h bpo-43244: Remove parser_interface.h header file (GH-25001) 2021-03-24 01:29:09 +01:00
pycore_pathconfig.h bpo-45582: Port getpath[p].c to Python (GH-29041) 2021-12-03 00:08:42 +00:00
pycore_pyarena.h bpo-43244: Remove the pyarena.h header (GH-25007) 2021-03-24 02:23:01 +01:00
pycore_pyerrors.h gh-90667: Add specializations of Py_DECREF when types are known (GH-30872) 2022-04-19 19:02:19 +01:00
pycore_pyhash.h bpo-36635: Change pyport.h for Py_BUILD_CORE_MODULE define (GH-12853) 2019-04-17 23:02:26 +02:00
pycore_pylifecycle.h gh-64783: Fix signal.NSIG value on FreeBSD (#91929) 2022-04-26 00:13:31 +02:00
pycore_pymath.h gh-82616: Add Py_IS_TYPE_SIGNED() macro (#93178) 2022-05-27 15:05:35 +02:00
pycore_pymem.h bpo-40170: Move _Py_GetAllocatedBlocks() to pycore_pymem.h (GH-30943) 2022-01-27 21:23:22 +01:00
pycore_pystate.h GH-96177: Move GIL and eval breaker code out of ceval.c into ceval_gil.c. (GH-96204) 2022-08-24 14:21:01 +01:00
pycore_range.h GH-91432: Specialize FOR_ITER (GH-91713) 2022-06-21 11:19:26 +01:00
pycore_runtime.h gh-96947: Fix comment on `pyruntimestate->pyinterpreters` struct for `next_id` (GH-96949) 2022-09-20 12:54:33 -07:00
pycore_runtime_init.h GH-91079: Decouple C stack overflow checks from Python recursion checks. (GH-96510) 2022-10-05 01:34:03 +01:00
pycore_runtime_init_generated.h gh-91058: Add error suggestions to 'import from' import errors (#98305) 2022-10-25 23:56:59 +01:00
pycore_signal.h gh-64783: Fix signal.NSIG value on FreeBSD (#91929) 2022-04-26 00:13:31 +02:00
pycore_sliceobject.h GH-94163: Add BINARY_SLICE and STORE_SLICE instructions. (GH-94168) 2022-06-27 12:24:23 +01:00
pycore_strhex.h gh-91768: C API no longer use "const PyObject*" type (#91769) 2022-04-21 22:07:19 +02:00
pycore_structseq.h gh-94673: Add _PyStaticType_InitBuiltin() (#95152) 2022-07-25 12:47:31 -06:00
pycore_symtable.h Make _symtable_entry.ste_type's comment consistent wit _Py_block_ty (#92414) 2022-10-07 10:53:07 -07:00
pycore_sysmodule.h bpo-46541: Replace core use of _Py_IDENTIFIER() with statically initialized global objects. (gh-30928) 2022-02-08 13:39:07 -07:00
pycore_token.h gh-97669: Create Tools/build/ directory (#97963) 2022-10-17 12:01:00 +02:00
pycore_traceback.h bpo-45459: Use type names in the internal C API (GH-31669) 2022-03-03 23:08:07 +01:00
pycore_tuple.h bpo-46753: Add the empty tuple to the _PyRuntimeState.global_objects. (gh-31345) 2022-02-28 15:15:48 -07:00
pycore_typeobject.h GH-90699: use statically allocated interned strings in typeobject's slotdefs (GH-94706) 2022-09-07 15:02:08 -07:00
pycore_ucnhash.h bpo-42157: Rename unicodedata.ucnhash_CAPI (GH-22994) 2020-10-27 04:36:22 +01:00
pycore_unicodeobject.h GH-96458: Statically initialize utf8 representation of static strings (#96481) 2022-09-02 23:43:08 -07:00
pycore_unionobject.h gh-87347: Add parenthesis around PyXXX_Check() arguments (#92815) 2022-06-16 13:49:43 +02:00
pycore_warnings.h bpo-35134: Split warnings.h and weakrefobject.h (GH-29042) 2021-10-19 01:31:57 +02:00