summaryrefslogtreecommitdiff
path: root/Programs
Commit message (Collapse)AuthorAgeFilesLines
* bpo-35233: InitConfigTests tests more config vars (GH-10541) (GH-10546)Victor Stinner2018-11-141-3/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | test_embed.InitConfigTests tests more configuration variables. Changes: * InitConfigTests tests more core configuration variables: * base_exec_prefix * base_prefix * exec_prefix * home * module_search_path_env * prefix * "_testembed init_from_config" tests more variables: * argv * warnoptions * xoptions * Py_HasFileSystemDefaultEncoding value is no longer tested since it depends on the LC_CTYPE locale and the platform. * InitConfigTests: add check_global_config(), check_core_config() and check_main_config() subfunctions to cleanup the code. Move also constants at the class level (ex: COPY_MAIN_CONFIG). * Use more macros in _PyCoreConfig_AsDict() and _PyMainInterpreterConfig_AsDict() to reduce code duplication. * Other minor cleanups. (cherry picked from commit 01de89cb59107d4f889aa503a1c0350dae4aebaf)
* [3.7] bpo-35233: Rewrite test_embed.InitConfigTests (GH-10524) (GH-10529)Victor Stinner2018-11-141-74/+59
| | | | | | | | | | | | | | | | | | | | | * Add C functions: * _Py_GetGlobalVariablesAsDict() * _PyCoreConfig_AsDict() * _PyMainInterpreterConfig_AsDict() * Add new _testcapi methods: * get_global_config() * get_core_config() * get_main_config() * test.pythoninfo: get global, core and main configuration * _testembed now serializes global, core and main configurations using JSON to reuse _Py_GetGlobalVariablesAsDict(), _PyCoreConfig_AsDict() and _PyMainInterpreterConfig_AsDict(), rather than duplicating code. * test_embed.InitConfigTests now test much more configuration variables
* Revert "[3.7] bpo-34589: Add -X coerce_c_locale option; C locale coercion ↵Victor Stinner2018-09-192-4/+7
| | | | | off by default (GH-9379)" (GH-9416) This reverts commit 144f1e2c6f4a24bd288c045986842c65cc289684.
* [3.7] bpo-34589: Add -X coerce_c_locale option; C locale coercion off by ↵Victor Stinner2018-09-172-7/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | default (GH-9379) * bpo-34589: Make _PyCoreConfig.coerce_c_locale private (GH-9371) _PyCoreConfig: * Rename coerce_c_locale to _coerce_c_locale * Rename coerce_c_locale_warn to _coerce_c_locale_warn These fields are now private (name prefixed by "_"). (cherry picked from commit 188ebfa475a6f6aa2d0ea14ca8e1fbe7865b6d27) * bpo-34589: C locale coercion off by default (GH-9073) Py_Initialize() and Py_Main() cannot enable the C locale coercion (PEP 538) anymore: it is always disabled. It can now only be enabled by the Python program ("python3). test_embed: get_filesystem_encoding() doesn't have to set PYTHONUTF8 nor PYTHONCOERCECLOCALE, these variables are already set in the parent. (cherry picked from commit 7a0791b6992d420dc52536257f2f093851ed7215) * bpo-34589: Add -X coerce_c_locale command line option (GH-9378) Add a new -X coerce_c_locale command line option to control C locale coercion (PEP 538). (cherry picked from commit dbdee0073cf0b88fe541980ace1f650900f455cc)
* [3.7] bpo-34247: Fix Python 3.7 initialization (#8659)Victor Stinner2018-08-052-3/+304
| | | | | | | | | | | | | | | | | * -X dev: it is now possible to override the memory allocator using PYTHONMALLOC even if the developer mode is enabled. * Add _Py_InitializeFromConfig() * Add _Py_Initialize_ReadEnvVars() to set global configuration variables from environment variables * Fix the code to initialize Python: Py_Initialize() now also reads environment variables * _Py_InitializeCore() can now be called twice: the second call only replaces the configuration. * Write unit tests on Py_Initialize() and the different ways to configure Python * The isolated mode now always sets Py_IgnoreEnvironmentFlag and Py_NoUserSiteDirectory to 1. * pymain_read_conf() now saves/restores the configuration if the encoding changed
* bpo-34008: Allow to call Py_Main() after Py_Initialize() (GH-8043) (GH-8352)Miss Islington (bot)2018-07-211-0/+16
| | | | | | | | Py_Main() can again be called after Py_Initialize(), as in Python 3.6. The new configuration is ignored, except of _PyMainInterpreterConfig.argv which is used to update sys.argv. (cherry picked from commit fb47bca9ee2d07ce96df94b4e4abafd11826eb01) Co-authored-by: Victor Stinner <vstinner@redhat.com>
* bpo-33932: Calling Py_Initialize() twice does nothing (GH-7845)Miss Islington (bot)2018-06-221-0/+14
| | | | | | | Calling Py_Initialize() twice does nothing, instead of failing with a fatal error: restore the Python 3.6 behaviour. (cherry picked from commit 209abf746985526bce255e2fba97d3246924885d) Co-authored-by: Victor Stinner <vstinner@redhat.com>
* bpo-33182: Fix pointer types in _testembed (GH-6310) (GH-6311)Miss Islington (bot)2018-03-301-5/+7
| | | | | (cherry picked from commit 69f5c73311a61b05485b19626935bf240ad31c5b) Co-authored-by: Nick Coghlan <ncoghlan@gmail.com>
* bpo-33042: Fix pre-initialization sys module configuration (GH-6157)Miss Islington (bot)2018-03-251-2/+70
| | | | | | | | | | | - new test case for pre-initialization of sys.warnoptions and sys._xoptions - restored ability to call these APIs prior to Py_Initialize - updated the docs for the affected APIs to make it clear they can be called before Py_Initialize - also enhanced the existing embedding test cases to check for expected settings in the sys module (cherry picked from commit bc77eff8b96be4f035e665ab35c1d06e22f46491) Co-authored-by: Nick Coghlan <ncoghlan@gmail.com>
* bpo-31901: atexit callbacks should be run at subinterpreter shutdown (#4611)Marcel Plch2017-12-201-1/+0
| | | | Change atexit behavior and PEP-489 multiphase init support.
* bpo-32030: Fix compilation on FreeBSD, #include <fenv.h> (#4919)Victor Stinner2017-12-181-8/+0
| | | | | * main.c: add missing #include <fenv.h> on FreeBSD * indent also other #ifdef in main.c * cleanup Programs/python.c
* bpo-29240, bpo-32030: Py_Main() re-reads config if encoding changes (#4899)Victor Stinner2017-12-161-90/+1
| | | | | | | | | | | | | | | | | | bpo-29240, bpo-32030: If the encoding change (C locale coerced or UTF-8 Mode changed), Py_Main() now reads again the configuration with the new encoding. Changes: * Add _Py_UnixMain() called by main(). * Rename pymain_free_pymain() to pymain_clear_pymain(), it can now be called multipled times. * Rename pymain_parse_cmdline_envvars() to pymain_read_conf(). * Py_Main() now clears orig_argc and orig_argv at exit. * Remove argv_copy2, Py_Main() doesn't modify argv anymore. There is no need anymore to get two copies of the wchar_t** argv. * _PyCoreConfig: add coerce_c_locale and coerce_c_locale_warn. * Py_UTF8Mode is now initialized to -1. * Locale coercion (PEP 538) now respects -I and -E options.
* bpo-29240: PEP 540: Add a new UTF-8 Mode (#855)Victor Stinner2017-12-131-9/+14
| | | | | | | | | | | | | | | | | | | | | | * Add -X utf8 command line option, PYTHONUTF8 environment variable and a new sys.flags.utf8_mode flag. * If the LC_CTYPE locale is "C" at startup: enable automatically the UTF-8 mode. * Add _winapi.GetACP(). encodings._alias_mbcs() now calls _winapi.GetACP() to get the ANSI code page * locale.getpreferredencoding() now returns 'UTF-8' in the UTF-8 mode. As a side effect, open() now uses the UTF-8 encoding by default in this mode. * Py_DecodeLocale() and Py_EncodeLocale() now use the UTF-8 encoding in the UTF-8 Mode. * Update subprocess._args_from_interpreter_flags() to handle -X utf8 * Skip some tests relying on the current locale if the UTF-8 mode is enabled. * Add test_utf8mode.py. * _Py_DecodeUTF8_surrogateescape() gets a new optional parameter to return also the length (number of wide characters). * pymain_get_global_config() and pymain_set_global_config() now always copy flag values, rather than only copying if the new value is greater than the old value.
* bpo-20891: Fix PyGILState_Ensure() (#4650)Victor Stinner2017-11-301-0/+49
| | | | | | | When PyGILState_Ensure() is called in a non-Python thread before PyEval_InitThreads(), only call PyEval_InitThreads() after calling PyThreadState_New() to fix a crash. Add an unit test in test_embed.
* bpo-32030: Rework memory allocators (#4625)Victor Stinner2017-11-291-13/+6
| | | | | | | | | | | | | | | | | | | | * Fix _PyMem_SetupAllocators("debug"): always restore allocators to the defaults, rather than only caling _PyMem_SetupDebugHooks(). * Add _PyMem_SetDefaultAllocator() helper to set the "default" allocator. * Add _PyMem_GetAllocatorsName(): get the name of the allocators * main() now uses debug hooks on memory allocators if Py_DEBUG is defined, rather than calling directly malloc() * Document default memory allocators in C API documentation * _Py_InitializeCore() now fails with a fatal user error if PYTHONMALLOC value is an unknown memory allocator, instead of failing with a fatal internal error. * Add new tests on the PYTHONMALLOC environment variable * Add support.with_pymalloc() * Add the _testcapi.WITH_PYMALLOC constant and expose it as support.with_pymalloc(). * sysconfig.get_config_var('WITH_PYMALLOC') doesn't work on Windows, so replace it with support.with_pymalloc(). * pythoninfo: add _testcapi collector for pymem
* bpo-32096: Ensure new embedding test can find the encodings module (GH-4566)Nick Coghlan2017-11-261-1/+2
|
* bpo-32096: Remove obj and mem from _PyRuntime (#4532)Victor Stinner2017-11-241-0/+23
| | | | | | | | | | | | | | | | | bpo-32096, bpo-30860: Partially revert the commit 2ebc5ce42a8a9e047e790aefbf9a94811569b2b6: * Move structures back from Include/internal/mem.h to Objects/obmalloc.c * Remove _PyObject_Initialize() and _PyMem_Initialize() * Remove Include/internal/pymalloc.h * Add test_capi.test_pre_initialization_api(): Make sure that it's possible to call Py_DecodeLocale(), and then call Py_SetProgramName() with the decoded string, before Py_Initialize(). PyMem_RawMalloc() and Py_DecodeLocale() can be called again before _PyRuntimeState_Init(). Co-Authored-By: Eric Snow <ericsnowcurrently@gmail.com>
* bpo-32030: Split Py_Main() into subfunctions (#4399)Victor Stinner2017-11-152-4/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Don't use "Python runtime" anymore to parse command line options or to get environment variables: pymain_init() is now a strict separation. * Use an error message rather than "crashing" directly with Py_FatalError(). Limit the number of calls to Py_FatalError(). It prepares the code to handle errors more nicely later. * Warnings options (-W, PYTHONWARNINGS) and "XOptions" (-X) are now only added to the sys module once Python core is properly initialized. * _PyMain is now the well identified owner of some important strings like: warnings options, XOptions, and the "program name". The program name string is now properly freed at exit. pymain_free() is now responsible to free the "command" string. * Rename most methods in Modules/main.c to use a "pymain_" prefix to avoid conflits and ease debug. * Replace _Py_CommandLineDetails_INIT with memset(0) * Reorder a lot of code to fix the initialization ordering. For example, initializing standard streams now comes before parsing PYTHONWARNINGS. * Py_Main() now handles errors when adding warnings options and XOptions. * Add _PyMem_GetDefaultRawAllocator() private function. * Cleanup _PyMem_Initialize(): remove useless global constants: move them into _PyMem_Initialize(). * Call _PyRuntime_Initialize() as soon as possible: _PyRuntime_Initialize() now returns an error message on failure. * Add _PyInitError structure and following macros: * _Py_INIT_OK() * _Py_INIT_ERR(msg) * _Py_INIT_USER_ERR(msg): "user" error, don't abort() in that case * _Py_INIT_FAILED(err)
* bpo-28180: Fix the implementation of PEP 538 on Android (GH-4334)xdegaye2017-11-121-8/+1
|
* bpo-31877: Add _Py_LegacyLocaleDetected and _PyCoerceLegacyLocale to ↵Erik Bray2017-10-271-14/+10
| | | | | | | | pylifecycle.h (GH-4134) Only declaring these as interns inside the CLI's main C module caused build problems on some platforms (notably Cygwin), so this switches them to a regular underscore prefixed "private" C API declaration.
* bpo-31462: Remove trailing whitespaces. (#3564)Serhiy Storchaka2017-09-141-2/+2
|
* bpo-31370: Remove support for threads-less builds (#3385)Antoine Pitrou2017-09-071-6/+0
| | | | | | * Remove Setup.config * Always define WITH_THREAD for compatibility.
* bpo-28180: Implementation for PEP 538 (#659)Nick Coghlan2017-06-111-0/+37
| | | | | | | | | | - new PYTHONCOERCECLOCALE config setting - coerces legacy C locale to C.UTF-8, C.utf8 or UTF-8 by default - always uses C.UTF-8 on Android - uses `surrogateescape` on stdin and stdout in the coercion target locales - configure option to disable locale coercion at build time - configure option to disable C locale warning at build time
* bpo-30447: Fix/skip the subinterpreters test on some platforms. (#1791)Eric Snow2017-05-241-1/+1
|
* bpo-29102: Add a unique ID to PyInterpreterState. (#1639)Eric Snow2017-05-221-2/+7
|
* Issue #24932: Use proper command line parsing in _testembedSteve Dower2017-01-011-11/+44
|
* Fix some warnings from MSVCSteve Dower2016-09-061-1/+1
|
* Issue #27713: merge from 3.5Ned Deily2016-08-191-0/+1
|\
| * Issue #27713: Surpress spurious build warnings when updating importlib'sNed Deily2016-08-191-0/+1
| | | | | | | | | | | | | | bootstrap files: Could not find platform dependent libraries <exec_prefix Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] Patch by Xiang Zhang
* | Issue #27736: Improve the existing embedded interpreter init/fini testNed Deily2016-08-161-1/+1
| | | | | | | | | | | | by increasing the number of iterations. That appears sufficient to expose the ref count problem fixed in this issue. Patch suggested by Xiang Zhang
* | Merge doc and comment fixes from 3.5Martin Panter2016-04-191-1/+1
|\ \ | |/
| * Fix spelling (inital), grammar (may translates) in documentation, commentsMartin Panter2016-04-191-1/+1
| |
* | Add PYTHONMALLOC env varVictor Stinner2016-03-141-0/+9
|/ | | | | | | | | | | | | Issue #26516: * Add PYTHONMALLOC environment variable to set the Python memory allocators and/or install debug hooks. * PyMem_SetupDebugHooks() can now also be used on Python compiled in release mode. * The PYTHONMALLOCSTATS environment variable can now also be used on Python compiled in release mode. It now has no effect if set to an empty string. * In debug mode, debug hooks are now also installed on Python memory allocators when Python is configured without pymalloc.
* Replace fpgetmask() with fedisableexcept()Victor Stinner2016-01-201-6/+2
| | | | | Issue #24520: On FreeBSD, fpgetmask() was deprecated long time ago. fedisableexcept() is now preferred.
* Remove an unnecessary flag.Eric Snow2015-05-051-2/+0
|
* Issue #23911: Move path-based bootstrap code to a separate frozen module.Eric Snow2015-05-021-4/+16
|
* Issue #23752: _Py_fstat() is now responsible to raise the Python exceptionVictor Stinner2015-03-301-3/+3
| | | | Add _Py_fstat_noraise() function when a Python exception is not welcome.
* Silenced minor GCC warnings.Serhiy Storchaka2015-02-261-1/+1
|
* Issue #23152: Implement _Py_fstat() to support files larger than 2 GB on ↵Steve Dower2015-02-211-2/+2
| | | | | | Windows. fstat() may fail with EOVERFLOW on files larger than 2 GB because the file size type is an signed 32-bit integer.
* Issue #22934: Update the comment to mention Programs/_freeze_importlib.c.Berker Peksag2014-11-241-1/+1
|
* Issue #18395: Rename ``_Py_char2wchar()`` to :c:func:`Py_DecodeLocale`, renameVictor Stinner2014-08-011-1/+1
| | | | | ``_Py_wchar2char()`` to :c:func:`Py_EncodeLocale`, and document these functions.
* Issue #18093: Factor out the programs that embed the runtimeNick Coghlan2014-07-254-0/+362