summaryrefslogtreecommitdiffstats
path: root/Include/internal
Commit message (Collapse)AuthorAgeFilesLines
* bpo-1230540: Add threading.excepthook() (GH-13515)Victor Stinner2019-05-271-0/+2
| | | | | | | | | | | | | | | | | | | Add a new threading.excepthook() function which handles uncaught Thread.run() exception. It can be overridden to control how uncaught exceptions are handled. threading.ExceptHookArgs is not documented on purpose: it should not be used directly. * threading.excepthook() and threading.ExceptHookArgs. * Add _PyErr_Display(): similar to PyErr_Display(), but accept a 'file' parameter. * Add _thread._excepthook(): C implementation of the exception hook calling _PyErr_Display(). * Add _thread._ExceptHookArgs: structseq type. * Add threading._invoke_excepthook_wrapper() which handles the gory details to ensure that everything remains alive during Python shutdown. * Add unit tests.
* bpo-36763: Implement the PEP 587 (GH-13592)Victor Stinner2019-05-275-199/+204
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add a whole new documentation page: "Python Initialization Configuration" * PyWideStringList_Append() return type is now PyStatus, instead of int * PyInterpreterState_New() now calls PyConfig_Clear() if PyConfig_InitPythonConfig() fails. * Rename files: * Python/coreconfig.c => Python/initconfig.c * Include/cpython/coreconfig.h => Include/cpython/initconfig.h * Include/internal/: pycore_coreconfig.h => pycore_initconfig.h * Rename structures * _PyCoreConfig => PyConfig * _PyPreConfig => PyPreConfig * _PyInitError => PyStatus * _PyWstrList => PyWideStringList * Rename PyConfig fields: * use_module_search_paths => module_search_paths_set * module_search_path_env => pythonpath_env * Rename PyStatus field: _func => func * PyInterpreterState: rename core_config field to config * Rename macros and functions: * _PyCoreConfig_SetArgv() => PyConfig_SetBytesArgv() * _PyCoreConfig_SetWideArgv() => PyConfig_SetArgv() * _PyCoreConfig_DecodeLocale() => PyConfig_SetBytesString() * _PyInitError_Failed() => PyStatus_Exception() * _Py_INIT_ERROR_TYPE_xxx enums => _PyStatus_TYPE_xxx * _Py_UnixMain() => Py_BytesMain() * _Py_ExitInitError() => Py_ExitStatusException() * _Py_PreInitializeFromArgs() => Py_PreInitializeFromBytesArgs() * _Py_PreInitializeFromWideArgs() => Py_PreInitializeFromArgs() * _Py_PreInitialize() => Py_PreInitialize() * _Py_RunMain() => Py_RunMain() * _Py_InitializeFromConfig() => Py_InitializeFromConfig() * _Py_INIT_XXX() => _PyStatus_XXX() * _Py_INIT_FAILED() => _PyStatus_EXCEPTION() * Rename 'err' PyStatus variables to 'status' * Convert RUN_CODE() macro to config_run_code() static inline function * Remove functions: * _Py_InitializeFromArgs() * _Py_InitializeFromWideArgs() * _PyInterpreterState_GetCoreConfig()
* bpo-36710: Add tstate parameter in ceval.c (GH-13547)Victor Stinner2019-05-244-3/+68
| | | | | | | | | | | | | | | | * Fix a possible reference leak in _PyErr_Print() if exception is NULL. * PyErr_BadInternalCall(): replace PyErr_Format() with _PyErr_SetString(). * Add pycore_pyerrors.h header file. * New functions: * _PyErr_Clear() * _PyErr_Fetch() * _PyErr_Print() * _PyErr_Restore() * _PyErr_SetObject() * _PyErr_SetString() * Add 'tstate' parameter to _PyEval_AddPendingCall().
* bpo-36842: Implement PEP 578 (GH-12613)Steve Dower2019-05-231-0/+16
| | | Adds sys.audit, sys.addaudithook, io.open_code, and associated C APIs.
* bpo-36829: PyErr_WriteUnraisable() normalizes exception (GH-13507)Victor Stinner2019-05-221-0/+4
| | | | | | PyErr_WriteUnraisable() now creates a traceback object if there is no current traceback. Moreover, call PyErr_NormalizeException() and PyException_SetTraceback() to normalize the exception value. Ignore silently any error.
* bpo-36763: Add _PyPreConfig._config_init (GH-13481)Victor Stinner2019-05-221-2/+2
| | | | | | | | | | | | | | | | | | | * _PyPreConfig_GetGlobalConfig() and _PyCoreConfig_GetGlobalConfig() now do nothing if the configuration was not initialized with _PyPreConfig_InitCompatConfig() and _PyCoreConfig_InitCompatConfig() * Remove utf8_mode=-2 special case: use utf8_mode=-1 instead. * Fix _PyPreConfig_InitPythonConfig(): * isolated = 0 instead of -1 * use_environment = 1 instead of -1 * Rename _PyConfig_INIT to _PyConfig_INIT_COMPAT * Rename _PyPreConfig_Init() to _PyPreConfig_InitCompatConfig() * Rename _PyCoreConfig_Init() to _PyCoreConfig_InitCompatConfig() * PyInterpreterState_New() now uses _PyCoreConfig_InitPythonConfig() as default configuration, but it's very quickly overriden anyway. * _freeze_importlib.c uses _PyCoreConfig_SetString() to set program_name. * Cleanup preconfig_init_utf8_mode(): cmdline is always non-NULL.
* bpo-36829: Add sys.unraisablehook() (GH-13187)Victor Stinner2019-05-221-0/+4
| | | | | | | | | | | | | | | | | | | Add new sys.unraisablehook() function which can be overridden to control how "unraisable exceptions" are handled. It is called when an exception has occurred but there is no way for Python to handle it. For example, when a destructor raises an exception or during garbage collection (gc.collect()). Changes: * Add an internal UnraisableHookArgs type used to pass arguments to sys.unraisablehook. * Add _PyErr_WriteUnraisableDefaultHook(). * The default hook now ignores exception on writing the traceback. * test_sys now uses unittest.main() to automatically discover tests: remove test_main(). * Add _PyErr_Init(). * Fix PyErr_WriteUnraisable(): hold a strong reference to sys.stderr while using it
* bpo-36763: Fix Python preinitialization (GH-13432)Victor Stinner2019-05-201-2/+8
| | | | | | | | | | | | | | | | | | | | | * Add _PyPreConfig.parse_argv * Add _PyCoreConfig._config_init field and _PyCoreConfigInitEnum enum type * Initialization functions: reject preconfig=NULL and config=NULL * Add config parameter to _PyCoreConfig_DecodeLocaleErr(): pass config->argv to _Py_PreInitializeFromPyArgv(), to parse config command line arguments in preinitialization. * Add config parameter to _PyCoreConfig_SetString(). It now preinitializes Python. * _PyCoreConfig_SetPyArgv() now also preinitializes Python for wide argv * Fix _Py_PreInitializeFromCoreConfig(): don't pass args to _Py_PreInitializeFromPyArgv() if config.parse_argv=0. * Use "char * const *" and "wchar_t * const *" types for 'argv' parameters and _PyArgv.argv. * Add unit test on preinitialization from argv. * _PyPreConfig.allocator type becomes int * Add _PyPreConfig_InitFromPreConfig() and _PyPreConfig_InitFromCoreConfig() helper functions
* bpo-35134: Split traceback.h header (GH-13430)Victor Stinner2019-05-191-0/+92
| | | | Add new Include/cpython/traceback.h and Include/internal/traceback.h header files.
* bpo-36763: Remove _PyCoreConfig.dll_path (GH-13402)Victor Stinner2019-05-181-0/+4
|
* bpo-36763: Use _PyCoreConfig_InitPythonConfig() (GH-13398)Victor Stinner2019-05-181-19/+1
| | | | | | | | | | | | | | | | | _PyPreConfig_InitPythonConfig() and _PyCoreConfig_InitPythonConfig() no longer inherit their values from global configuration variables. Changes: * _PyPreCmdline_Read() now ignores -X dev and PYTHONDEVMODE if dev_mode is already set. * Inline _PyPreConfig_INIT macro into _PyPreConfig_Init() function. * Inline _PyCoreConfig_INIT macro into _PyCoreConfig_Init() function. * Replace _PyCoreConfig_Init() with _PyCoreConfig_InitPythonConfig() in most tests of _testembed.c. * Replace _PyCoreConfig_Init() with _PyCoreConfig_InitIsolatedConfig() in _freeze_importlib.c. * Move some initialization functions from the internal to the private API.
* bpo-36763: _Py_InitializeFromArgs() argc becomes Py_ssize_t (GH-13396)Victor Stinner2019-05-171-4/+4
| | | | | | | * The type of initlization function 'argc' parameters becomes Py_ssize_t, instead of int. * Change _PyPreConfig_Copy() return type to void, instead of int. The function cannot fail anymore. * Fix compilation warnings on Windows.
* bpo-36763: Add _PyInitError functions (GH-13395)Victor Stinner2019-05-171-0/+32
| | | | | | | | | | | | | | | * Add _PyInitError functions: * _PyInitError_Ok() * _PyInitError_Error() * _PyInitError_NoMemory() * _PyInitError_Exit() * _PyInitError_IsError() * _PyInitError_IsExit() * _PyInitError_Failed() * frozenmain.c and _testembed.c now use functions rather than macros. * Move _Py_INIT_xxx() macros to the internal API. * Move _PyWstrList_INIT macro to the internal API.
* bpo-36763: _Py_RunMain() doesn't call Py_Exit() anymore (GH-13390)Victor Stinner2019-05-171-0/+2
| | | | | | | | | Py_Main() and _Py_RunMain() now return the exitcode rather than calling Py_Exit(exitcode) when calling PyErr_Print() if the current exception type is SystemExit. * Add _Py_HandleSystemExit(). * Add pymain_exit_err_print(). * Add pymain_exit_print().
* bpo-36763: Add _PyCoreConfig_InitPythonConfig() (GH-13388)Victor Stinner2019-05-171-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add new functions to get the Python interpreter behavior: * _PyPreConfig_InitPythonConfig() * _PyCoreConfig_InitPythonConfig() Add new functions to get an isolated configuration: * _PyPreConfig_InitIsolatedConfig() * _PyCoreConfig_InitIsolatedConfig() Replace _PyPreConfig_INIT and _PyCoreConfig_INIT with new functions _PyPreConfig_Init() and _PyCoreConfig_Init(). _PyCoreConfig: set configure_c_stdio and parse_argv to 0 by default to behave as Python 3.6 in the default configuration. _PyCoreConfig_Read() no longer sets coerce_c_locale_warn to 1 if it's equal to 0. coerce_c_locale_warn must now be set to -1 (ex: using _PyCoreConfig_InitPythonConfig()) to enable C locale coercion warning. Add unit tests for _PyCoreConfig_InitPythonConfig() and _PyCoreConfig_InitIsolatedConfig(). Changes: * Rename _PyCoreConfig_GetCoreConfig() to _PyPreConfig_GetCoreConfig() * Fix core_read_precmdline(): handle parse_argv=0 * Fix _Py_PreInitializeFromCoreConfig(): pass coreconfig.argv to _Py_PreInitializeFromPyArgv(), except if parse_argv=0
* bpo-36763: Add PyMemAllocatorName (GH-13387)Victor Stinner2019-05-172-2/+10
| | | | | | | | | | | | | | * Add PyMemAllocatorName enum * _PyPreConfig.allocator type becomes PyMemAllocatorName, instead of char* * Remove _PyPreConfig_Clear() * Add _PyMem_GetAllocatorName() * Rename _PyMem_GetAllocatorsName() to _PyMem_GetCurrentAllocatorName() * Remove _PyPreConfig_SetAllocator(): just call _PyMem_SetupAllocators() directly, we don't have do reallocate the configuration with the new allocator anymore! * _PyPreConfig_Write() parameter becomes const, as it should be in the first place!
* bpo-36763: Cleanup precmdline in _PyCoreConfig_Read() (GH-13371)Victor Stinner2019-05-171-1/+1
| | | | precmdline is only needed in _PyCoreConfig_Read(), not in config_read_cmdline(). Reorganize _PyCoreConfig_Read().
* bpo-36900: import.c uses PyInterpreterState.core_config (GH-13278)Victor Stinner2019-05-131-0/+2
| | | | Move _PyImportZip_Init() to the internal C API and add an 'interp' parameter.
* bpo-36728: Remove PyEval_ReInitThreads() from C API (GH-13241)Victor Stinner2019-05-131-0/+2
| | | | | | | | Remove the PyEval_ReInitThreads() function from the Python C API. It should not be called explicitly: use PyOS_AfterFork_Child() instead. Rename PyEval_ReInitThreads() to _PyEval_ReInitThreads() and add a 'runtime' parameter.
* bpo-36710: Add 'ceval' local variable to ceval.c (GH-12934)Victor Stinner2019-05-102-47/+65
| | | | | | | | | | | | | | | | | | | | | | | | | Add "struct _ceval_runtime_state *ceval = &_PyRuntime.ceval;" local variables to function to better highlight the dependency on the global variable _PyRuntime and to point directly to _PyRuntime.ceval field rather than on the larger _PyRuntime. Changes: * Add _PyRuntimeState_GetThreadState(runtime) macro. * Add _PyEval_AddPendingCall(ceval, ...) and _PyThreadState_Swap(gilstate, ...) functions. * _PyThreadState_GET() macro now calls _PyRuntimeState_GetThreadState() using &_PyRuntime. * Add 'ceval' parameter to COMPUTE_EVAL_BREAKER(), SIGNAL_PENDING_SIGNALS(), _PyEval_SignalAsyncExc(), _PyEval_SignalReceived() and _PyEval_FiniThreads() macros and functions. * Add 'tstate' parameter to call_function(), do_call_core() and do_raise(). * Add 'runtime' parameter to _Py_CURRENTLY_FINALIZING(), _Py_FinishPendingCalls() and _PyThreadState_DeleteExcept() macros and functions. * Declare 'runtime', 'tstate', 'ceval' and 'eval_breaker' variables as constant.
* bpo-36737: Use the module state C-API for warnings. (gh-13159)Eric Snow2019-05-102-2/+3
|
* bpo-36763: _PyCoreConfig_SetPyArgv() preinitializes Python (GH-13037)Victor Stinner2019-05-021-2/+7
| | | | | | | | _PyCoreConfig_SetPyArgv() and _PyCoreConfig_SetWideString() now pre-initialize Python if needed to ensure that the locale encoding is properly configured. * Add _Py_PreInitializeFromPyArgv() internal function. * Add 'args' parameter to _Py_PreInitializeFromCoreConfig()
* bpo-36775: _PyCoreConfig only uses wchar_t* (GH-13062)Victor Stinner2019-05-023-5/+12
| | | | | | | | | | | | | | | | | _PyCoreConfig: Change filesystem_encoding, filesystem_errors, stdio_encoding and stdio_errors fields type from char* to wchar_t*. Changes: * PyInterpreterState: replace fscodec_initialized (int) with fs_codec structure. * Add get_error_handler_wide() and unicode_encode_utf8() helper functions. * Add error_handler parameter to unicode_encode_locale() and unicode_decode_locale(). * Remove _PyCoreConfig_SetString(). * Rename _PyCoreConfig_SetWideString() to _PyCoreConfig_SetString(). * Rename _PyCoreConfig_SetWideStringFromString() to _PyCoreConfig_DecodeLocale().
* bpo-36775: Add _PyUnicode_InitEncodings() (GH-13057)Victor Stinner2019-05-021-2/+3
| | | | | | Move get_codec_name() and initfsencoding() from pylifecycle.c to unicodeobject.c. Rename also "init" functions in pylifecycle.c.
* bpo-36763: Add _PyCoreConfig_SetString() (GH-13035)Victor Stinner2019-05-011-2/+10
| | | | | | | | | | | | Add 3 new config methods: * _PyCoreConfig_SetString() * _PyCoreConfig_SetWideString() * _PyCoreConfig_SetWideStringFromString() Changes: * _PyCoreConfig_Copy() returns _PyInitError. * Add CONFIG_GET_ENV_DUP().
* bpo-36763: Add _PyCoreConfig_SetArgv() (GH-13030)Victor Stinner2019-05-011-2/+12
| | | | | | | | | * Add 2 new config methods: * _PyCoreConfig_SetArgv() * _PyCoreConfig_SetWideArgv() * Add also an internal _PyCoreConfig_SetPyArgv() method. * Remove 'args' parameter from _PyCoreConfig_Read().
* Revert "bpo-36356: Destroy the GIL at exit (GH-12453)" (GH613006)Victor Stinner2019-04-291-3/+0
| | | This reverts commit b36e5d627d4232a01850707eb78a5067f3fd77f4.
* bpo-36356: Destroy the GIL at exit (GH-12453)Victor Stinner2019-04-291-0/+3
| | | | | | * Add _PyEval_FiniThreads2(). _PyEval_FiniThreads() now only clears the pending lock, whereas _PyEval_FiniThreads2() destroys the GIL. * pymain_free() now calls _PyEval_FiniThreads2(). * Py_FinalizeEx() now calls _PyEval_FiniThreads().
* bpo-36724: Add _PyWarnings_Fini() (#12963)Victor Stinner2019-04-261-0/+1
| | | | | | | | | | Py_FinalizeEx() now clears _PyRuntime.warnings variables and _PyRuntime.exitfuncs. Changes: * Add _PyWarnings_Fini(): called by Py_FinalizeEx() * call_ll_exitfuncs() now clears _PyRuntime.exitfuncs while iterating on it (on backward order).
* bpo-36710: Add runtime parameter in gcmodule.c (GH-12958)Victor Stinner2019-04-261-1/+1
| | | | Add 'state' or 'runtime' parameter to functions in gcmodule.c to avoid to rely directly on the global variable _PyRuntime.
* bpo-36710: Add runtime variable to Py_InitializeEx() (GH-12939)Victor Stinner2019-04-242-3/+12
| | | | | | | | Py_InitializeEx() now uses a runtime variable passed to subfunctions, rather than working directly on the global variable _PyRuntime. Add 'runtime' parameter to _PyCoreConfig_Write(), _PySys_Create(), _PySys_InitMain(), _PyGILState_Init(), emit_stderr_warning_for_legacy_locale() and other subfunctions.
* bpo-36710: Add runtime variable to Py_FinalizeEx() (GH-12937)Victor Stinner2019-04-241-2/+4
| | | | | | * Add a 'runtime' variable to Py_FinalizeEx() rather than working directly on the global variable _PyRuntime * Add a 'runtime' parameter to _PyGC_Fini(), _PyGILState_Fini() and call_ll_exitfuncs()
* bpo-36710: PyOS_AfterFork_Child() pass runtime parameter (GH-12936)Victor Stinner2019-04-241-5/+7
| | | | | | | | | The PyOS_AfterFork_Child() function now pass a 'runtime' parameter to subfunctions. * Fix _PyRuntimeState_ReInitThreads(): use the correct memory allocator * Add runtime parameter to _PyRuntimeState_ReInitThreads(), _PyGILState_Reinit() and _PyInterpreterState_DeleteExceptMain() * Move _PyGILState_Reinit() to the internal C API.
* bpo-36710: Add runtime parameter to _PyThreadState_Init() (GH-12935)Victor Stinner2019-04-241-0/+5
| | | | | | * Add 'runtime' parameter to _PyThreadState_Init() * Add 'gilstate' parameter to _PyGILState_NoteThreadState() * Move _PyThreadState_Init() and _PyThreadState_DeleteExcept() to the internal C API.
* bpo-33608: Normalize atomic macros so that they all expect an atomic struct ↵Steve Dower2019-04-221-24/+36
| | | | (GH-12877)
* bpo-36635: Add _testinternalcapi module (GH-12841)Victor Stinner2019-04-181-0/+5
| | | | | | Add a new _testinternalcapi module to test the internal C API. Move _Py_GetConfigsAsDict() function to the internal C API: _testembed now uses _testinternalcapi to access the function.
* bpo-36635: Change pyport.h for Py_BUILD_CORE_MODULE define (GH-12853)Victor Stinner2019-04-1717-34/+34
| | | | | | | | | | | | | | | | | | | | Change PyAPI_FUNC(type), PyAPI_DATA(type) and PyMODINIT_FUNC macros of pyport.h when Py_BUILD_CORE_MODULE is defined. The Py_BUILD_CORE_MODULE define must be now be used to build a C extension as a dynamic library accessing Python internals: export the PyInit_xxx() function in DLL exports on Windows. Changes: * Py_BUILD_CORE_BUILTIN and Py_BUILD_CORE_MODULE now imply Py_BUILD_CORE directy in pyport.h. * ceval.c compilation now fails with an error if Py_BUILD_CORE is not defined, just to ensure that Python is build with the correct defines. * setup.py now compiles _pickle.c with Py_BUILD_CORE_MODULE define. * setup.py compiles _json.c with Py_BUILD_CORE_MODULE define, rather than Py_BUILD_CORE_BUILTIN define * PCbuild/pythoncore.vcxproj: Add Py_BUILD_CORE_BUILTIN define.
* bpo-36389: Add _PyObject_CheckConsistency() function (GH-12803)Victor Stinner2019-04-121-0/+4
| | | | | | Add a new _PyObject_CheckConsistency() function which can be used to help debugging. The function is available in release mode. Add a 'check_content' parameter to _PyDict_CheckConsistency().
* bpo-33608: Revert "Factor out a private, per-interpreter ↵Eric Snow2019-04-122-16/+5
| | | | | _Py_AddPendingCall()." (gh-12806) This reverts commit f13c5c8b9401a9dc19e95d8b420ee100ac022208 (gh-12360).
* bpo-33608: Factor out a private, per-interpreter _Py_AddPendingCall(). ↵Eric Snow2019-04-122-5/+16
| | | | | (gh-12360) This is effectively an un-revert of #11617 and #12024 (reverted in #12159). Portions of those were merged in other PRs (with lower risk) and this represents the remainder. Note that I found 3 different bugs in the original PRs and have fixed them here.
* bpo-36389: Change PyMem_SetupDebugHooks() constants (GH-12782)Victor Stinner2019-04-111-10/+9
| | | | | Modify CLEANBYTE, DEADDYTE and FORBIDDENBYTE constants: use 0xCD, 0xDD and 0xFD, rather than 0xCB, 0xBB and 0xFB, to use the same byte patterns than Windows CRT debug malloc() and free().
* bpo-36389: _PyObject_IsFreed() now also detects uninitialized memory (GH-12770)Victor Stinner2019-04-111-0/+25
| | | | | | | | | Replace _PyMem_IsFreed() function with _PyMem_IsPtrFreed() inline function. The function is now way more efficient, it became a simple comparison on integers, rather than a short loop. It detects also uninitialized bytes and "forbidden bytes" filled by debug hooks on memory allocators. Add unit tests on _PyObject_IsFreed().
* bpo-36444: Rework _Py_InitializeFromConfig() API (GH-12576)Victor Stinner2019-03-272-37/+43
|
* bpo-36444: Remove _PyMainInterpreterConfig (GH-12571)Victor Stinner2019-03-272-6/+0
|
* bpo-36301: Cleanup preconfig.c and coreconfig.c (GH-12563)Victor Stinner2019-03-261-28/+16
| | | | | | | | | | | | | | | * _PyCoreConfig_Write() now updates _PyRuntime.preconfig * Remove _PyPreCmdline_Copy() * _PyPreCmdline_Read() now accepts _PyPreConfig and _PyCoreConfig optional configurations. * Rename _PyPreConfig_ReadFromArgv() to _PyPreConfig_Read(). Simplify the code. * Calling _PyCoreConfig_Read() no longer adds the warning options twice: don't add a warning option if it's already in the list. * Rename _PyCoreConfig_ReadFromArgv() to _PyCoreConfig_Read(). * Rename config_from_cmdline() to _PyCoreConfig_ReadFromArgv(). * Add more assertions on _PyCoreConfig in _PyCoreConfig_Read(). * Move some functions. * Make some config functions private.
* bpo-36301: Remove _PyCoreConfig.preconfig (GH-12546)Victor Stinner2019-03-262-2/+7
| | | | | | * Replace _PyCoreConfig.preconfig with 3 new fields in _PyCoreConfig: isolated, use_environment, dev_mode. * Add _PyPreCmdline.dev_mode. * Add _Py_PreInitializeFromPreConfigInPlace().
* bpo-36301: Add _Py_GetEnv() function (GH-12542)Victor Stinner2019-03-251-11/+5
| | | | | * Make _PyPreConfig_GetEnv(), _PyCoreConfig_GetEnv() and _PyCoreConfig_GetEnvDup() private * _Py_get_env_flag() first parameter becomes "int use_environment"
* bpo-36301: Add _Py_GetConfigsAsDict() function (GH-12540)Victor Stinner2019-03-251-2/+6
| | | | | | | * Add _Py_GetConfigsAsDict() function to get all configurations as a dict. * dump_config() of _testembed.c now dumps preconfig as a separated key: call _Py_GetConfigsAsDict(). * Make _PyMainInterpreterConfig_AsDict() private.
* bpo-36301: Add _Py_PreInitializeFromConfig() (GH-12536)Victor Stinner2019-03-251-1/+13
| | | | | | | * Initialize _PyPreConfig.dev_mode to -1. * _PyPreConfig_Read(): coreconfig has the priority over preconfig. * _PyCoreConfig_Read() now calls _PyPreCmdline_Read() internally. * config_from_cmdline() now pass _PyPreCmdline to config_read(). * Add _PyPreCmdline_Copy().
* bpo-36301: Cleanup preconfig code (GH-12535)Victor Stinner2019-03-251-8/+7
| | | | | | | | | | | | | | | Prepare code to move some _PyPreConfig parameters into _PyPreCmdline. Changes: * _PyCoreConfig_ReadFromArgv(): remove preconfig parameter, use _PyRuntime.preconfig. * Add _PyPreCmdline_GetPreConfig() (called by _PyPreConfig_Read()). * Rename _PyPreCmdline_Init() to _PyPreCmdline_SetArgv() * Factorize _Py_PreInitializeFromPreConfig() code: add pyinit_preinit(). * _PyPreConfig_Read() now sets coerce_c_locale to 2 if it must be coerced. * Remove _PyCoreConfig_ReadPreConfig(). * _PyCoreConfig_Write() now copies updated preconfig into _PyRuntime.