Commit graph

34715 commits

Author SHA1 Message Date
Ken Jin
e02a35c365
gh-134584: Cleanups for GH-135860 (GH-142604) 2025-12-13 14:38:10 +00:00
Neil Schemenauer
c98182be8d
gh-132657: Add lock-free set contains implementation (#132290)
This roughly follows what was done for dictobject to make a lock-free
lookup operation. With this change, the set contains operation scales much
better when used from multiple-threads. The frozenset contains performance
seems unchanged (as already lock-free).

Summary of changes:

* refactor set_lookkey() into set_do_lookup() which now takes a function
  pointer that does the entry comparison. This is similar to dictobject and
  do_lookup(). In an optimized build, the comparison function is inlined and
  there should be no performance cost to this.

* change set_do_lookup() to return a status separately from the entry value

* add set_compare_frozenset() and use if the object is a frozenset. For the
  free-threaded build, this avoids some overhead (locking, atomic operations,
  incref/decref on key)

* use FT_ATOMIC_* macros as needed for atomic loads and stores

* use a deferred free on the set table array, if shared (only on free-threaded
  build, normal build always does an immediate free)

* for free-threaded build, use explicit for loop to zero the table, rather than memcpy()

* when mutating the set, assign so->table to NULL while the change is a
  happening. Assign the real table array after the change is done.
2025-12-13 09:50:23 +00:00
Amer Esmail Elsheikh
57db12514a
gh-139686: Make reloading a lazy module no-op (GH-139857)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Brett Cannon <brett@python.org>
2025-12-12 20:26:50 +00:00
Savannah Ostrowski
8b669d54c3
GH-142389: Add backtick markup support in description and epilog (#142390) 2025-12-12 20:08:19 +00:00
Alper
1eddef8193
gh-116738: Make zlib module thread-safe (gh-142432)
Makes the zlib module thread-safe free-threading build. Even though operations
are protected by locks, attributes exposed via PyMemberDef (eof, needs_input,
unused_data, unconsumed_tail) should still be stored atomically within locked
sections, since they can be read without acquiring the lock.
2025-12-12 13:14:42 -05:00
Alex Prengère
6d644e4453
gh-141939: Add colors to interpolated values in argparse (#141940)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Savannah Ostrowski <savannah@python.org>
2025-12-12 16:58:12 +00:00
Bartosz Sławecki
f564654bae
gh-142353: Isolate tests from personal GNU Readline init files (#142370)
Isolate tests from personal Readline init files using `INPUTRC=/dev/null` trick.

Co-authored-by: Victor Stinner <vstinner@python.org>
2025-12-12 15:42:38 +01:00
Ken Jin
a3a611b042
gh-134584: Revert partially GH-135860 (GH-142620) 2025-12-12 14:04:11 +00:00
Pablo Galindo Salgado
1356fbed7b
gh-142374: Fix recursive function cumulative over-counting in sampling profiler (#142378) 2025-12-12 00:50:17 +00:00
Pablo Galindo Salgado
6a0135a392
gh-138122: Add exception profiling mode to the sampling profiler (#142561) 2025-12-11 20:46:34 +00:00
Neil Schemenauer
e38967ed60
gh-142531: Fix free-threaded GC performance regression (gh-142562)
If there are many untracked tuples, the GC will run too often, resulting
in poor performance.  The fix is to include untracked tuples in the
"long lived" object count. The number of frozen objects is also now
included since the free-threaded GC must scan those too.
2025-12-11 12:30:56 -08:00
Brett Cannon
af185727b2
GH-65961: Stop setting __cached__ on modules (GH-142165) 2025-12-11 11:44:46 -08:00
Sam Gross
a26c831bc4
gh-142589: Fix PyUnstable_Object_IsUniqueReferencedTemporary (gh-142593)
PyUnstable_Object_IsUniqueReferencedTemporary wasn't handling tagged
ints on the evaluation stack properly.
2025-12-11 14:41:03 -05:00
Brett Cannon
dac4589726
GH-142203: Remove the debug_override parameter from packaging.util.cache_from_source() (GH-142204) 2025-12-11 09:55:47 -08:00
Donghee Na
a27538540e
gh-134584: Eliminate redundant refcounting from `_CALL_LEN` (gh-136104) 2025-12-11 15:24:34 +00:00
Pablo Galindo Salgado
c433986005
gh-142236: Improve error location for missing comma in string concatenations (#142330) 2025-12-11 14:47:26 +00:00
Noam Cohen
a78f43b001
gh-134584: Eliminate redundant refcounting from _CALL_TUPLE_1 (GH-135860) 2025-12-11 14:31:28 +00:00
elenril
79aa43a979
gh-79986: Add parsing for References/In-Reply-To email headers (#137201)
This is a followup to 46d88a1131 (#13397),
which added parsing for Message-ID. Similar handling is needed for the
other two identification headers.
2025-12-11 09:20:53 -05:00
Kumar Aditya
42d2bedb87
gh-142556: fix crash when a task gets re-registered during finalization in asyncio (#142565) 2025-12-11 15:04:49 +05:30
Stan Ulbrych
b52e8ce4af
gh-142539: Fix traceback caret location calculation for SyntaxErrors with wide chars (#142540) 2025-12-11 04:20:55 +00:00
Pablo Galindo Salgado
5b19c75b47
gh-138122: Make the tachyon profiler opcode-aware (#142394) 2025-12-11 03:41:47 +00:00
Steve Dower
fa448451ab
gh-140172: Skip JSON tools test during PGO training (GH-140809) 2025-12-11 00:34:49 +00:00
Brett Cannon
880a7905ca
GH-97850: Remove all uses and definitions of load_module() from importlib (#142205) 2025-12-10 15:35:51 -08:00
Victor Stinner
dc3ece2bc0
gh-142489: Increase ssl_handshake_timeout in asyncio tests (#142523)
Replace SHORT_TIMEOUT with LONG_TIMEOUT for very slow CIs.
And add the HANDSHAKE_TIMEOUT constant.
2025-12-10 22:21:03 +00:00
Ethan Furman
26757d1351
gh-135559: [Enum] dir() on a Flag now shows aliases (GH-136527) 2025-12-10 11:46:10 -08:00
dr-carlos
70671267c1
gh-142029: Raise ValueError instead of crashing on empty name given to create_builtin() (#142033)
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-12-10 12:01:57 +05:30
Bartosz Sławecki
d716e3b2dd
gh-142315: Don't pass the "real path" of Pdb script target to system functions (#142371)
* Pick target depending on preconditions

* Clarify the news fragment

* Add test capturing missed expectation.

* Add more idiomatic safe realpath helper

* Restore logic where existance and directoriness are checked on realpath.

* Link GH issue to test.

* Extract a function to check the target. Remove the _safe_realpath, now no longer needed.

* Extract method for replacing sys_path, and isolate realpath usage there.

* Revert "Extract method for replacing sys_path, and isolate realpath usage there."

This reverts commit 855aac3d28.

* Restore _safe_realpath.

---------

Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
2025-12-09 20:04:49 -05:00
Fabian Henze
1adb17b1a2
gh-112527: Fix help text for required options in argparse (GH-112528)
For optional arguments with required=True, the ArgumentDefaultsHelpFormatter
would always add a " (default: None)" to the end of the help text.
Since that's a bit misleading, it is removed with this commit.
2025-12-09 16:48:35 +00:00
Victor Stinner
b20722c300
gh-142447: Fix cast warning in pycore_backoff.h (#142465)
MAKE_VALUE_AND_BACKOFF() macro casts its result to uint16_t.

Add pycore_backoff.h header to test_cppext tests.
2025-12-09 17:03:13 +01:00
Filipe Laíns
1b460fcddc
gh-84530: fix namespace package support in modulefinder (#29196)
* bpo-40350: fix namespace package support in modulefinder

Signed-off-by: Filipe Laíns <lains@riseup.net>

* consider that namespace package specs might have the loader set

Signed-off-by: Filipe Laíns <lains@riseup.net>

* Revert "consider that namespace package specs might have the loader set"

This reverts commit 23fb4e0de3.

Signed-off-by: Filipe Laíns <lains@riseup.net>

* Fix load_module and load_package to handle namespace packages

Signed-off-by: Filipe Laíns <lains@riseup.net>

* Drop _NAMESPACE constant

Signed-off-by: Filipe Laíns <lains@riseup.net>

* Drop importlib changes

Signed-off-by: Filipe Laíns <lains@riseup.net>

* Update NamespacePath check

Signed-off-by: Filipe Laíns <lains@riseup.net>

* Mixed some

Signed-off-by: Filipe Laíns <lains@riseup.net>

---------

Signed-off-by: Filipe Laíns <lains@riseup.net>
2025-12-09 15:50:50 +00:00
Jeong, YunWon
3ec941b364
gh-142282 Fix winreg.QueryValueEx() under race condition (GH-142283) 2025-12-09 12:09:07 +00:00
Ken Jin
97f0a1f203
gh-142276: Watch attribute loads when promoting JIT constants (GH-142303)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Savannah Ostrowski <savannah@python.org>
2025-12-08 18:03:15 +00:00
Zanie Blue
e3539e99e3
gh-140125: Increase object recursion depth for test_json from 200k to 500k (#142226)
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-12-08 14:05:13 +01:00
Frost Ming
7099af8f5e
gh-139946: distinguish stdout or stderr when colorizing output in argparse (#140495)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Savannah Ostrowski <savannah@python.org>
2025-12-08 04:08:06 +00:00
Pablo Galindo Salgado
ef51a7c8f3
gh-138122: Make sampling profiler integration tests more resilient (#142382)
The tests were flaky on slow machines because subprocesses could finish
before enough samples were collected. This adds synchronization similar
to test_external_inspection: test scripts now signal when they start
working, and the profiler waits for this signal before sampling.

Test scripts now run in infinite loops until killed rather than for
fixed iterations, ensuring the profiler always has active work to
sample regardless of machine speed.
2025-12-07 22:41:15 +00:00
dr-carlos
ff2577f56e
gh-141732: Fix ExceptionGroup repr changing when original exception sequence is mutated (#141736) 2025-12-07 21:04:04 +00:00
Savannah Ostrowski
dc9f2385ed
GH-139862: Fix direct instantiation of HelpFormatter (#142384) 2025-12-07 21:02:12 +00:00
Malcolm Smith
f193c8fe9e
gh-141794: Reduce size of compiler stress tests to fix Android warnings (#142263) 2025-12-07 22:01:01 +02:00
Serhiy Storchaka
1db9f56bff
gh-142346: Fix usage formatting for mutually exclusive groups in argparse (GH-142381)
Support groups preceded by positional arguments or followed or intermixed
with other optional arguments. Support empty groups.
2025-12-07 21:36:01 +02:00
Pablo Galindo Salgado
d6d850df89
gh-138122: Don't sample partial frame chains (#141912) 2025-12-07 15:53:48 +00:00
Pablo Galindo Salgado
edff5aaa48
gh-142368: Refactor test_external_inspection to reduce flakiness in parallel execution (#142369) 2025-12-07 02:32:20 +00:00
Pablo Galindo Salgado
572c780aa8
gh-138122: Implement frame caching in RemoteUnwinder to reduce memory reads (#142137)
This PR implements frame caching in the RemoteUnwinder class to significantly reduce memory reads when profiling remote processes with deep call stacks.

When cache_frames=True, the unwinder stores the frame chain from each sample and reuses unchanged portions in subsequent samples. Since most profiling samples capture similar call stacks (especially the parent frames), this optimization avoids repeatedly reading the same frame data from the target process.

The implementation adds a last_profiled_frame field to the thread state that tracks where the previous sample stopped. On the next sample, if the current frame chain reaches this marker, the cached frames from that point onward are reused instead of being re-read from remote memory.

The sampling profiler now enables frame caching by default.
2025-12-06 22:37:34 +00:00
Ivo Bellin Salarin
9d707d8a64
gh-68552: fix defects policy (#138579)
Extend defect handling via policy to a couple of missed defects.

---------

Co-authored-by: Martin Panter <vadmium@users.noreply.github.com>
Co-authored-by: Ivo Bellin Salarin <ivo@nilleb.com>
2025-12-06 16:54:29 -05:00
Pablo Galindo Salgado
ed4f78a4b3
gh-142236: Fix incorrect keyword suggestions for syntax errors (#142328)
The keyword typo suggestion mechanism in traceback would incorrectly
suggest replacements when the extracted source code was merely incomplete
rather than containing an actual typo. For example, when a missing comma
caused a syntax error, the system would suggest replacing 'print' with
'not' because the incomplete code snippet happened to pass validation.

The fix adds a validation step that first checks whether the original
extracted code raises a SyntaxError. If the code compiles successfully
or is simply incomplete (compile_command returns None), the function
returns early since there is no way to verify that a keyword replacement
would actually fix the problem.
2025-12-06 21:09:35 +00:00
Paresh Joshi
07eff899d8
gh-142006: Fix HeaderWriteError in email.policy.default caused by extra newline (#142008)
RDM: This fixes a subtle folding error that showed up when a token exactly filled a line and was followed by whitespace and a token with no folding whitespace that was longer than a line.  In this particular circumstance the whitespace after the first token got pushed on to the next line, and then stolen to go in front of the next unfoldable token...leaving a completely empty line in the line buffer.  That line got turned in to a newline, which is RFC illegal, and the newish security check caught it.  The fix is to just delete that empty line from the buffer.

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2025-12-06 15:59:35 -05:00
Sanyam Khurana
100e316e53
gh-69113: Fix doctest to report line numbers for __test__ strings (#141624)
Enhanced the _find_lineno method in doctest to correctly identify and
report line numbers for doctests defined in __test__ dictionaries when
formatted as triple-quoted strings.

Finds a non-blank line in the test string and matches it in the source
file, verifying subsequent lines also match to handle duplicate lines.

Previously, doctest would report "line None" for __test__ dictionary
strings, making it difficult to debug failing tests.

Co-authored-by: Jurjen N.E. Bos <jneb@users.sourceforge.net>
Co-authored-by: R. David Murray <rdmurray@bitdance.com>
2025-12-06 15:47:08 -05:00
ivonastojanovic
c91c373ef6
gh-140677 Improve heatmap colors (#142241)
Co-authored-by: Pablo Galindo Salgado <pablogsal@gmail.com>
2025-12-06 20:27:16 +00:00
Kaisheng Xu
14715e3a64
gh-105836: Fix asyncio.run_coroutine_threadsafe leaving underlying cancelled asyncio task running (#141696)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-12-06 19:33:25 +00:00
Savannah Ostrowski
56a442d0d8
GH-141565: Add async code awareness to Tachyon (#141533)
Co-authored-by: Pablo Galindo Salgado <pablogsal@gmail.com>
2025-12-06 19:31:40 +00:00
Savannah Ostrowski
0ed56ed88f
GH-64532: Include parent's required optional arguments in subparser usage (#142355) 2025-12-06 18:30:50 +00:00