summaryrefslogtreecommitdiff
path: root/Python
Commit message (Collapse)AuthorAgeFilesLines
...
* bpo-39573: Use Py_TYPE() macro in Python and Include directories (GH-18391)Victor Stinner2020-02-079-29/+29
| | | Replace direct access to PyObject.ob_type with Py_TYPE().
* bpo-39573: Use Py_REFCNT() macro (GH-18388)Victor Stinner2020-02-071-1/+1
| | | | Replace direct acccess to PyObject.ob_refcnt with usage of the Py_REFCNT() macro.
* bpo-38823: Fix refleaks in _ast initialization error path (GH-17276)Brandt Bucher2020-02-061-176/+354
|
* bpo-39127: Make _Py_HashPointer's argument be const (GH-17690)Andy Lester2020-02-051-1/+1
|
* bpo-39542: Declare _Py_AddToAllObjects() in pycore_object.h (GH-18368)Victor Stinner2020-02-051-1/+2
| | | | | | _Py_AddToAllObjects() is used in bltinmodule.c and typeobject.c when Py_TRACE_REFS is defined. Fix Py_TRACE_REFS build.
* bpo-39553: Delete HAVE_SXS protected code (GH-18356)Zackery Spytz2020-02-041-15/+0
| | | | | | | https://bugs.python.org/issue39553 Automerge-Triggered-By: @zooba
* bpo-38076 Clear the interpreter state only after clearing module globals ↵Eddie Elizondo2020-02-041-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (GH-18039) Currently, during runtime destruction, `_PyImport_Cleanup` is clearing the interpreter state before clearing out the modules themselves. This leads to a segfault on modules that rely on the module state to clear themselves up. For example, let's take the small snippet added in the issue by @DinoV : ``` import _struct class C: def __init__(self): self.pack = _struct.pack def __del__(self): self.pack('I', -42) _struct.x = C() ``` The module `_struct` uses the module state to run `pack`. Therefore, the module state has to be alive until after the module has been cleared out to successfully run `C.__del__`. This happens at line 606, when `_PyImport_Cleanup` calls `_PyModule_Clear`. In fact, the loop that calls `_PyModule_Clear` has in its comments: > Now, if there are any modules left alive, clear their globals to minimize potential leaks. All C extension modules actually end up here, since they are kept alive in the interpreter state. That means that we can't clear the module state (which is used by C Extensions) before we run that loop. Moving `_PyInterpreterState_ClearModules` until after it, fixes the segfault in the code snippet. Finally, this updates a test in `io` to correctly assert the error that it now throws (since it now finds the io module state). The test that uses this is: `test_create_at_shutdown_without_encoding`. Given this test is now working is a proof that the module state now stays alive even when `__del__` is called at module destruction time. Thus, I didn't add a new tests for this. https://bugs.python.org/issue38076
* bpo-39542: Move object.h debug functions to internal C API (GH-18331)Victor Stinner2020-02-032-0/+2
| | | | | | | | Move the following functions from the public C API to the internal C API: * _PyDebug_PrintTotalRefs(), * _Py_PrintReferenceAddresses() * _Py_PrintReferences()
* bpo-39489: Remove COUNT_ALLOCS special build (GH-18259)Victor Stinner2020-02-034-64/+1
| | | | | | | | | | | 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
* Update sum comment. (#18240)Brandt Bucher2020-02-011-1/+5
|
* bpo-39511: PyThreadState_Clear() calls on_delete (GH-18296)Victor Stinner2020-02-011-3/+5
| | | | | | | | | | | | | | | | | | PyThreadState.on_delete is a callback used to notify Python when a thread completes. _thread._set_sentinel() function creates a lock which is released when the thread completes. It sets on_delete callback to the internal release_sentinel() function. This lock is known as Threading._tstate_lock in the threading module. The release_sentinel() function uses the Python C API. The problem is that on_delete is called late in the Python finalization, when the C API is no longer fully working. The PyThreadState_Clear() function now calls the PyThreadState.on_delete callback. Previously, that happened in PyThreadState_Delete(). The release_sentinel() function is now called when the C API is still fully working.
* bpo-39487: Merge duplicated _Py_IDENTIFIER identifiers in C code (GH-18254)Hai Shi2020-01-304-12/+7
| | | Moving repetitive `_Py_IDENTIFIER` instances to a global location helps identify them more easily in regards to sub-interpreter support.
* bpo-38631: Replace Py_FatalError() with assert() in ceval.c (GH-18279)Victor Stinner2020-01-301-10/+4
| | | | | | | Replace a few Py_FatalError() calls if tstate is NULL with assert(tstate != NULL) in ceval.c. PyEval_AcquireThread(), PyEval_ReleaseThread() and PyEval_RestoreThread() must never be called with a NULL tstate.
* bpo-38960: DTrace build fix for FreeBSD. (GH-17451)David Carlier2020-01-283-6/+6
| | | | | | | | DTrace build fix for FreeBSD. - allowing passing an extra flag as it need to define the arch size. - casting some probe's arguments.
* bpo-38644: Pass tstate in ceval.c (GH-18222)Victor Stinner2020-01-281-6/+6
| | | Pass explicitly the Python thread state (tstate) in ceval.c.
* bpo-38631: Avoid Py_FatalError() in _PyCodecRegistry_Init() (GH-18217)Victor Stinner2020-01-271-16/+21
| | | | _PyCodecRegistry_Init() now reports exceptions to the caller, rather than calling Py_FatalError().
* bpo-39320: Handle unpacking of **values in compiler (GH-18141)Mark Shannon2020-01-275-3642/+3653
| | | | | | | | | | | | | * Add DICT_UPDATE and DICT_MERGE bytecodes. Use them for ** unpacking. * Remove BUILD_MAP_UNPACK and BUILD_MAP_UNPACK_WITH_CALL, as they are now unused. * Update magic number for ** unpacking opcodes. * Update dis.rst to incorporate new bytecodes. * Add blurb entry.
* bpo-39320: Handle unpacking of *values in compiler (GH-17984)Mark Shannon2020-01-234-2308/+2300
| | | | | | | | * Add three new bytecodes: LIST_TO_TUPLE, LIST_EXTEND, SET_UPDATE. Use them to implement star unpacking expressions. * Remove four bytecodes BUILD_LIST_UNPACK, BUILD_TUPLE_UNPACK, BUILD_SET_UNPACK and BUILD_TUPLE_UNPACK_WITH_CALL opcodes as they are now unused. * Update magic number and dis.rst for new bytecodes.
* bpo-39427: Document -X opt options in the CLI --help and the man page (GH-18131)Pablo Galindo2020-01-221-1/+32
| | | | | | | https://bugs.python.org/issue39427 Automerge-Triggered-By: @pablogsal
* bpo-39336: Allow packages to not let their child modules be set on them (#18006)Dino Viehland2020-01-221-337/+346
| | | | | * bpo-39336: Allow setattr to fail on modules which aren't assignable When attaching a child module to a package if the object in sys.modules raises an AttributeError (e.g. because it is immutable) it causes the whole import to fail. This now allows immutable packages to exist and an ImportWarning is reported and the AttributeError exception is ignored.
* bpo-31031: Unify duplicate bits_in_digit and bit_length (GH-2866)Niklas Fiekas2020-01-161-0/+15
| | | Add _Py_bit_length() to unify duplicate bits_in_digit() and bit_length().
* Fix compiler warning on Windows (GH-18012)Ammar Askar2020-01-151-1/+1
| | | | | | | | Python-ast.h contains a macro named Yield that conflicts with the Yield macro in Windows system headers. While Python-ast.h has an "undef Yield" directive to prevent this, it means that Python-ast.h must be included before Windows header files or we run into a re-declaration warning. In commit c96be811fa7d an include for pycore_pystate.h was added which indirectly includes Windows header files. In this commit we re-order the includes to fix this warning.
* bpo-39164: Fix compiler warning in PyErr_GetExcInfo() (GH-18010)Victor Stinner2020-01-151-1/+1
| | | The function has no return value.
* bpo-39048: Look up __aenter__ before __aexit__ in async with (GH-17609)Géry Ogam2020-01-141-9/+10
| | | | | | * Reorder the __aenter__ and __aexit__ checks for async with * Add assertions for async with body being skipped * Swap __aexit__ and __aenter__ loading in the documentation
* bpo-39156: Break up COMPARE_OP into four logically distinct opcodes. (GH-17754)Mark Shannon2020-01-147-4753/+4780
| | | | | | | | Break up COMPARE_OP into four logically distinct opcodes: * COMPARE_OP for rich comparisons * IS_OP for 'is' and 'is not' tests * CONTAINS_OP for 'in' and 'is not' tests * JUMP_IF_NOT_EXC_MATCH for checking exceptions in 'try-except' statements.
* bpo-38644: Pass tstate to _Py_FinishPendingCalls() (GH-17990)Victor Stinner2020-01-132-3/+3
| | | | _Py_FinishPendingCalls() now expects a tstate argument, instead of a runtime argument.
* bpo-39164: Add private _PyErr_GetExcInfo() function (GH-17752)Julien Danjou2020-01-131-4/+10
| | | | | | This adds a new function named _PyErr_GetExcInfo() that is a variation of the original PyErr_GetExcInfo() taking a PyThreadState as its first argument. That function allows to retrieve the exceptions information of any Python thread -- not only the current one.
* Cleanup exit code for interpreter. (GH-17756)Mark Shannon2020-01-131-6/+5
|
* bpo-39200: Correct the error message for min/max builtin function (GH-17814)Dong-hee Na2020-01-101-2/+7
| | | | Correct the error message when calling the min() or max() with no arguments.
* bpo-39166: Fix trace of last iteration of async for loops (#17800)Pablo Galindo2020-01-101-5/+9
|
* bpo-39235: Fix end location for genexp in call args (GH-17925)Guido van Rossum2020-01-091-8/+8
| | | | | | The fix changes copy_location() to require an extra node from which to extract the end location, and fixing all 5 call sites. https://bugs.python.org/issue39235
* bpo-39270: Remove dead assignment from config_init_module_search_paths ↵Alex Henrie2020-01-091-2/+1
| | | | (GH-17914)
* closes bpo-39261: Remove dead assignment from pyinit_config. (GH-17907)Alex Henrie2020-01-081-1/+0
|
* bpo-29778: Fix incorrect NULL check in _PyPathConfig_InitDLLPath() (GH-17818)Anthony Wee2020-01-061-1/+1
|
* Fix constant folding optimization for positional only arguments (GH-17837)Anthony Sottile2020-01-051-0/+1
|
* Fix SystemError when nested function has annotation on positional-only ↵Anthony Sottile2020-01-051-0/+2
| | | | argument (GH-17826)
* Bring Python into the next decade. (GH-17801)Benjamin Peterson2020-01-021-1/+1
|
* bpo-39114: Fix tracing of except handlers with name binding (GH-17769)Pablo Galindo2020-01-021-1/+3
| | | When producing the bytecode of exception handlers with name binding (like `except Exception as e`) we need to produce a try-finally block to make sure that the name is deleted after the handler is executed to prevent cycles in the stack frame objects. The bytecode associated with this try-finally block does not have source lines associated and it was causing problems when the tracing functionality was running over it.
* bpo-13601: always use line-buffering for sys.stderr (GH-17646)Jendrik Seipp2020-01-011-1/+1
|
* bpo-39176: Improve error message for 'named assignment' (GH-17777)Ned Batchelder2019-12-311-1/+1
|
* closes bpo-37446: resolve undefined behavior in Python/hamt.c (GH-17727)Batuhan Taşkaya2019-12-301-1/+1
|
* Fix handling of line numbers around finally-blocks. (#17737)Mark Shannon2019-12-302-1622/+1626
|
* bpo-39028: Performance enhancement in keyword extraction (GH-17576)Sebastian Berg2019-12-181-3/+7
| | | | | | | | All keywords should first be checked for pointer identity. Only after that failed for all keywords (unlikely) should unicode equality be used. The original code would call unicode equality on any non-matching keyword argument. Meaning calling it often e.g. when a function has many kwargs but only the last one is provided.
* bpo-39080: Starred Expression's column offset fix when inside a CALL (GH-17645)Lysandros Nikolaou2019-12-181-1/+1
| | | | Co-Authored-By: Pablo Galindo <Pablogsal@gmail.com>
* bpo-38858: Small integer per interpreter (GH-17315)Victor Stinner2019-12-171-4/+9
| | | | | | | | | | | | Each Python subinterpreter now has its own "small integer singletons": numbers in [-5; 257] range. It is no longer possible to change the number of small integers at build time by overriding NSMALLNEGINTS and NSMALLPOSINTS macros: macros should now be modified manually in pycore_pystate.h header file. For now, continue to share _PyLong_Zero and _PyLong_One singletons between all subinterpreters.
* bpo-39033: Fix NameError in zipimport during hash validation (GH-17588)Xtreak2019-12-161-268/+267
| | | | Patch by Karthikeyan Singaravelan.
* The comment in ast_for_namedexpr shouldn't include if_stmt (GH-17586)Guido van Rossum2019-12-151-3/+1
| | | Automerge-Triggered-By: @gvanrossum
* Fix elif start column offset when there is an else following (GH-17596)Lysandros Nikolaou2019-12-141-2/+2
|
* Add PYTHONUTF8 to commandline usage. (GH-17587)Inada Naoki2019-12-141-0/+1
| | | | Co-Authored-By: Victor Stinner <vstinner@python.org>
* bpo-39031: Include elif keyword when producing lineno/col-offset info for ↵Lysandros Nikolaou2019-12-121-2/+2
| | | | | | | | | | | | if_stmt (GH-17582) When parsing an "elif" node, lineno and col_offset of the node now point to the "elif" keyword and not to its condition, making it consistent with the "if" node. https://bugs.python.org/issue39031 Automerge-Triggered-By: @pablogsal