summaryrefslogtreecommitdiffstats
path: root/Python
Commit message (Collapse)AuthorAgeFilesLines
* bpo-32436: Fix a refleak; var GC tracking; a GCC warning (#5326)Yury Selivanov2018-01-252-4/+6
| | | | | The refleak in question wasn't really important, as context vars are usually created at the toplevel and live as long as the interpreter lives, so the context var name isn't ever GCed anyways.
* Fix 3rd level node's binary representation in HAMT algorithm description (#5319)Dmitry Alimov2018-01-251-1/+1
|
* bpo-32571: Avoid raising unneeded AttributeError and silencing it in C code ↵Serhiy Storchaka2018-01-255-1069/+1204
| | | | | (GH-5222) Add two new private APIs: _PyObject_LookupAttr() and _PyObject_LookupAttrId()
* bpo-32436: Don't use native popcount() (also fixes bpo-32641) (#5292)Yury Selivanov2018-01-242-15/+13
|
* bpo-32436: Fix potential NULL dereference (#5286)Yury Selivanov2018-01-231-0/+4
|
* bpo-32436: Remove a redundant assert (#5275)Yury Selivanov2018-01-231-1/+0
|
* bpo-32436: Implement PEP 567 (#5027)Yury Selivanov2018-01-235-0/+4363
|
* bpo-29240: PyUnicode_DecodeLocale() uses UTF-8 on Android (#5272)Victor Stinner2018-01-221-0/+10
| | | | | | | | PyUnicode_DecodeLocaleAndSize(), PyUnicode_DecodeLocale() and PyUnicode_EncodeLocale() now use always use the UTF-8 encoding on Android, instead of the current locale encoding. On Android API 19, mbstowcs() and wcstombs() are broken and cannot be used.
* bpo-32593: Drop FreeBSD 9 and older support (#5232)Victor Stinner2018-01-221-10/+0
| | | Drop support of FreeBSD 9 and older.
* bpo-32591: Fix PyExc_WarnFormat call (follow-up commit) (#5263)Yury Selivanov2018-01-221-5/+4
| | | | | The previous version was correct in terms of behaviour, but checking the return value of PyErr_WarnFormat allows to avoid calling PyErr_Occurred and silences the coverity alarm.
* bpo-32591: Add native coroutine origin tracking (#5250)Nathaniel J. Smith2018-01-215-0/+185
| | | | | | * Add coro.cr_origin and sys.set_coroutine_origin_tracking_depth * Use coroutine origin information in the unawaited coroutine warning * Stop using set_coroutine_wrapper in asyncio debug mode * In BaseEventLoop.set_debug, enable debugging in the correct thread
* bpo-9566: Fix size_t=>int downcast warnings (#5230)Victor Stinner2018-01-183-7/+7
| | | | * Use wider types (int => Py_ssize_t) to avoid integer overflows. * Fix gc.get_freeze_count(): use Py_ssize_t type rather than int, since gc_list_size() returns a Py_ssize_t.
* Fix typo in thread_nt.h code comment (GH-5211)hui shang2018-01-171-1/+1
| | | | The comment for PyThread_allocate_lock says "It has too be implemented ...". There was an extra "o" in ".. to be implemented.."
* bpo-32544: Speed up hasattr() and getattr() (GH-5173)INADA Naoki2018-01-161-10/+11
| | | | | AttributeError was raised always when attribute is not found. This commit skip raising AttributeError when `tp_getattro` is `PyObject_GenericGetAttr`. It makes hasattr() and getattr() about 4x faster when attribute is not found.
* Implement the get_resource_reader() API for file system imports (#5168)Barry Warsaw2018-01-151-1248/+1307
|
* bpo-31900: Fix localeconv() encoding for LC_NUMERIC (#4174)Victor Stinner2018-01-152-11/+81
| | | | | | | | * Add _Py_GetLocaleconvNumeric() function: decode decimal_point and thousands_sep fields of localeconv() from the LC_NUMERIC encoding, rather than decoding from the LC_CTYPE encoding. * Modify locale.localeconv() and "n" formatter of str.format() (for int, float and complex to use _Py_GetLocaleconvNumeric() internally.
* bpo-29240: Fix locale encodings in UTF-8 Mode (#5170)Victor Stinner2018-01-152-141/+248
| | | | | | | | | | | | | | | | | | | | | | | | | | | Modify locale.localeconv(), time.tzname, os.strerror() and other functions to ignore the UTF-8 Mode: always use the current locale encoding. Changes: * Add _Py_DecodeLocaleEx() and _Py_EncodeLocaleEx(). On decoding or encoding error, they return the position of the error and an error message which are used to raise Unicode errors in PyUnicode_DecodeLocale() and PyUnicode_EncodeLocale(). * Replace _Py_DecodeCurrentLocale() with _Py_DecodeLocaleEx(). * PyUnicode_DecodeLocale() now uses _Py_DecodeLocaleEx() for all cases, especially for the strict error handler. * Add _Py_DecodeUTF8Ex(): return more information on decoding error and supports the strict error handler. * Rename _Py_EncodeUTF8_surrogateescape() to _Py_EncodeUTF8Ex(). * Replace _Py_EncodeCurrentLocale() with _Py_EncodeLocaleEx(). * Ignore the UTF-8 mode to encode/decode localeconv(), strerror() and time zone name. * Remove PyUnicode_DecodeLocale(), PyUnicode_DecodeLocaleAndSize() and PyUnicode_EncodeLocale() now ignore the UTF-8 mode: always use the "current" locale. * Remove _PyUnicode_DecodeCurrentLocale(), _PyUnicode_DecodeCurrentLocaleAndSize() and _PyUnicode_EncodeCurrentLocale().
* bpo-31113: Get rid of recursion in the compiler for normal control flow. (#3015)Serhiy Storchaka2018-01-111-78/+104
|
* bpo-29240: readline now ignores the UTF-8 Mode (#5145)Victor Stinner2018-01-101-28/+52
| | | | | | | | | | | | Add new fuctions ignoring the UTF-8 mode: * _Py_DecodeCurrentLocale() * _Py_EncodeCurrentLocale() * _PyUnicode_DecodeCurrentLocaleAndSize() * _PyUnicode_EncodeCurrentLocale() Modify the readline module to use these functions. Re-enable test_readline.test_nonascii().
* bpo-24340: Fix estimation of the code stack size. (#5076)Serhiy Storchaka2018-01-093-1152/+1205
|
* bpo-31975 (PEP 565): Show DeprecationWarning in __main__ (GH-4458)Nick Coghlan2018-01-081-7/+33
| | | | | | | | | | | | | - primary change is to add a new default filter entry for 'default::DeprecationWarning:__main__' - secondary change is an internal one to cope with plain strings in the warning module's internal filter list (this avoids the need to create a compiled regex object early on during interpreter startup) - assorted documentation updates, including many more examples of configuring the warnings settings - additional tests to ensure that both the pure Python and the C accelerated warnings modules have the expected default configuration
* bpo-30579: Allow TracebackType creation and tb_next mutation from Python ↵Nathaniel J. Smith2018-01-072-26/+158
| | | | | | | | | | | | | | | | | (GH-4793) Third party projects may wish to hide their own internal machinery in order to present more comprehensible tracebacks to end users (e.g. Jinja2 and Trio both do this). Previously such projects have had to rely on ctypes to do so: https://github.com/pallets/jinja/blob/fe3dadacdf4cf411d0a5b6bbd4d5234697a28af2/jinja2/debug.py#L345 https://github.com/python-trio/trio/blob/1e86b1aee8c0c759f6f239ae53a05d0d3963c629/trio/_core/_multierror.py#L296 This provides a Python level API for creating and modifying real Traceback objects, allowing tracebacks to be edited at runtime. Patch by Nathaniel Smith.
* bpo-29137: Remove fpectl module (#4789)Nathaniel J. Smith2018-01-061-14/+6
| | | | | This module has never been enabled by default, never worked correctly on x86-64, and caused ABI problems that caused C extension compatibility. See bpo-29137 for details/discussion.
* advance copyright years to 2018 (#5094)Benjamin Peterson2018-01-051-1/+1
|
* closes bpo-32460: ensure all non-static globals have initializers (#5061)Benjamin Peterson2017-12-312-11/+11
|
* bpo-32439: Clean up the code for compiling comparison expressions. (#5029)Serhiy Storchaka2017-12-301-23/+20
|
* bpo-32259: Make a TypeError message when unpack non-iterable more specific. ↵Serhiy Storchaka2017-12-261-2/+10
| | | | (#4903)
* bpo-32372: Move __debug__ optimization to the AST level. (#4925)Serhiy Storchaka2017-12-252-51/+46
|
* remove the dynload_next.c file (closes bpo-32386) (#4957)Benjamin Peterson2017-12-221-111/+0
|
* bpo-32030: Add _Py_FindEnvConfigValue() (#4963)Victor Stinner2017-12-212-10/+56
| | | | | | | | | | | | | | | Add a new _Py_FindEnvConfigValue() function: code shared between Windows and Unix implementations of _PyPathConfig_Calculate() to read the pyenv.cfg file. _Py_FindEnvConfigValue() now uses _Py_DecodeUTF8_surrogateescape() instead of using a Python Unicode string, the Python API must not be used early during Python initialization. Same change in Unix search_for_exec_prefix(): use _Py_DecodeUTF8_surrogateescape(). Cleanup also encode_current_locale(): PyMem_RawFree/PyMem_Free can be called with NULL. Fix also "NUL byte" => "NULL byte" typo.
* bpo-32030: Add _Py_EncodeLocaleRaw() (#4961)Victor Stinner2017-12-211-32/+72
| | | | | | | | | | | | Replace Py_EncodeLocale() with _Py_EncodeLocaleRaw() in: * _Py_wfopen() * _Py_wreadlink() * _Py_wrealpath() * _Py_wstat() * pymain_open_filename() These functions are called early during Python intialization, only the RAW memory allocator must be used.
* bpo-32030: Add _Py_EncodeUTF8_surrogateescape() (#4960)Victor Stinner2017-12-211-38/+4
| | | | | Py_EncodeLocale() now uses _Py_EncodeUTF8_surrogateescape(), instead of using temporary unicode and bytes objects. So Py_EncodeLocale() doesn't use the Python C API anymore.
* bpo-32030: Fix usage of memory allocators (#4953)Victor Stinner2017-12-201-5/+29
| | | | | | | | | * _Py_InitializeCore() doesn't call _PyMem_SetupAllocators() anymore if the PYTHONMALLOC environment variable is not set. * pymain_cmdline() now sets the allocator to the default, instead of setting the allocator in subfunctions. * Py_SetStandardStreamEncoding() now calls _PyMem_SetDefaultAllocator() to get a known allocator, to be able to release the memory with the same allocator.
* bpo-32030: Complete _PyCoreConfig_Read() (#4946)Victor Stinner2017-12-201-13/+11
| | | | | | | | | | * Add _PyCoreConfig.install_signal_handlers * Remove _PyMain.config: _PyMainInterpreterConfig usage is now restricted to pymain_init_python_main(). * Rename _PyMain.core_config to _PyMain.config * _PyMainInterpreterConfig_Read() now creates the xoptions dictionary from the core config * Fix _PyMainInterpreterConfig_Read(): don't replace xoptions and argv if they are already set.
* bpo-32030: Add _PyCoreConfig.warnoptions (#4936)Victor Stinner2017-12-202-7/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Merge _PyCoreConfig_ReadEnv() into _PyCoreConfig_Read(), and _Py_CommandLineDetails usage is now restricted to pymain_cmdline(). Changes: * _PyCoreConfig: Add nxoption, xoptions, nwarnoption and warnoptions * Add _PyCoreConfig.program: argv[0] or "" * Move filename, command, module and xoptions from _Py_CommandLineDetails to _PyMain. xoptions _Py_OptList becomes (int, wchar_t**) list. * Add pymain_cmdline() function * Rename copy_argv() to copy_wstrlist(). Rename clear_argv() to clear_wstrlist(). Remove _Py_OptList structure: use (int, wchar_t**) list instead. * Rename pymain_set_flag_from_env() to pymain_get_env_flag() * Rename pymain_set_flags_from_env() to pymain_get_env_flags() * _PyMainInterpreterConfig_Read() now creates the warnoptions from _PyCoreConfig.warnoptions * Inline pymain_add_warning_dev_mode() and pymain_add_warning_bytes_flag() into config_init_warnoptions() * Inline pymain_get_program_name() into _PyCoreConfig_Read() * _Py_CommandLineDetails: Replace warning_options with nwarnoption and warnoptions. Replace env_warning_options with nenv_warnoption and env_warnoptions. * pymain_warnings_envvar() now has a single implementation for Windows and Unix: use config_get_env_var_dup() to also get the variable as wchar_t* on Unix.
* bpo-31901: atexit callbacks should be run at subinterpreter shutdown (#4611)Marcel Plch2017-12-202-11/+24
| | | | Change atexit behavior and PEP-489 multiphase init support.
* bpo-32030: Cleanup pymain_main() (#4935)Victor Stinner2017-12-201-2/+2
| | | | | | | * Reorganize pymain_main() to make the code more flat * Clear configurations before pymain_update_sys_path() * Mark Py_FatalError() and _Py_FatalInitError() with _Py_NO_RETURN * Replace _PyMain.run_code variable with a new RUN_CODE() macro * Move _PyMain.cf into a local variable in pymain_run_python()
* bpo-32030: Fix compiler warnings (#4921)Victor Stinner2017-12-192-15/+14
| | | | | | | | | | | 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-32365: Fix a reference leak when compile __debug__. (#4916)Serhiy Storchaka2017-12-181-4/+4
| | | It was introduced in bpo-27169.
* bpo-29469: peephole: Remove const_stack (GH-4879)INADA Naoki2017-12-181-81/+21
| | | | | | | | | | Constant folding was moved to AST optimizer. But compiler may emit LOAD_CONSTs + BUILD_TUPLE. For example, default arguments can be constant tuple if all arguments are constant. This commit makes peephole's tuple folding simple. It doesn't support nested tuples because nested tuples are folded by AST optimizer already.
* fix up signedness in PyImport_ExtendInittab (#4831)Benjamin Peterson2017-12-161-5/+3
| | | | | | | | | | As a result of 92a3c6f493ad411e4cf0acdf305ef4876aa90669, the compiler complains: Python/import.c:2311:21: warning: comparison of integers of different signs: 'long' and 'unsigned long' [-Wsign-compare] if ((i + n + 1) <= PY_SSIZE_T_MAX / sizeof(struct _inittab)) { ~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This overflow is extremely unlikely to happen, but let's avoid undefined behavior anyway.
* bpo-29240, bpo-32030: Py_Main() re-reads config if encoding changes (#4899)Victor Stinner2017-12-163-57/+34
| | | | | | | | | | | | | | | | | | 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: Don't define decode_locale() on macOS (#4895)Victor Stinner2017-12-151-0/+4
| | | Don't define decode_locale() nor encode_locale() on macOS or Android.
* bpo-30416: Protect the optimizer during constant folding. (#4860)Serhiy Storchaka2017-12-151-25/+130
| | | | | | | | It no longer spends much time doing complex calculations and no longer consumes much memory for creating large constants that will be dropped later. This fixes also bpo-21074.
* bpo-32240: Add the const qualifier to declarations of PyObject* array ↵Serhiy Storchaka2017-12-158-50/+53
| | | | arguments. (#4746)
* bpo-27169: The __debug__ constant is now optimized out at compile time. (#4880)Serhiy Storchaka2017-12-151-30/+15
| | | This fixes also bpo-22091.
* move pygetopt.h to internal (closes bpo-32264) (#4830)Benjamin Peterson2017-12-151-1/+1
|
* bpo-32030: Add _PyMainInterpreterConfig.executable (#4876)Victor Stinner2017-12-152-43/+32
| | | | | | | | | | | | * 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-152-84/+43
| | | | | | | | | | 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-27/+10
| | | | | | | | | | | | 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.