summaryrefslogtreecommitdiffstats
path: root/Doc/c-api/init_config.rst
Commit message (Collapse)AuthorAgeFilesLines
* gh-101386: fix typos found by codespell (#101387)Peter Jiping Xie2023-01-281-2/+2
|
* Doc: Replace question mark with fullstop (#99558)Rafael Fontenelle2022-11-181-1/+1
| | | | The sentence "Set the LC_CTYPE locale to the user preferred locale." should end with a period instead of a question mark.
* gh-98608: Change _Py_NewInterpreter() to _Py_NewInterpreterFromConfig() ↵Eric Snow2022-10-261-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | (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.)
* gh-96512: Move int_max_str_digits setting to PyConfig (#96944)Gregory P. Smith2022-10-031-0/+18
| | | | | | | | | | | It had to live as a global outside of PyConfig for stable ABI reasons in the pre-3.12 backports. This removes the `_Py_global_config_int_max_str_digits` and gets rid of the equivalent field in the internal `struct _is PyInterpreterState` as code can just use the existing nested config struct within that. Adds tests to verify unique settings and configs in subinterpreters.
* gh-96143: Allow Linux perf profiler to see Python calls (GH-96123)Pablo Galindo Salgado2022-08-301-0/+14
| | | | | | | :warning: :warning: Note for reviewers, hackers and fellow systems/low-level/compiler engineers :warning: :warning: If you have a lot of experience with this kind of shenanigans and want to improve the **first** version, **please make a PR against my branch** or **reach out by email** or **suggest code changes directly on GitHub**. If you have any **refinements or optimizations** please, wait until the first version is merged before starting hacking or proposing those so we can keep this PR productive.
* Doc: Update references and examples of old, unsupported OSes and uarches ↵CAM Gerlach2022-06-091-3/+2
| | | | (GH-92791)
* gh-93103: Enhance PyConfig.parser_debug documentation (#93186)Victor Stinner2022-05-241-0/+3
| | | | Document that -d option and PYTHONDEBUG env var require a debug build of Python. Also mention them in the debug build documentation.
* gh-92913: Fix typos in documentation (GH-93129)Steve Dower2022-05-231-3/+3
|
* gh-93103: Deprecate global configuration variable (#93104)Victor Stinner2022-05-231-7/+10
| | | | | Deprecate global configuration variables, like Py_IgnoreEnvironmentFlag, in the documentation: the Py_InitializeFromConfig() API should be instead.
* gh-92913: Clarify changes to PyInitConfig.module_search_paths[_set] fields ↵Steve Dower2022-05-191-4/+16
| | | | (GH-92980)
* Enhance PyConfig documentation (#92394)Victor Stinner2022-05-091-37/+46
|
* gh-57684: Add -P cmdline option and PYTHONSAFEPATH env var (#31542)Victor Stinner2022-05-051-9/+37
| | | | | | | | | | | | Add the -P command line option and the PYTHONSAFEPATH environment variable to not prepend a potentially unsafe path to sys.path. * Add sys.flags.safe_path flag. * Add PyConfig.safe_path member. * Programs/_bootstrap_python.c uses config.safe_path=0. * Update subprocess._optim_args_from_interpreter_flags() to handle the -P command line option. * Modules/getpath.py sets safe_path to 1 if a "._pth" file is present.
* More minor fixes to C API docs (GH-31714)Jelle Zijlstra2022-04-021-4/+4
| | | | | | | * init_config: wording fixes * bytearray: remove XXX, there is a good link to the buffer docs * bytes, call, exceptions: minor wording fixes
* no-issue: Fix documentation typos. (GH-30576)Piotr Fusik2022-01-201-1/+1
|
* bpo-45582: Port getpath[p].c to Python (GH-29041)Steve Dower2021-12-031-13/+28
| | | | | The getpath.py file is frozen at build time and executed as code over a namespace. It is never imported, nor is it meant to be importable or reusable. However, it should be easier to read, modify, and patch than the previous code. This commit attempts to preserve every previously tested quirk, but these may be changed in the future to better align platforms.
* bpo-45954: Rename PyConfig.no_debug_ranges to code_debug_ranges (GH-29886)Victor Stinner2021-12-021-3/+6
| | | | | | | Rename PyConfig.no_debug_ranges to PyConfig.code_debug_ranges and invert the value. Document -X no_debug_ranges and PYTHONNODEBUGRANGES env var in PyConfig.code_debug_ranges documentation.
* [doc] Fix typos found using codespell (GH-28744)Christian Clauss2021-10-051-2/+2
| | | Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* bpo-43950: Add option to opt-out of PEP-657 (GH-27023)Ammar Askar2021-07-071-0/+10
| | | | | Co-authored-by: Pablo Galindo <Pablogsal@gmail.com> Co-authored-by: Batuhan Taskaya <batuhanosmantaskaya@gmail.com> Co-authored-by: Ammar Askar <ammar@ammaraskar.com>
* bpo-44441: _PyImport_Fini2() resets PyImport_Inittab (GH-26874)Victor Stinner2021-06-231-1/+4
| | | | | Py_RunMain() now resets PyImport_Inittab to its initial value at exit. It must be possible to call PyImport_AppendInittab() or PyImport_ExtendInittab() at each Python initialization.
* bpo-43774: Remove unused PYMALLOC_DEBUG macro (GH-25711)Victor Stinner2021-04-291-8/+11
| | | Enhance also the documentation of debug hooks on memory allocators.
* bpo-43862: Enhance -W cmdline option documentation (GH-25439)Victor Stinner2021-04-161-0/+7
| | | | | The -W format is "action:message:category:module:lineno". Update also the Python manual page.
* bpo-43774: Add more links to configure options (GH-25363)Victor Stinner2021-04-121-4/+4
|
* Fix Sphinx errors in the documentation and re-activate the suspicious check ↵Pablo Galindo2021-04-121-1/+1
| | | | | | | (GH-25368) The suspicious check is still executed as part of the release process and release managers have been lately fixing some actual errors that the suspicious target can find. For this reason, reactivate the suspicious until we decide what to do in a coordinated fashion.
* bpo-43774: Document configure options (GH-25283)Victor Stinner2021-04-081-7/+12
| | | | | | Add Doc/using/configure.rst documentation to document configure, preprocessor, compiler and linker options. Add a new section about the "Python debug build".
* bpo-43510: Implement PEP 597 opt-in EncodingWarning. (GH-19481)Inada Naoki2021-03-291-0/+9
| | | | | | | | | | | See [PEP 597](https://www.python.org/dev/peps/pep-0597/). * Add `-X warn_default_encoding` and `PYTHONWARNDEFAULTENCODING`. * Add EncodingWarning * Add io.text_encoding() * open(), TextIOWrapper() emits EncodingWarning when encoding is omitted and warn_default_encoding is enabled. * _pyio.TextIOWrapper() uses UTF-8 as fallback default encoding used when failed to import locale module. (used during building Python) * bz2, configparser, gzip, lzma, pathlib, tempfile modules use io.text_encoding(). * What's new entry
* bpo-42260: Fix _PyConfig_Read() if compute_path_config=0 (GH-23220)Victor Stinner2020-11-101-17/+21
| | | | | | | | | | | | | | | | | | | Fix _PyConfig_Read() if compute_path_config=0: use values set by Py_SetPath(), Py_SetPythonHome() and Py_SetProgramName(). Add compute_path_config parameter to _PyConfig_InitPathConfig(). The following functions now return NULL if called before Py_Initialize(): * Py_GetExecPrefix() * Py_GetPath() * Py_GetPrefix() * Py_GetProgramFullPath() * Py_GetProgramName() * Py_GetPythonHome() These functions no longer automatically computes the Python Path Configuration. Moreover, Py_SetPath() no longer computes program_full_path.
* bpo-42260: PyConfig_Read() only parses argv once (GH-23168)Victor Stinner2020-11-051-92/+104
| | | | | | | | | | | | The PyConfig_Read() function now only parses PyConfig.argv arguments once: PyConfig.parse_argv is set to 2 after arguments are parsed. Since Python arguments are strippped from PyConfig.argv, parsing arguments twice would parse the application options as Python options. * Rework the PyConfig documentation. * Fix _testinternalcapi.set_config() error handling. * SetConfigTests no longer needs parse_argv=0 when restoring the old configuration.
* bpo-42260: Add _PyInterpreterState_SetConfig() (GH-23158)Victor Stinner2020-11-041-0/+2
| | | | | | | | * Inline _PyInterpreterState_SetConfig(): replace it with _PyConfig_Copy(). * Add _PyErr_SetFromPyStatus() * Add _PyInterpreterState_GetConfigCopy() * Add a new _PyInterpreterState_SetConfig() function. * Add an unit which gets, modifies, and sets the config.
* bpo-42236: Enhance init and encoding documentation (GH-23109)Victor Stinner2020-11-021-126/+463
| | | | | | | | | | | | | | | | | | | | | Enhance the documentation of the Python startup, filesystem encoding and error handling, locale encoding. Add a new "Python UTF-8 Mode" section. * Add "locale encoding" and "filesystem encoding and error handler" to the glossary * Remove documentation from Include/cpython/initconfig.h: move it to Doc/c-api/init_config.rst. * Doc/c-api/init_config.rst: * Document command line options and environment variables * Document default values. * Add a new "Python UTF-8 Mode" section in Doc/library/os.rst. * Add warnings to Py_DecodeLocale() and Py_EncodeLocale() docs. * Document how Python selects the filesystem encoding and error handler at a single place: PyConfig.filesystem_encoding and PyConfig.filesystem_errors. * PyConfig: move orig_argv member at the right place.
* bpo-42236: Use UTF-8 encoding if nl_langinfo(CODESET) fails (GH-23086)Victor Stinner2020-11-011-5/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the nl_langinfo(CODESET) function returns an empty string, Python now uses UTF-8 as the filesystem encoding. In May 2010 (commit b744ba1d14c5487576c95d0311e357b707600b47), I modified Python to log a warning and use UTF-8 as the filesystem encoding (instead of None) if nl_langinfo(CODESET) returns an empty string. In August 2020 (commit 94908bbc1503df830d1d615e7b57744ae1b41079), I modified Python startup to fail with a fatal error and a specific error message if nl_langinfo(CODESET) returns an empty string. The intent was to prevent guessing the encoding and also investigate user configuration where this case happens. In 10 years (2010 to 2020), I saw zero user report about the error message related to nl_langinfo(CODESET) returning an empty string. Today, UTF-8 became the defacto standard and it's safe to make the assumption that the user expects UTF-8. For example, nl_langinfo(CODESET) can return an empty string on macOS if the LC_CTYPE locale is not supported, and UTF-8 is the default encoding on macOS. While this change is likely to not affect anyone in practice, it should make UTF-8 lover happy ;-) Rewrite also the documentation explaining how Python selects the filesystem encoding and error handler.
* Doc: Minor fix to init config C API documentation (GH-21198)tomerv2020-07-011-2/+2
| | | Co-authored-by: Tomer Vromen <tomer.vromen@intel.com>
* bpo-23427: Add sys.orig_argv attribute (GH-20729)Victor Stinner2020-06-291-0/+21
| | | | | | | Add sys.orig_argv attribute: the list of the original command line arguments passed to the Python executable. Rename also PyConfig._orig_argv to PyConfig.orig_argv and document it.
* bpo-40939: Remove the old parser (GH-20768)Pablo Galindo2020-06-111-10/+0
| | | This commit removes the old parser, the deprecated parser module, the old parser compatibility flags and environment variables and all associated support code and documentation.
* bpo-40854: PYTHONPLATLIBDIR env var added to 3.9 (GH-20735)Victor Stinner2020-06-081-1/+1
|
* bpo-40910: Export Py_GetArgcArgv() function (GH-20721)Victor Stinner2020-06-081-0/+9
| | | | | | | | | | | | Export explicitly the Py_GetArgcArgv() function to the C API and document the function. Previously, it was exported implicitly which no longer works since Python is built with -fvisibility=hidden. * Add PyConfig._orig_argv member. * Py_InitializeFromConfig() no longer calls _PyConfig_Write() twice. * PyConfig_Read() no longer initializes Py_GetArgcArgv(): it is now _PyConfig_Write() responsibility. * _PyConfig_Write() result type becomes PyStatus instead of void. * Write an unit test on Py_GetArgcArgv().
* bpo-40854: Allow overriding sys.platlibdir via PYTHONPLATLIBDIR env-var ↵Sandro Mani2020-06-081-0/+9
| | | | (GH-20605)
* bpo-40453: Add PyConfig._isolated_subinterpreter (GH-19820)Victor Stinner2020-05-011-0/+2
| | | | | | | | | An isolated subinterpreter cannot spawn threads, spawn a child process or call os.fork(). * Add private _Py_NewInterpreter(isolated_subinterpreter) function. * Add isolated=True keyword-only parameter to _xxsubinterpreters.create(). * Allow again os.fork() in "non-isolated" subinterpreters.
* bpo-40334: Rename PyConfig.use_peg to _use_peg_parser (GH-19670)Victor Stinner2020-04-231-0/+10
| | | | | | | | | | | * Rename PyConfig.use_peg to _use_peg_parser * Document PyConfig._use_peg_parser and mark it a deprecated * Mark -X oldparser option and PYTHONOLDPARSER env var as deprecated in the documentation. * Add use_old_parser() and skip_if_new_parser() to test.support * Remove sys.flags.use_peg: use_old_parser() uses _testinternalcapi.get_configs() instead. * Enhance test_embed tests * subprocess._args_from_interpreter_flags() copies -X oldparser
* bpo-36465: Update doc of init_config.rst (GH-18520)Hai Shi2020-02-171-1/+1
|
* bpo-39489: Remove COUNT_ALLOCS special build (GH-18259)Victor Stinner2020-02-031-8/+4
| | | | | | | | | | | Remove: * COUNT_ALLOCS macro * sys.getcounts() function * SHOW_ALLOC_COUNT code in listobject.c * SHOW_TRACK_COUNT code in tupleobject.c * PyConfig.show_alloc_count field * -X showalloccount command line option * @test.support.requires_type_collecting decorator
* bpo-39429: Add a new "Python Development Mode" doc page (GH-18132)Victor Stinner2020-01-241-1/+1
|
* bpo-39136: Fixed typos (GH-17720)Gurupad Hegde2019-12-281-1/+1
| | | | | funtion -> function; configuraton -> configuration; defintitions -> definitions; focusses -> focuses; necesarily -> necessarily; follwing -> following; Excape -> Escape,
* bpo-38600: NULL -> ``NULL``. (GH-17001)Serhiy Storchaka2019-10-301-3/+3
| | | Also fix some other formatting.
* bpo-38304: PyConfig_InitPythonConfig() cannot fail anymore (GH-16509)Victor Stinner2019-10-011-25/+10
| | | | PyConfig_InitPythonConfig() and PyConfig_InitIsolatedConfig() no longer return PyStatus: they cannot fail anymore.
* bpo-38304: Remove PyConfig.struct_size (GH-16500) (GH-16508)Victor Stinner2019-10-011-36/+3
| | | | | | | For now, we'll rely on the fact that the config structures aren't covered by the stable ABI. We may revisit this in the future if we further explore the idea of offering a stable embedding API. (cherry picked from commit bdace21b769998396d0ccc8da99a8ca9b507bfdf)
* bpo-38317: Fix PyConfig.warnoptions priority (GH-16478)Victor Stinner2019-09-291-1/+7
| | | | | | | | | Fix warnings options priority: PyConfig.warnoptions has the highest priority, as stated in the PEP 587. * Document options order in PyConfig.warnoptions documentation. * Make PyWideStringList_INIT macro private: replace "Py" prefix with "_Py". * test_embed: add test_init_warnoptions().
* bpo-38304: Add PyConfig.struct_size (GH-16451)Victor Stinner2019-09-281-5/+39
| | | | | | | | | | | | | | | | | Add a new struct_size field to PyPreConfig and PyConfig structures to allow to modify these structures in the future without breaking the backward compatibility. * Replace private _config_version field with public struct_size field in PyPreConfig and PyConfig. * Public PyPreConfig_InitIsolatedConfig() and PyPreConfig_InitPythonConfig() return type becomes PyStatus, instead of void. * Internal _PyConfig_InitCompatConfig(), _PyPreConfig_InitCompatConfig(), _PyPreConfig_InitFromConfig(), _PyPreConfig_InitFromPreConfig() return type becomes PyStatus, instead of void. * Remove _Py_CONFIG_VERSION * Update the Initialization Configuration documentation.
* bpo-38234: Complete init config documentation (GH-16404)Victor Stinner2019-09-261-23/+37
|
* bpo-38234: Add test_init_setpath_config() to test_embed (GH-16402)Victor Stinner2019-09-261-5/+14
| | | | | | | | | | | | * Add test_embed.test_init_setpath_config(): test Py_SetPath() with PyConfig. * test_init_setpath() and test_init_setpythonhome() no longer call Py_SetProgramName(), but use the default program name. * _PyPathConfig: isolated, site_import and base_executable fields are now only available on Windows. * If executable is set explicitly in the configuration, ignore calculated base_executable: _PyConfig_InitPathConfig() copies executable to base_executable. * Complete path config documentation.
* bpo-38236: Dump path config at first import error (GH-16300)Victor Stinner2019-09-231-1/+11
| | | | Python now dumps path configuration if it fails to import the Python codecs of the filesystem and stdio encodings.