summaryrefslogtreecommitdiffstats
path: root/Python
Commit message (Collapse)AuthorAgeFilesLines
* bpo-40521: Make context free list per-interpreter (GH-20644)Victor Stinner2020-06-052-20/+20
| | | | | | | | | Each interpreter now has its own context free list: * Move context free list into PyInterpreterState. * Add _Py_context_state structure. * Add tstate parameter to _PyContext_ClearFreeList() and _PyContext_Fini(). * Pass tstate to clear_freelists().
* bpo-40521: Make async gen free lists per-interpreter (GH-20643)Victor Stinner2020-06-051-1/+5
| | | | | | | | | Each interpreter now has its own asynchronous generator free lists: * Move async gen free lists into PyInterpreterState. * Move _PyAsyncGen_MAXFREELIST define to pycore_interp.h * Add _Py_async_gen_state structure. * Add tstate parameter to _PyAsyncGen_ClearFreeLists and _PyAsyncGen_Fini().
* bpo-40521: Make list free list per-interpreter (GH-20642)Victor Stinner2020-06-051-3/+3
| | | | | | | | | | | | Each interpreter now has its own list free list: * Move list numfree and free_list into PyInterpreterState. * Add _Py_list_state structure. * Add tstate parameter to _PyList_ClearFreeList() and _PyList_Fini(). * Remove "#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS". * _PyGC_Fini() clears gcstate->garbage list which can be stored in the list free list. Call _PyGC_Fini() before _PyList_Fini() to prevent leaking this list.
* bpo-40521: Make frame free list per-interpreter (GH-20638)Victor Stinner2020-06-041-4/+1
| | | | | | | | | | Each interpreter now has its own frame free list: * Move frame free list into PyInterpreterState. * Add _Py_frame_state structure. * Add tstate parameter to _PyFrame_ClearFreeList() and _PyFrame_Fini(). * Remove "#if PyFrame_MAXFREELIST > 0". * Remove "#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS".
* bpo-40521: Make slice cache per-interpreter (GH-20637)Victor Stinner2020-06-041-1/+1
| | | | | | Each interpreter now has its own slice cache: * Move slice cache into PyInterpreterState. * Add tstate parameter to _PySlice_Fini().
* bpo-40521: Make float free list per-interpreter (GH-20636)Victor Stinner2020-06-041-1/+1
| | | | | | | | Each interpreter now has its own float free list: * Move tuple numfree and free_list into PyInterpreterState. * Add _Py_float_state structure. * Add tstate parameter to _PyFloat_ClearFreeList() and _PyFloat_Fini().
* bpo-40521: Make tuple free list per-interpreter (GH-20247)Victor Stinner2020-06-041-1/+3
| | | | | | | | | | Each interpreter now has its own tuple free lists: * Move tuple numfree and free_list arrays into PyInterpreterState. * Define PyTuple_MAXSAVESIZE and PyTuple_MAXFREELIST macros in pycore_interp.h. * Add _Py_tuple_state structure. Pass it explicitly to tuple_alloc(). * Add tstate parameter to _PyTuple_ClearFreeList() * Each interpreter now has its own empty tuple singleton.
* bpo-40679: Fix _PyEval_EvalCode() crash if qualname is NULL (GH-20615)Victor Stinner2020-06-041-22/+36
| | | | | | | | | | If name is NULL, name is now set to co->co_name. If qualname is NULL, qualname is now set to name. qualname must not be NULL: it is used to build error messages. Cleanup also the code: declare variables where they are initialized. Rename "name" local variables to "varname" to avoid overriding "name" parameter.
* bpo-40471: Fix grammar typo in 'issubclass' docstring (GH-19847)Alex Povel2020-06-032-6/+6
| | | | | Just a brief grammar fix. See also <>.
* PyOS_AfterFork_Child() pass tstate to _PyEval_ReInitThreads() (GH-20598)Victor Stinner2020-06-021-3/+2
|
* bpo-40232: _PyImport_ReInitLock() can now safely use its lock (GH-20597)Victor Stinner2020-06-021-5/+1
| | | | | Since _PyImport_ReInitLock() now calls _PyThread_at_fork_reinit() on the import lock, the lock is now in a known state: unlocked. It became safe to acquire it after fork.
* PyOS_AfterFork_Child() uses PyStatus (GH-20596)Victor Stinner2020-06-023-35/+36
| | | | | | | | PyOS_AfterFork_Child() helper functions now return a PyStatus: PyOS_AfterFork_Child() is now responsible to handle errors. * Move _PySignal_AfterFork() to the internal C API * Add #ifdef HAVE_FORK on _PyGILState_Reinit(), _PySignal_AfterFork() and _PyInterpreterState_DeleteExceptMain().
* Fix MSVC warnings in pythonrun.c (#GH-0587)Ammar Askar2020-06-021-8/+8
|
* bpo-40826: Add _Py_EnsureTstateNotNULL() macro (GH-20571)Victor Stinner2020-06-014-29/+18
| | | | Add _Py_EnsureTstateNotNULL(tstate) macro: call Py_FatalError() if tstate is NULL, the error message contains the current function name.
* Make sure that keyword arguments are merged into the arguments dictionary ↵Mark Shannon2020-06-011-0/+3
| | | | when dict unpacking and keyword arguments are interleaved. (GH-20553)
* bpo-40780: Fix failure of _Py_dg_dtoa to remove trailing zeros (GH-20435)Mark Dickinson2020-05-291-0/+11
| | | | | | | | | | | * Fix failure of _Py_dg_dtoa to remove trailing zeros * Add regression test and news entry * Add explanation about why it's safe to strip trailing zeros * Make code safer, clean up comments, add change note at top of file * Nitpick: avoid implicit int-to-float conversion in tests
* bpo-40792: Make the result of PyNumber_Index() always having exact type int. ↵Serhiy Storchaka2020-05-282-3/+3
| | | | | | | | | | | | (GH-20443) Previously, the result could have been an instance of a subclass of int. Also revert bpo-26202 and make attributes start, stop and step of the range object having exact type int. Add private function _PyNumber_Index() which preserves the old behavior of PyNumber_Index() for performance to use it in the conversion functions like PyLong_AsLong().
* bpo-40614: Respect feature version for f-string debug expressions (GH-20196)Shantanu2020-05-271-0/+6
| | | | Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com> Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
* bpo-40217: Ensure Py_VISIT(Py_TYPE(self)) is always called for ↵Pablo Galindo2020-05-271-0/+1
| | | | | | | | | PyType_FromSpec types (reverts GH-19414) (GH-20264) Heap types now always visit the type in tp_traverse. See added docs for details. This reverts commit 0169d3003be3d072751dd14a5c84748ab63a249f. Automerge-Triggered-By: @encukou
* bpo-37999: No longer use __int__ in implicit integer conversions. (GH-15636)Serhiy Storchaka2020-05-267-140/+18
| | | | Only __index__ should be used to make integer conversions lossless.
* bpo-36290: Fix keytword collision handling in AST node constructors (GH-12382)Rémi Lapeyre2020-05-241-3/+24
|
* bpo-40679: Use the function's qualname in certain TypeErrors (GH-20236)Dennis Sweeney2020-05-221-15/+16
| | | | Patch by Dennis Sweeney.
* bpo-40696: Fix a hang that can arise after gen.throw() (GH-20287)Chris Jerdonek2020-05-221-9/+53
| | | | | | | | This updates _PyErr_ChainStackItem() to use _PyErr_SetObject() instead of _PyErr_ChainExceptions(). This prevents a hang in certain circumstances because _PyErr_SetObject() performs checks to prevent cycles in the exception context chain while _PyErr_ChainExceptions() doesn't.
* bpo-40663: Correctly handle annotations with subscripts in ast_unparse.c ↵Batuhan Taskaya2020-05-181-1/+12
| | | | (GH-20156)
* bpo-35890: Use RegQueryInfoKeyW and CryptAcquireContextW explicitly (GH-19974)Minmin Gong2020-05-181-2/+2
|
* bpo-40650: Include winsock2.h in pytime.c, instead of a full windows.h ↵Minmin Gong2020-05-181-1/+1
| | | | (GH-20137)
* bpo-31033: Improve the traceback for cancelled asyncio tasks (GH-19951)Chris Jerdonek2020-05-181-0/+14
| | | | | When an asyncio.Task is cancelled, the exception traceback now starts with where the task was first interrupted. Previously, the traceback only had "depth one."
* bpo-40636: Clarify the zip built-in docstring. (GH-20118)Gregory P. Smith2020-05-151-5/+8
| | | | | | | | | | | | | | | | | | | | | Clarify the zip built-in docstring. This puts much simpler text up front along with an example. As it was, the zip built-in docstring was technically correct. But too technical for the reader who shouldn't _need_ to know about `__next__` and `StopIteration` as most people do not need to understand the internal implementation details of the iterator protocol in their daily life. This is a documentation only change, intended to be backported to 3.8; it is only tangentially related to PEP-618 which might offer new behavior options in the future. Wording based a bit more on enumerate per Brandt's suggestion. This gets rid of the legacy wording paragraph which seems too tied to implementation details of the iterator protocol which isn't relevant here. Co-authored-by: Brandt Bucher <brandtbucher@gmail.com>
* Fix typo in code comment in main_loop label. (GH-20068)Chris Jerdonek2020-05-151-1/+1
|
* bpo-40612: Fix SyntaxError edge cases in traceback formatting (GH-20072)Guido van Rossum2020-05-151-19/+47
| | | | | | | | | | | | | This fixes both the traceback.py module and the C code for formatting syntax errors (in Python/pythonrun.c). They now both consistently do the following: - Suppress caret if it points left of text - Allow caret pointing just past end of line - If caret points past end of line, clip to *just* past end of line The syntax error formatting code in traceback.py was mostly rewritten; small, subtle changes were applied to the C code in pythonrun.c. There's still a difference when the text contains embedded newlines. Neither handles these very well, and I don't think the case occurs in practice. Automerge-Triggered-By: @gvanrossum
* bpo-40334: Correctly identify invalid target in assignment errors (GH-20076)Pablo Galindo2020-05-151-5/+8
| | | Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
* bpo-40602: _Py_hashtable_set() reports rehash failure (GH-20077)Victor Stinner2020-05-141-9/+17
| | | | If _Py_hashtable_set() fails to grow the hash table (rehash), it now fails rather than ignoring the error.
* bpo-40602: Write unit tests for _Py_hashtable_t (GH-20091)Victor Stinner2020-05-142-109/+51
| | | | | | | Cleanup also hashtable.c. Rename _Py_hashtable_t members: * Rename entries to nentries * Rename num_buckets to nbuckets
* bpo-40602: Optimize _Py_hashtable_get_ptr() (GH-20066)Victor Stinner2020-05-131-24/+23
| | | | | | | _Py_hashtable_get_entry_ptr() avoids comparing the entry hash: compare directly keys. Move _Py_hashtable_get_entry_ptr() just after _Py_hashtable_get_entry_generic().
* bpo-40609: _Py_hashtable_t values become void* (GH-20065)Victor Stinner2020-05-132-99/+41
| | | | | | | | | | | | | | | | | | | | | _Py_hashtable_t values become regular "void *" pointers. * Add _Py_hashtable_entry_t.data member * Remove _Py_hashtable_t.data_size member * Remove _Py_hashtable_t.get_func member. It is no longer needed to specialize _Py_hashtable_get() for a specific value size, since all entries now have the same size (void*). * Remove the following macros: * _Py_HASHTABLE_GET() * _Py_HASHTABLE_SET() * _Py_HASHTABLE_SET_NODATA() * _Py_HASHTABLE_POP() * Rename _Py_hashtable_pop() to _Py_hashtable_steal() * _Py_hashtable_foreach() callback now gets key and value rather than entry. * Remove _Py_hashtable_value_destroy_func type. value_destroy_func callback now only has a single parameter: data (void*).
* bpo-40609: _tracemalloc allocates traces (GH-20064)Victor Stinner2020-05-131-49/+0
| | | | | | | | | | | | | Rewrite _tracemalloc to store "trace_t*" rather than directly "trace_t" in traces hash tables. Traces are now allocated on the heap memory, outside the hash table. Add tracemalloc_copy_traces() and tracemalloc_copy_domains() helper functions. Remove _Py_hashtable_copy() function since there is no API to copy a key or a value. Remove also _Py_hashtable_delete() function which was commented.
* bpo-40609: Add destroy functions to _Py_hashtable (GH-20062)Victor Stinner2020-05-132-23/+38
| | | | | | Add key_destroy_func and value_destroy_func parameters to _Py_hashtable_new_full(). marshal.c and _tracemalloc.c use these destroy functions.
* bpo-40609: Remove _Py_hashtable_t.key_size (GH-20060)Victor Stinner2020-05-132-68/+49
| | | | | | | | | | Rewrite _Py_hashtable_t type to always store the key as a "const void *" pointer. Add an explicit "key" member to _Py_hashtable_entry_t. Remove _Py_hashtable_t.key_size member. hash and compare functions drop their hash table parameter, and their 'key' parameter type becomes "const void *".
* bpo-40602: Add _Py_HashPointerRaw() function (GH-20056)Victor Stinner2020-05-122-5/+11
| | | | | Add a new _Py_HashPointerRaw() function which avoids replacing -1 with -2 to micro-optimize hash table using pointer keys: using _Py_hashtable_hash_ptr() hash function.
* bpo-38787: Add PyCFunction_CheckExact() macro for exact type checks (GH-20024)scoder2020-05-121-2/+2
| | | | | … now that we allow subtypes of PyCFunction. Also add PyCMethod_CheckExact() and PyCMethod_Check() for checks against the PyCMethod subtype.
* bpo-40602: Optimize _Py_hashtable for pointer keys (GH-20051)Victor Stinner2020-05-121-79/+128
| | | | | | | | | | | | | | | Optimize _Py_hashtable_get() and _Py_hashtable_get_entry() for pointer keys: * key_size == sizeof(void*) * hash_func == _Py_hashtable_hash_ptr * compare_func == _Py_hashtable_compare_direct Changes: * Add get_func and get_entry_func members to _Py_hashtable_t * Convert _Py_hashtable_get() and _Py_hashtable_get_entry() functions to static nline functions. * Add specialized get and get entry for pointer keys.
* bpo-40593: Improve syntax errors for invalid characters in source code. ↵Serhiy Storchaka2020-05-121-3/+0
| | | | (GH-20033)
* bpo-40602: _Py_hashtable_new() uses PyMem_Malloc() (GH-20046)Victor Stinner2020-05-121-3/+4
| | | | | | | _Py_hashtable_new() now uses PyMem_Malloc/PyMem_Free allocator by default, rather than PyMem_RawMalloc/PyMem_RawFree. PyMem_Malloc is faster than PyMem_RawMalloc for memory blocks smaller than or equal to 512 bytes.
* bpo-40602: Rename hashtable.h to pycore_hashtable.h (GH-20044)Victor Stinner2020-05-122-1/+525
| | | | | | | * Move Modules/hashtable.h to Include/internal/pycore_hashtable.h * Move Modules/hashtable.c to Python/hashtable.c * Python is now linked to hashtable.c. _tracemalloc is no longer linked to hashtable.c. Previously, marshal.c got hashtable.c via _tracemalloc.c which is built as a builtin module.
* bpo-39465: Don't access directly _Py_Identifier members (GH-20043)Victor Stinner2020-05-111-1/+1
| | | | | * Replace id->object with _PyUnicode_FromId(&id) * Use _Py_static_string_init(str) macro to initialize statically name_op in typeobject.c.
* bpo-40528: Improve and clear several aspects of the ASDL definition code for ↵Batuhan Taskaya2020-05-061-86/+69
| | | | the AST (GH-19952)
* bpo-40527: Fix command line argument parsing (GH-19955)Victor Stinner2020-05-061-7/+16
|
* bpo-40513: Per-interpreter GIL (GH-19943)Victor Stinner2020-05-053-5/+73
| | | | | | | | In the experimental isolated subinterpreters build mode, the GIL is now per-interpreter. Move gil from _PyRuntimeState.ceval to PyInterpreterState.ceval. new_interpreter() always get the config from the main interpreter.
* bpo-40513: new_interpreter() init GIL earlier (GH-19942)Victor Stinner2020-05-051-4/+4
| | | Fix also code to handle init_interp_main() failure.
* bpo-40522: _PyThreadState_Swap() sets autoTSSkey (GH-19939)Victor Stinner2020-05-052-0/+30
| | | | | | | | | | | | | | | | | | In the experimental isolated subinterpreters build mode, _PyThreadState_GET() gets the autoTSSkey variable and _PyThreadState_Swap() sets the autoTSSkey variable. * Add _PyThreadState_GetTSS() * _PyRuntimeState_GetThreadState() and _PyThreadState_GET() return _PyThreadState_GetTSS() * PyEval_SaveThread() sets the autoTSSkey variable to current Python thread state rather than NULL. * eval_frame_handle_pending() doesn't check that _PyThreadState_Swap() result is NULL. * _PyThreadState_Swap() gets the current Python thread state with _PyThreadState_GetTSS() rather than _PyRuntimeGILState_GetThreadState(). * PyGILState_Ensure() no longer checks _PyEval_ThreadsInitialized() since it cannot access the current interpreter.