Sam Gross [Tue, 4 Mar 2025 23:35:22 +0000 (18:35 -0500)]
[3.13] gh-130794: Process interpreter QSBR queue in _PyMem_AbandonDelayed. (gh-130808) (#130857)
This avoids a case where the interpreter's queue of memory to be freed
could grow rapidly if there are many short lived threads.
(cherry picked from commit 2f6e0e9f7001769be746ee96356656d3ebdc7f96)
[3.13] gh-130727: Retry test_wmi on TimeoutError (GH-130832) (#130839)
gh-130727: Retry test_wmi on TimeoutError (GH-130832)
Use sleeping_retry() in test_wmi to retry multiple times on
TimeoutError. Wait up to LONG_TIMEOUT seconds (5 minutes by default).
(cherry picked from commit f67ff9e82071b21c1960401aed4844b00b5bfb53)
Co-authored-by: Victor Stinner <vstinner@python.org>
Replace hardcoded delay (100 ms) with a loop awaiting until a
condition is true: replace assertReturnsIfImplemented() with
assertReachesEventually().
Use sleeping_retry() in assertReachesEventually() to tolerate slow
buildbots and raise an exception on timeout (30 seconds).
(cherry picked from commit 8a64a62002fa3cdc93cb4cfee315edb235cad8cb)
Co-authored-by: Victor Stinner <vstinner@python.org>
[3.13] gh-128388: pyrepl on Windows: add meta and ctrl+arrow keybindings (GH-128389) (GH-130500)
gh-128388: pyrepl on Windows: add meta and ctrl+arrow keybindings (GH-128389)
Fix `Lib/_pyrepl/windows_console.py` to support more keybindings, like the
`Ctrl`+`←` and `Ctrl`+`→` word-skipping keybindings and those with meta (i.e. Alt),
e.g. to `kill-word` or `backward-kill-word`.
Specifics: if Ctrl is pressed, emit "ctrl left" and "ctrl right" instead of just "left" or
"right," and if Meta/Alt is pressed, emit the special key code for meta before
emitting the other key that was pressed.
(cherry picked from commit 688f3a0d4b94874ff6d72af3baafd8bbf911153e)
Co-authored-by: Paulie Peña <203125+paulie4@users.noreply.github.com> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
[3.13] Docs: Fix a misplaced statement in the document for `ServerProxy` (GH-130616) (GH-130640)
Docs: Fix a misplaced statement in the document for `ServerProxy` (GH-130616)
The sentence "If an HTTPS URL ..." explains what the parameter means,
so moved it to the paragraph explaining what the other parameters mean.
(cherry picked from commit b26286ca49d87ad8491e411f7b0283b0f15ad5be)
Bénédikt Tran [Mon, 3 Mar 2025 12:09:59 +0000 (13:09 +0100)]
[3.13] gh-130740: Move some `stdbool.h` includes after `Python.h` (#130738) (#130756)
gh-130740: Move some `stdbool.h` includes after `Python.h` (#130738)
Move some `#include <stdbool.h>` after `#include "Python.h"` when `pyconfig.h` is not
included first and when we are in a platform-agnostic context. This is to avoid having
features defined by `stdbool.h` before those decided by `Python.h` (this caused some
build failures when compiling CPython with `zig cc`).
Bénédikt Tran [Mon, 3 Mar 2025 11:01:01 +0000 (12:01 +0100)]
[3.13] gh-127667: fix memory leaks in `hashlib` (GH-127668) (#130784)
gh-127667: fix memory leaks in `hashlib` (GH-127668)
- Correctly handle `NULL` values returned by `EVP_MD_CTX_md`.
- Correctly free resources in error branches.
- Consistently suppress `_setException()` return value when needed.
- Collapse `_setException() + return NULL` into a single statement.
[3.13] gh-128481: indicate that the default value for `FrameSummary.end_lineno` changed in 3.13 (GH-130755) (#130767)
gh-128481: indicate that the default value for `FrameSummary.end_lineno` changed in 3.13 (GH-130755)
The value taken by `FrameSummary.end_lineno` when passing `end_lineno=None` changed in gh-112097.
Previously, a `end_lineno` could be specified to be `None` directly but since 939fc6d, passing None makes
the constructor use the value of `lineno` instead.
(cherry picked from commit c6513f7a627c8918a5e3f3733fa47d34a94ddff9)
[3.13] Add link in the `importlib.metadata.version()` docs (GH-130739) (#130761)
Add link in the `importlib.metadata.version()` docs (GH-130739)
Link the specification for the returned data makes it clearer what this is
and what the format of the version string can be.
(cherry picked from commit c71e55869e7bc56b2bd04f3055f810026a66c076)
Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>
[3.13] gh-128481: Improve documentation for `traceback.FrameSummary` (GH-128484) (#130753)
* gh-128481: Improve documentation for `traceback.FrameSummary` (GH-128484)
Complete the `traceback.FrameSummary` signature and add missing
documentation for the `colno` and `end_{col,line}no` attributes.
(cherry picked from commit 051f0e5683fec3840fa7fc99723741dd2d701eae)
Sam Gross [Fri, 28 Feb 2025 14:53:35 +0000 (09:53 -0500)]
[3.13] gh-124878: Add temporary TSAN suppression for free_threadstate (gh-130602) (gh-130687)
The race condition with `free_threadstate` and daemon threads exists in
both the free threading and default builds. We were missing a
suppression in the default build.
(cherry picked from commit cc17307faaa248535c65f6a7668e06dc8ef04575)
Victor Stinner [Fri, 28 Feb 2025 09:40:06 +0000 (10:40 +0100)]
[3.13] Postpone <stdbool.h> inclusion after Python.h (#130641) (#130675)
Postpone <stdbool.h> inclusion after Python.h (#130641)
Remove inclusions prior to Python.h.
<stdbool.h> will cause <features.h> to be included before Python.h can
define some macros to enable some additional features, causing multiple
types not to be defined down the line.
A reference loop was resulting in the `fileobj` held by the `GzipFile`
being closed before the `GzipFile`.
The issue started with gh-89550 in 3.12, but was hidden in most cases
until 3.13 when gh-62948 made it more visible.
(cherry picked from commit 7f39137662f637518a74228286e7ec675fa4e27d)
[3.13] gh-129200: Add locking to the iOS testbed startup sequence. (GH-130564) (#130657)
Add a lock to ensure that only one iOS testbed per user can start at a time, so
that the simulator discovery process doesn't collide between instances.
(cherry picked from commit 9211b3dabeacb92713ac3f5f0fa43bc7cf69afd8)
Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
Sam Gross [Wed, 26 Feb 2025 18:59:59 +0000 (13:59 -0500)]
[3.13] gh-117657: Enable test_opcache under TSAN (GH-129831) (GH-130597)
Fix a few thread-safety bugs to enable test_opcache when run with TSAN:
* Use relaxed atomics when clearing `ht->_spec_cache.getitem`
(gh-115999)
* Add temporary suppression for type slot modifications (gh-127266)
* Use atomic load when reading `*dictptr`
Serhiy Storchaka [Tue, 25 Feb 2025 22:50:26 +0000 (00:50 +0200)]
[3.13] gh-130163: Fix crashes related to PySys_GetObject() (GH-130503) (GH-130556)
The use of PySys_GetObject() and _PySys_GetAttr(), which return a borrowed
reference, has been replaced by using one of the following functions, which
return a strong reference and distinguish a missing attribute from an error:
_PySys_GetOptionalAttr(), _PySys_GetOptionalAttrString(),
_PySys_GetRequiredAttr(), and _PySys_GetRequiredAttrString().
(cherry picked from commit 0ef4ffeefd1737c18dc9326133c7894d58108c2e)
[3.13] gh-46236: Add docs for PyUnicode_GetDefaultEncoding() doc (GH-130335) (GH-130511)
* Clarify sys.getdefaultencoding() documentation
* Add missing documentation for PyUnicode_GetDefaultEncoding,
the C equivalent of sys.getdefaultencoding
(cherry picked from commit 9f25c1f012c8d432a93bf2dcad5f19a64dc00d3c)
Co-authored-by: RUANG (James Roy) <longjinyii@outlook.com>
[3.13] gh-130151: Fix reference leaks in `_hashlib.hmac_{new,digest}` (GH-130152) (#130491)
gh-130151: Fix reference leaks in `_hashlib.hmac_{new,digest}` (GH-130152)
* fix leak in `_hashlib.hmac_new`
* fix leak in `hmac_digest`
* fix exception type in `_hashlib.HMAC.copy`
(cherry picked from commit 071820113f11b8f6a21f98652d0840e10268114c)
[3.13] gh-129712: Document the wheels tags corresponding to each universal SDK. (GH-130389) (#130449)
Document the architectures supported by macOS universal SDK configuration flags,
and add details on wheel tag naming.
(cherry picked from commit 474c388740ca5f8060c074f517dd14c54409126f)
Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
First, write the test name without color. Then, write the test name
and the result with color. Each test is displayed twice.
(cherry picked from commit f1b81c408fb83beeee519ae4fb9d3a36dd4522b3)
Co-authored-by: Victor Stinner <vstinner@python.org> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Newer GCC versions accept both __attribute__((no_sanitize("undefined")))
and __attribute__((no_sanitize_undefined)) so check that the macro is
not already defined.
(cherry picked from commit 568db400ff07240a5ed6f263af281405ccaec716)
Sam Gross [Thu, 20 Feb 2025 15:42:47 +0000 (10:42 -0500)]
[3.13] gh-129269: Exclude everything in sys.path in `test_coverage_ignore` (gh-130133) (gh-130357)
The `test_trace.test_coverage_ignore` test would fail if you had
`setuptools` installed, such as in `~/.local/lib/python3.xxx/site-packages/`.
Ignore everything in `sys.path` when running the test.
(cherry picked from commit 35925e952911aba97bfdaee85b09d734ceac4fea)
[3.13] gh-130250: use support.swap_attr() in test and don't assume we're beginning with a clean system state (GH-130342) (#130344)
gh-130250: use support.swap_attr() in test and don't assume we're beginning with a clean system state (GH-130342)
(cherry picked from commit 048ee2d5ec761296ef67f5c59aee1f24408b12db)
[3.13] gh-69001: Convert links to more usable buttons (GH-129591) (#130338)
gh-69001: Convert links to more usable buttons (GH-129591)
In Lib/idlelib/help_about.py, there are 2 links that are not underlined or colored, hence hard to tell that clicking works. All buttons might get converted to colored and underlined links in the future.
---------
(cherry picked from commit ed831b95a231ef949da13a261b40ee1ea0e126d7)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Tian Gao [Wed, 19 Feb 2025 17:40:03 +0000 (12:40 -0500)]
[3.13] gh-128396: Fix a crash when inline comprehension has the same … (#130311)
[3.13] gh-128396: Fix a crash when inline comprehension has the same local variable as the outside scope (GH-130235)
(cherry picked from commit ccf17323c218a2fdcf7f4845d3eaa74ebddefa44)
Stan Ulbrych [Mon, 17 Feb 2025 14:02:39 +0000 (14:02 +0000)]
[3.13] gh-82045: Correct and deduplicate "isprintable" docs; add test. (GH-130127)
We had the definition of what makes a character "printable" documented in three places, giving two different definitions.
The definition in the comment on `_PyUnicode_IsPrintable` was inverted; correct that.
With that correction, the two definitions turn out to be equivalent -- but to confirm that, you have to go look up, or happen to know, that those are the only five "Other" categories and only three "Separator" categories in the Unicode character database. That makes it hard for the reader to tell whether they really are the same, or if there's some subtle difference in the intended semantics.
Fix that by cutting the C API docs' and the C comment's copies of the subtle details, in favor of referring to the Python-level docs. That ensures it's explicit that these are all meant to agree, and also lets us concentrate improvements to the wording in one place.
Speaking of which, borrow some ideas from the C comment, along with other tweaks, to hopefully add a bit more clarity to that one newly-centralized copy in the docs.
Also add a thorough test that the implementation agrees with this definition.