Commit graph

56122 commits

Author SHA1 Message Date
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
0dd83111ab
Tachyon: Fix heatmap line highlight animation overriding heat colors (#142522) 2025-12-11 04:30:16 +00:00
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
Stan Ulbrych
2db9573e23
Tachyon: Set favicon for heatmap pages (#142493) 2025-12-10 14:10:23 +00: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
Stan Ulbrych
b5576d8146
Tachyon: Remove spurious CSS for stat-card (#142487) 2025-12-09 19:13:54 +00:00
Stan Ulbrych
9b4ce3c429
Tachyon: Make "Tachyon" in navbar link to index.html (#142486) 2025-12-09 18:51:57 +00:00
Stan Ulbrych
09d6bf20b6
Tachyon: Fix unesecarry plural when there is a single file/sample (#142478) 2025-12-09 17:45:52 +00: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
Pablo Galindo Salgado
4279785b31
gh-140727: Restructure profiling documentation for PEP 799 (#142373)
* Add profiling module documentation structure

PEP 799 introduces a new `profiling` package that reorganizes Python's
profiling tools under a unified namespace. This commit adds the documentation
structure to match: a main entry point (profiling.rst) that helps users choose
between profilers, detailed docs for the tracing profiler (profiling-tracing.rst),
and separated pstats documentation.

The tracing profiler docs note that cProfile remains as a backward-compatible
alias, so existing code continues to work. The pstats module gets its own page
since it's used by both profiler types and deserves focused documentation.

* Add profiling.sampling documentation

The sampling profiler is new in Python 3.15 and works fundamentally differently
from the tracing profiler. It observes programs from outside by periodically
capturing stack snapshots, which means zero overhead on the profiled code. This
makes it practical for production use where you can attach to live servers.

The docs explain the key concepts (statistical vs deterministic profiling),
provide quick examples upfront, document all output formats (pstats, flamegraph,
gecko, heatmap), and cover the live TUI mode. The defaults table helps users
understand what happens without any flags.

* Wire profiling docs into the documentation tree

Add the new profiling module pages to the Debugging and Profiling toctree.
The order places the main profiling.rst entry point first, followed by the
two profiler implementations, then pstats, and finally the deprecated profile
module last.

* Convert profile.rst to deprecation stub

The pure Python profile module is deprecated in 3.15 and scheduled for removal
in 3.17. Users should migrate to profiling.tracing (or use the cProfile alias
which continues to work).

The page now focuses on helping existing users migrate: it shows the old vs new
import style, keeps the shared API reference since both modules have the same
interface, and preserves the calibration docs for anyone still using the pure
Python implementation during the transition period.

* Update CLI module references for profiling restructure

Point cProfile to profiling.tracing docs and add profiling.sampling to the
list of modules with CLI interfaces. The old profile-cli label no longer
exists after the documentation restructure.

* Update whatsnew to link to profiling module docs

Enable cross-references to the new profiling module documentation and update
the CLI examples to use the current syntax with the attach subcommand. Also
reference profiling.tracing instead of cProfile since that's the new canonical
name.
2025-12-09 12:55:04 +00:00
Adam Turner
c5825ff4c9
GH-139436: Remove PDF and CHM from IDLE HelpSource (#140418) 2025-12-09 12:32:53 +00:00
Jeong, YunWon
3ec941b364
gh-142282 Fix winreg.QueryValueEx() under race condition (GH-142283) 2025-12-09 12:09:07 +00:00
Stan Ulbrych
726e8e8def
Tachyon: Fix html output sidebar cards hidden behind section headers on hover (#142428) 2025-12-08 21:10:48 +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
Victor Stinner
0b8c348f27
Fix pyflakes warnings: variable is assigned to but never used (#142294)
Example of fixed warning:

    Lib/netrc.py:98:13: local variable 'toplevel'
    is assigned to but never used
2025-12-08 14:00:31 +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
Hugo van Kemenade
3fa1425bfb
gh-142363: Improve Tachyon flamegraph contrast (#142377) 2025-12-08 00:51:51 +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
Savannah Ostrowski
332da6295f
GH-142363: Contrast and gradient CSS fixes for Tachyon flamegraph (#142364) 2025-12-06 22:09:10 +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
Serhiy Storchaka
70c27ce94b
gh-142332: Fix usage formatting for positional arguments in mutually exclusive groups in argparse (GH-142333) 2025-12-06 18:03:45 +00:00
Savannah Ostrowski
5be3405e4e
GH-75949: Fix argparse dropping '|' in mutually exclusive groups on line wrap (#142312) 2025-12-06 15:12:21 +00:00
Y. Z. Chen
61823a5382
Docs: fix RFC index reference for TLS 1.3 (#142262) 2025-12-06 14:05:20 +01:00
Victor Stinner
d119443936
Remove unused imports (#142320) 2025-12-06 11:27:31 +00:00
Stan Ulbrych
dcac498e50
gh-142318: Fix typing 'q' at interactive help screen exiting Tachyon (#142319) 2025-12-05 19:36:28 +00:00
Serhiy Storchaka
59f247e43b
gh-115952: Fix a potential virtual memory allocation denial of service in pickle (GH-119204)
Loading a small data which does not even involve arbitrary code execution
could consume arbitrary large amount of memory. There were three issues:

* PUT and LONG_BINPUT with large argument (the C implementation only).
  Since the memo is implemented in C as a continuous dynamic array, a single
  opcode can cause its resizing to arbitrary size. Now the sparsity of
  memo indices is limited.
* BINBYTES, BINBYTES8 and BYTEARRAY8 with large argument.  They allocated
  the bytes or bytearray object of the specified size before reading into
  it.  Now they read very large data by chunks.
* BINSTRING, BINUNICODE, LONG4, BINUNICODE8 and FRAME with large
  argument.  They read the whole data by calling the read() method of
  the underlying file object, which usually allocates the bytes object of
  the specified size before reading into it.  Now they read very large data
  by chunks.

Also add comprehensive benchmark suite to measure performance and memory
impact of chunked reading optimization in PR #119204.

Features:
- Normal mode: benchmarks legitimate pickles (time/memory metrics)
- Antagonistic mode: tests malicious pickles (DoS protection)
- Baseline comparison: side-by-side comparison of two Python builds
- Support for truncated data and sparse memo attack vectors

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2025-12-05 19:17:01 +02:00
Savannah Ostrowski
4085ff7b32
GH-142267: Cache formatter to avoid repeated _set_color calls (#142268) 2025-12-05 16:47:50 +00:00