summaryrefslogtreecommitdiffstats
path: root/Modules
Commit message (Collapse)AuthorAgeFilesLines
* Fix GCC warning in _asynciomodule.c (#4928)Zackery Spytz2017-12-191-1/+1
|
* bpo-26439 Fix ctypes.util.find_library failure on AIX (#4507)Michael Felt2017-12-191-0/+3
| | | | | Implement find_library() support in ctypes/util for AIX. Add some AIX specific tests.
* bpo-32357: Optimize asyncio.iscoroutine() for non-native coroutines (#4915)Yury Selivanov2017-12-191-28/+85
|
* bpo-32030: Fix compiler warnings (#4921)Victor Stinner2017-12-191-22/+3
| | | | | | | | | | | Fix compiler warnings in Py_FinalizeEx(): only define variables if they are needed, add #ifdef. Other cleanup changes: * _PyWarnings_InitWithConfig() is no more needed: call _PyWarnings_Init() instead. * Inline pymain_init_main_interpreter() in its caller. This subfunction is no more justifed.
* bpo-32331: Fix socket.type when SOCK_NONBLOCK is available (#4877)Yury Selivanov2017-12-191-6/+15
|
* bpo-32030: Fix compilation on FreeBSD, #include <fenv.h> (#4919)Victor Stinner2017-12-181-10/+14
| | | | | * main.c: add missing #include <fenv.h> on FreeBSD * indent also other #ifdef in main.c * cleanup Programs/python.c
* bpo-19764: Implemented support for subprocess.Popen(close_fds=True) on ↵Segev Finer2017-12-182-24/+260
| | | | | | | | | | | | | | | | | Windows (#1218) Even though Python marks any handles it opens as non-inheritable there is still a race when using `subprocess.Popen` since creating a process with redirected stdio requires temporarily creating inheritable handles. By implementing support for `subprocess.Popen(close_fds=True)` we fix this race. In order to implement this we use PROC_THREAD_ATTRIBUTE_HANDLE_LIST which is available since Windows Vista. Which allows to pass an explicit list of handles to inherit when creating a process. This commit also adds `STARTUPINFO.lpAttributeList["handle_list"]` which can be used to control PROC_THREAD_ATTRIBUTE_HANDLE_LIST directly.
* bpo-30050: Allow disabling full buffer warnings in signal.set_wakeup_fd (#4792)Nathaniel J. Smith2017-12-181-53/+51
|
* bpo-32348: Optimize asyncio.Future schedule/add/remove callback. (#4907)Yury Selivanov2017-12-181-75/+322
|
* bpo-32250: Implement asyncio.current_task() and asyncio.all_tasks() (#4799)Andrew Svetlov2017-12-162-111/+399
|
* Add tests for using PEP560 with classes implemented in C. (#4883)Serhiy Storchaka2017-12-161-0/+85
| | | Based on tests from #4878
* bpo-29240, bpo-32030: Py_Main() re-reads config if encoding changes (#4899)Victor Stinner2017-12-162-54/+248
| | | | | | | | | | | | | | | | | | 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-32240: Add the const qualifier to declarations of PyObject* array ↵Serhiy Storchaka2017-12-1554-466/+466
| | | | arguments. (#4746)
* move pygetopt.h to internal (closes bpo-32264) (#4830)Benjamin Peterson2017-12-151-2/+1
|
* bpo-32311: Implement asyncio.create_task() shortcut (#4848)Andrew Svetlov2017-12-151-1/+28
| | | | | * Implement functionality * Add documentation
* bpo-32030: Add _PyMainInterpreterConfig.executable (#4876)Victor Stinner2017-12-151-19/+50
| | | | | | | | | | | | * Add new fields to _PyMainInterpreterConfig: * executable * prefix * base_prefix * exec_prefix * base_exec_prefix * _PySys_EndInit() now sets sys attributes from _PyMainInterpreterConfig
* bpo-32030: Add _PyCoreConfig_Copy() (#4874)Victor Stinner2017-12-151-0/+148
| | | | | | | | | | Each interpreter now has its core_config and main_config copy: * Add _PyCoreConfig_Copy() and _PyMainInterpreterConfig_Copy() * Move _PyCoreConfig_Read(), _PyCoreConfig_Clear() and _PyMainInterpreterConfig_Clear() from Python/pylifecycle.c to Modules/main.c * Fix _Py_InitializeEx_Private(): call _PyCoreConfig_ReadEnv() before _Py_InitializeCore()
* bpo-32329: Fix -R option for hash randomization (#4873)Victor Stinner2017-12-141-7/+28
| | | | | | | | | | | | bpo-32329, bpo-32030: * The -R option now turns on hash randomization when the PYTHONHASHSEED environment variable is set to 0 Previously, the option was ignored. * sys.flags.hash_randomization is now properly set to 0 when hash randomization is turned off by PYTHONHASHSEED=0. * _PyCoreConfig_ReadEnv() now reads the PYTHONHASHSEED environment variable. _Py_HashRandomization_Init() now only apply the configuration, it doesn't read PYTHONHASHSEED anymore.
* bpo-32143: add f_fsid to os.statvfs() (#4571)Giuseppe Scrivano2017-12-141-0/+2
| | | Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
* bpo-32277: Fix exception raised from chmod(..., follow_symlinks=False) (#4797)Anthony Sottile2017-12-141-0/+1
|
* bpo-32030: Add _PyMainInterpreterConfig.warnoptions (#4855)Victor Stinner2017-12-141-40/+84
| | | Add warnoptions and xoptions fields to _PyMainInterpreterConfig.
* bpo-32297: Few misspellings found in Python source code comments. (#4803)Mike2017-12-141-1/+1
| | | | | | | | * Fix multiple typos in code comments * Add spacing in comments (test_logging.py, test_math.py) * Fix spaces at the beginning of comments in test_logging.py
* bpo-32030: Rewrite _PyMainInterpreterConfig (#4854)Victor Stinner2017-12-142-129/+211
| | | | | | | | | | | | | | | | | | | | _PyMainInterpreterConfig now contains Python objects, whereas _PyCoreConfig contains wchar_t* strings. Core config: * Rename _PyMainInterpreterConfig_ReadEnv() to _PyCoreConfig_ReadEnv() * Move 3 strings from _PyMainInterpreterConfig to _PyCoreConfig: module_search_path_env, home, program_name. * Add _PyCoreConfig_Clear() * _PyPathConfig_Calculate() now takes core config rather than main config * _PyMainInterpreterConfig_Read() now requires also a core config Main config: * Add _PyMainInterpreterConfig.module_search_path: sys.path list * Add _PyMainInterpreterConfig.argv: sys.argv list * _PyMainInterpreterConfig_Read() now computes module_search_path
* bpo-32030: Add _PyPathConfig_ComputeArgv0() (#4845)Victor Stinner2017-12-131-16/+91
| | | | | | | | | | | | | | | | Changes: * Split _PySys_SetArgvWithError() into subfunctions for Py_Main(): * Create the Python list object * Set sys.argv to the list * Compute argv0 * Prepend argv0 to sys.path * Add _PyPathConfig_ComputeArgv0() * Remove _PySys_SetArgvWithError() * Py_Main() now splits the code to compute sys.argv/path0 and the code to update the sys module: add pymain_compute_argv() subfunction.
* bpo-32296: Implement asyncio.get_event_loop and _get_running_loop in C. (#4827)Yury Selivanov2017-12-132-8/+323
| | | | | | | | asyncio.get_event_loop(), and, subsequently asyncio._get_running_loop() are one of the most frequently executed functions in asyncio. They also can't be sped up by third-party event loops like uvloop. When implemented in C they become 4x faster.
* pymain_set_sys_argv() now copies argv (#4838)Victor Stinner2017-12-131-28/+58
| | | | | | | | | | bpo-29240, bpo-32030: * Rename pymain_set_argv() to pymain_set_sys_argv() * pymain_set_sys_argv() now creates of copy of argv and modify the copy, rather than modifying pymain->argv * Call pymain_set_sys_argv() earlier: before pymain_run_python(), but after pymain_get_importer(). * Add _PySys_SetArgvWithError() to handle errors
* bpo-29240: PEP 540: Add a new UTF-8 Mode (#855)Victor Stinner2017-12-133-56/+129
| | | | | | | | | | | | | | | | | | | | | | * 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-17852: Revert incorrect fix based on misunderstanding of _Py_PyAtExit() ↵Antoine Pitrou2017-12-133-54/+1
| | | | semantics (#4826)
* bpo-32230: Set sys.warnoptions with -X dev (#4820)Victor Stinner2017-12-121-0/+66
| | | | | | | | | | | | | | Rather than supporting dev mode directly in the warnings module, this instead adjusts the initialisation code to add an extra 'default' entry to sys.warnoptions when dev mode is enabled. This ensures that dev mode behaves *exactly* as if `-Wdefault` had been passed on the command line, including in the way it interacts with `sys.warnoptions`, and with other command line flags like `-bb`. Fix also bpo-20361: have -b & -bb options take precedence over any other warnings options. Patch written by Nick Coghlan, with minor modifications of Victor Stinner.
* bpo-32241: Add the const qualifire to declarations of umodifiable strings. ↵Serhiy Storchaka2017-12-123-25/+25
| | | | (#4748)
* bpo-32255: Always quote a single empty field when write into a CSV file. (#4769)Licht Takeuchi2017-12-121-1/+1
| | | This allows to distinguish an empty row from a row consisting of a single empty field.
* bpo-32252: Fix faulthandler_suppress_crash_report() (#4794)Victor Stinner2017-12-111-1/+1
| | | | Fix faulthandler_suppress_crash_report() used to prevent core dump files when testing crashes. getrlimit() returns zero on success.
* closes bpo-31650: PEP 552 (Deterministic pycs) implementation (#4575)Benjamin Peterson2017-12-092-4/+43
| | | | | | | | | | | | | | | | | | | | | | | | | Python now supports checking bytecode cache up-to-dateness with a hash of the source contents rather than volatile source metadata. See the PEP for details. While a fairly straightforward idea, quite a lot of code had to be modified due to the pervasiveness of pyc implementation details in the codebase. Changes in this commit include: - The core changes to importlib to understand how to read, validate, and regenerate hash-based pycs. - Support for generating hash-based pycs in py_compile and compileall. - Modifications to our siphash implementation to support passing a custom key. We then expose it to importlib through _imp. - Updates to all places in the interpreter, standard library, and tests that manually generate or parse pyc files to grok the new format. - Support in the interpreter command line code for long options like --check-hash-based-pycs. - Tests and documentation for all of the above.
* bpo-32030: Add _PyImport_Fini2() (#4737)Victor Stinner2017-12-061-18/+26
| | | | | | | | | | | | | | | | | | | | | PyImport_ExtendInittab() now uses PyMem_RawRealloc() rather than PyMem_Realloc(). PyImport_ExtendInittab() can be called before Py_Initialize() whereas only the PyMem_Raw allocator is supposed to be used before Py_Initialize(). Add _PyImport_Fini2() to release the memory allocated by PyImport_ExtendInittab() at exit. PyImport_ExtendInittab() now forces the usage of the default raw allocator, to be able to release memory in _PyImport_Fini2(). Don't export these functions anymore to be C API, only to Py_BUILD_CORE: * _PyExc_Fini() * _PyImport_Fini() * _PyGC_DumpShutdownStats() * _PyGC_Fini() * _PyType_Fini() * _Py_HashRandomization_Fini()
* bpo-32030: Add pymain_get_global_config() (#4735)Victor Stinner2017-12-061-57/+113
| | | | | | | | | | | | | * Py_Main() now starts by reading Py_xxx configuration variables to only work on its own private structure, and then later writes back the configuration into these variables. * Replace Py_GETENV() with pymain_get_env_var() which ignores empty variables. * Add _PyCoreConfig.dump_refs * Add _PyCoreConfig.malloc_stats * _PyObject_DebugMallocStats() is now responsible to check if debug hooks are installed. The function returns 1 if stats were written, or 0 if the hooks are disabled. Mark _PyMem_PymallocEnabled() as static.
* bpo-32030: Simplify _PyCoreConfig_INIT macro (#4728)Victor Stinner2017-12-051-9/+3
| | | | | | | * Simplify _PyCoreConfig_INIT, _PyMainInterpreterConfig_INIT, _PyPathConfig_INIT macros: no need to set fields to 0/NULL, it's redundant (the C language sets them to 0/NULL for us). * Fix typo: pymain_run_statup() => pymain_run_startup() * Remove a few XXX/TODO
* Revert "bpo-32197: Try to fix a compiler error on OS X introduced in ↵Victor Stinner2017-12-042-209/+109
| | | | | | | | | | | | | | | | | | | | | | | bpo-32030. (#4681)" (#4694) * Revert "bpo-32197: Try to fix a compiler error on OS X introduced in bpo-32030. (#4681)" This reverts commit 13badcbc60cdbfae1dba1683fd2fae9d70717143. Re-apply commits: * "bpo-32030: _PyPathConfig_Init() sets home and program_name (#4673)" commit af5a895073c24637c094772b27526b94a12ec897. * "bpo-32030: Fix config_get_program_name() on macOS (#4669)" commit e23c06e2b03452c9aaf0dae52296c85e572f9bcd. * "bpo-32030: Add Python/pathconfig.c (#4668)" commit 0ea395ae964c9cd0f499e2ef0d0030c971201220. * "bpo-32030: Don't call _PyPathConfig_Fini() in Py_FinalizeEx() (#4667)" commit ebac19dad6263141d5db0a2c923efe049dba99d2. * "bpo-32030: Fix Py_GetPath(): init program_name (#4665)" commit 9ac3d8882712c9675c3d2f9f84af6b5729575cde. * Fix compilation error on macOS
* bpo-25054, bpo-1647489: Added support of splitting on zerowidth patterns. ↵Serhiy Storchaka2017-12-043-73/+55
| | | | | | (#4471) Also fixed searching patterns that could match an empty string.
* bpo-32197: Try to fix a compiler error on OS X introduced in bpo-32030. (#4681)Serhiy Storchaka2017-12-022-109/+209
| | | | | | | | | | | | | | | | | | | | | | * Revert "bpo-32030: _PyPathConfig_Init() sets home and program_name (#4673)" This reverts commit af5a895073c24637c094772b27526b94a12ec897. * Revert "bpo-32030: Fix config_get_program_name() on macOS (#4669)" This reverts commit e23c06e2b03452c9aaf0dae52296c85e572f9bcd. * Revert "bpo-32030: Add Python/pathconfig.c (#4668)" This reverts commit 0ea395ae964c9cd0f499e2ef0d0030c971201220. * Revert "bpo-32030: Don't call _PyPathConfig_Fini() in Py_FinalizeEx() (#4667)" This reverts commit ebac19dad6263141d5db0a2c923efe049dba99d2. * Revert "bpo-32030: Fix Py_GetPath(): init program_name (#4665)" This reverts commit 9ac3d8882712c9675c3d2f9f84af6b5729575cde.
* bpo-32030: _PyPathConfig_Init() sets home and program_name (#4673)Victor Stinner2017-12-022-31/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | _PyPathConfig_Init() now also initialize home and program_name: * Rename existing _PyPathConfig_Init() to _PyPathConfig_Calculate(). Add a new _PyPathConfig_Init() function in pathconfig.c which handles the _Py_path_config variable and call _PyPathConfig_Calculate(). * Add home and program_name fields to _PyPathConfig.home * _PyPathConfig_Init() now initialize home and program_name from main_config * Py_SetProgramName(), Py_SetPythonHome() and Py_GetPythonHome() now calls Py_FatalError() on failure, instead of silently ignoring failures. * config_init_home() now gets directly _Py_path_config.home to only get the value set by Py_SetPythonHome(), or NULL if Py_SetPythonHome() was not called. * config_get_program_name() now gets directly _Py_path_config.program_name to only get the value set by Py_SetProgramName(), or NULL if Py_SetProgramName() was not called. * pymain_init_python() doesn't call Py_SetProgramName() anymore, _PyPathConfig_Init() now always sets the program name * Call _PyMainInterpreterConfig_Read() in pymain_parse_cmdline_envvars_impl() to control the memory allocator * C API documentation: it's no more safe to call Py_GetProgramName() before Py_Initialize().
* bpo-32030: Fix config_get_program_name() on macOS (#4669)Victor Stinner2017-12-011-2/+2
|
* bpo-32030: Add Python/pathconfig.c (#4668)Victor Stinner2017-12-012-116/+4
| | | | | | | * Factorize code from PC/getpathp.c and Modules/getpath.c to remove duplicated code * rename pathconfig_clear() to _PyPathConfig_Clear() * Inline _PyPathConfig_Fini() in pymain_impl() and then remove it, since it's a oneliner
* bpo-32030: Don't call _PyPathConfig_Fini() in Py_FinalizeEx() (#4667)Victor Stinner2017-12-012-16/+24
| | | | | | | | | | | | | | | Changes: * _PyPathConfig_Fini() cannot be called in Py_FinalizeEx(). Py_Initialize() and Py_Finalize() can be called multiple times, but it must not "forget" parameters set by Py_SetProgramName(), Py_SetPath() or Py_SetPythonHome(), whereas _PyPathConfig_Fini() clear all these parameters. * config_get_program_name() and calculate_program_full_path() now also decode paths using Py_DecodeLocale() to use the surrogateescape error handler, rather than decoding using mbstowcs() which is strict. * Change _Py_CheckPython3() prototype: () => (void) * Truncate a few lines which were too long
* bpo-32030: Fix Py_GetPath(): init program_name (#4665)Victor Stinner2017-12-012-75/+86
| | | | | | | | | | | | | | | * _PyMainInterpreterConfig_ReadEnv() now sets program_name from environment variables and pymain_parse_envvars() implements the falls back on argv[0]. * Remove _PyMain.program_name: use the program_name from _PyMainInterpreterConfig * Move the Py_SetProgramName() call back to pymain_init_python(), just before _Py_InitializeCore(). * pathconfig_global_init() now also calls _PyMainInterpreterConfig_Read() to set program_name if it isn't set yet * Cleanup PyCalculatePath: pass main_config to subfunctions to get directly fields from main_config (home, module_search_path_env and program_name)
* bpo-32030: Cleanup "path config" code (#4663)Victor Stinner2017-12-011-64/+54
| | | | | | | | | | * Rename PyPathConfig structure to _PyPathConfig and move it to Include/internal/pystate.h * Rename path_config to _Py_path_config * _PyPathConfig: Rename program_name field to program_full_path * Add assert(str != NULL); to _PyMem_RawWcsdup(), _PyMem_RawStrdup() and _PyMem_Strdup(). * Rename calculate_path() to pathconfig_global_init(). The function now does nothing if it's already initiallized.
* bpo-32186: Release the GIL during lseek and fstat (#4652)Nir Soffer2017-12-011-1/+5
| | | | | | In _io_FileIO_readall_impl(), lseek() and _Py_fstat_noraise() were called without releasing the GIL. This can cause all threads to hang for unlimited time when calling FileIO.read() and the NFS server is not accessible.
* Fix CID-1420310: cast PY_TIMEOUT_MAX to _Py_time_t (#4646)Victor Stinner2017-11-301-1/+1
| | | | | | | | | | | | | Fix the following false-alarm Coverity warning: Result is not floating-point (UNINTENDED_INTEGER_DIVISION)integer_division: Dividing integer expressions 9223372036854775807LL and 1000LL, and then converting the integer quotient to type double. Any remainder, or fractional part of the quotient, is ignored. To compute and use a non-integer quotient, change or cast either operand to type double. If integer division is intended, consider indicating that by casting the result to type long long .
* bpo-28416: Break reference cycles in Pickler and Unpickler subclasses (#4080)Serhiy Storchaka2017-11-301-38/+98
| | | | with the persistent_id() and persistent_load() methods.
* Fix CID-1414686: PyInit_readline() handles errors (#4647)Victor Stinner2017-11-301-4/+18
| | | | | | | | | | | | Handle PyModule_AddIntConstant() and PyModule_AddStringConstant() failures. Add also constants before calling setup_readline(), since setup_readline() registers callbacks which uses a reference to the module, whereas the module is destroyed if adding constants fails. Fix Coverity warning: CID 1414686: Unchecked return value (CHECKED_RETURN) 2. check_return: Calling PyModule_AddStringConstant without checking return value (as is done elsewhere 45 out of 55 times).
* bpo-32101: Add PYTHONDEVMODE environment variable (#4624)Victor Stinner2017-11-301-2/+5
| | | | | | * bpo-32101: Add sys.flags.dev_mode flag Rename also the "Developer mode" to the "Development mode". * bpo-32101: Add PYTHONDEVMODE environment variable Mention it in the development chapiter.