Compare commits

...

2532 commits

Author SHA1 Message Date
yihong
3db7bf2d18
gh-142207: remove assertions incompatible under profiling.sampling (#142331) 2025-12-08 04:45:04 +00: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
c5b37228af
gh-138122: Improve the profiling section in the 3.15 what's new document (#140156) 2025-12-07 02:46:33 +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
Kir Chou
35142b18ae
gh-142168: explicitly initialize stack_array in _PyEval_Vector and _PyEvalFramePushAndInit_Ex (#142192)
Co-authored-by: Kir Chou <note351@hotmail.com>
2025-12-06 19:59:52 +01: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
Brett Cannon
eba449a198
GH-142234: Allow --enable-wasm-dynamic-linking under WASI (GH-142235)
While CPython doesn't support `--enable-wasm-dynamic-linking`, external tools like componentize-py do and they have to patch around it. Since the flag is off by default, allowing the flag so external users can add/inject dynamic linking support seems acceptable.
2025-12-05 23:27:16 +00:00
Brett Cannon
d49e6f38a7
Extract data from Tools/wasm/wasi that varies between Python versions into a config file (GH-142273)
This should allow for easier backporting of code.
2025-12-05 14:31:30 -08:00
Brett Cannon
58e1c7a16f
Introduce build-python and build-host subcommands for Tools/wasm/wasi (GH-142266)
It should make it easier when you need to rebuild just the e.g. host Python, but it requires ./configure to run.

Co-authored-by: Emma Smith <emma@emmatyping.dev>
2025-12-05 13:35:50 -08: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
Savannah Ostrowski
4b14529730
GH-139862: Remove color from HelpFormatter (#142274)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-12-05 16:21:31 +00:00
Serhiy Storchaka
100c726d98
Add explanation comments for tests for overlapped ZIP entries (GH-137152) 2025-12-05 18:09:20 +02:00
Serhiy Storchaka
706fdda8b3
gh-141370: Fix undefined behavior when using Py_ABS() (GH-141548)
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
2025-12-05 16:24:35 +02:00
Serhiy Storchaka
1d8f3ed2eb
gh-101100: Fix references to the set methods (GH-141857) 2025-12-05 16:22:38 +02:00
Malcolm Smith
cac4b04973
Fix disk space issues in Android CI (#142289) 2025-12-05 13:10:51 +00:00
Sanyam Khurana
4238a975d7
gh-48752: Add readline.get_pre_input_hook() function (#141586)
Add readline.get_pre_input_hook() to retrieve the current pre-input
hook. This allows applications to save and restore the hook without
overwriting user settings.
2025-12-05 13:18:54 +01:00
Jelle Zijlstra
53ec7c8fc0
gh-142214: Fix two regressions in dataclasses (#142223) 2025-12-04 20:04:42 -08:00
Zanie Blue
128d31637e
gh-141926: Do not unset RUNSHARED when cross-compiling (#141958) 2025-12-05 02:15:04 +00:00
Ken Jin
b3bf212898
gh-141976: Check stack bounds in JIT optimizer (GH-142201) 2025-12-04 20:28:08 +00:00
Alper
2dac9e6016
gh-116738: Statically initialize special constants in cmath module (gh-142161)
The initialization during `mod_exec` wasn't thread-safe with multiple interpreters.
2025-12-04 09:21:51 -05:00
Kir Chou
8392095bf9
gh-129483: Make TestLocalTimeDisambiguation's time format locale independent (#142193)
* Change to update %c to the exact time format.

---------

Co-authored-by: Kir Chou <note351@hotmail.com>
2025-12-04 08:32:23 -05:00
Mark Shannon
6825d5c11d
GH-139757: Fix reference leaks introduced in GH-140800 (GH-142257) 2025-12-04 12:27:15 +00:00
Stan Ulbrych
fb404ab575
gh-142225: Fix PyABIInfo_VAR macro (GH-142230) 2025-12-04 10:33:15 +01:00
Peter Bierma
1a7824a927
gh-141004: Add a CI job ensuring that new C APIs include documentation (GH-142102)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-12-04 03:14:25 +00:00
Brett Cannon
c5252045d3
Being more flexible in when not to explicitly set the sysroot when compiling for WASI (GH-142242) 2025-12-03 15:42:10 -08:00
Sam Gross
547d8daf78
gh-142218: Fix split table dictionary crash (gh-142229)
This fixes a regression introduced in gh-140558. The interpreter would
crash if we inserted a non `str` key into a split table that matches an
existing key.
2025-12-03 18:37:35 -05:00
Chris Eibl
618dc36714
GH-142050: Jit stencils on Windows contain debug data (#142052)
Co-authored-by: Savannah Ostrowski <savannah@python.org>
2025-12-03 22:08:51 +00:00
Sam Gross
c0c65141b3
gh-140482: Avoid changing terminal settings in test_pty (gh-142202)
The previous test_spawn_doesnt_hang test had a few problems:

* It would cause ENV CHANGED failures if other tests were running
  concurrently due to stty changes
* Typing while the test was running could cause it to fail
2025-12-03 15:48:44 -05:00
Mark Shannon
62423c9c36
GH-141794: Limit size of generated machine code. (GH-142228)
* Factor out bodies of the largest uops, to reduce jit code size.
* Factor out common assert, also reducing jit code size.
* Limit size of jitted code for a single executor to 1MB.
2025-12-03 17:43:35 +00:00
Petr Viktorin
aea5531583
gh-135676: Reword the f-string (and t-string) section (GH-137469)
Much of the information was duplicated in stdtypes.rst; this PR keeps lexical/syntactical details in Lexical Analysis and the evaluation & runtime behaviour in Standard types, with cross-references between the two.
Since the t-string section only listed differences from f-strings, and the grammar for the two is equivalent, that section was moved to Standard types almost entirely.

Co-authored-by: Blaise Pabon <blaise@gmail.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2025-12-03 16:14:53 +01:00
Uwe L. Korn
f6f456f950
gh-142038: Expand guard for types_world_is_stopped() to fix debug builds without assertions (#142039) 2025-12-03 15:24:17 +01:00
Victor Stinner
7e5fcae09b
gh-142217: Remove internal _Py_Identifier functions (#142219)
Remove internal functions:

* _PyDict_ContainsId()
* _PyDict_DelItemId()
* _PyDict_GetItemIdWithError()
* _PyDict_SetItemId()
* _PyEval_GetBuiltinId()
* _PyObject_CallMethodIdNoArgs()
* _PyObject_CallMethodIdObjArgs()
* _PyObject_CallMethodIdOneArg()
* _PyObject_VectorcallMethodId()
* _PyUnicode_EqualToASCIIId()

These functions were not exported and so no usable outside CPython.
2025-12-03 14:33:32 +01:00
Petr Viktorin
4172644d78
gh-142206: multiprocessing.resource_tracker: Decode messages using older protocol (GH-142215) 2025-12-03 12:59:14 +00:00
Bartosz Sławecki
88cd5d9850
gh-142170: Add pymanager link to issue template menu (#142199)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-12-03 11:11:40 +02:00
Seth Michael Larson
08d8e18ad8
gh-142145: Remove quadratic behavior in node ID cache clearing (GH-142146)
* Remove quadratic behavior in node ID cache clearing

Co-authored-by: Jacob Walls <38668450+jacobtylerwalls@users.noreply.github.com>

* Add news fragment

---------

Co-authored-by: Jacob Walls <38668450+jacobtylerwalls@users.noreply.github.com>
2025-12-02 23:16:37 -08:00
Pablo Galindo Salgado
8801c6dec7
gh-140677 Add heatmap visualization to Tachyon sampling profiler (#140680)
Co-authored-by: Ivona Stojanovic <stojanovic.i@hotmail.com>
2025-12-02 20:33:40 +00:00
Stan Ulbrych
d3c888b4ec
gh-139707: Fix example for configure option (GH-142153)
Fix example for nre configure option
2025-12-02 14:12:20 +01:00
Petr Viktorin
748c4b47b7
Document None for timeout argument of select.select (#142177) 2025-12-02 10:57:09 +02:00
LloydZ
fddc24e4c8
gh-141982: Fix pdb can't set breakpoints on async functions (#141983)
Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
2025-12-01 23:40:02 -08:00
Krishna-web-hub
2dc28eb8b0
gh-140281: Update free threading Python HOWTO for 3.14 (gh-140566)
Co-authored-by: Sam Gross <colesbury@gmail.com>
2025-12-02 05:53:12 +00:00
LloydZ
5e58548ebe
gh-59000: Fix pdb breakpoint resolution for class methods when module not imported (#141949) 2025-12-01 20:41:54 -08:00
Peter Bierma
41728856a2
gh-142163: Only define HAVE_THREAD_LOCAL when Py_BUILD_CORE is set (#142164) 2025-12-02 09:43:11 +05:30
Kevin Wang
eb892868b3
gh-142048: Fix quadratically increasing GC delays (gh-142051)
The GC for the free threaded build would get slower with each collection due
to effectively double counting objects freed by the GC.
2025-12-01 19:04:47 -05:00
Pablo Galindo Salgado
e32c975640
gh-138122: Small fixes to the new tachyon UI (#142157) 2025-12-01 18:37:46 +00:00
László Kiss Kollár
f87eb4d7cd
gh-138122: New Tachyon UI (#142116)
Co-authored-by: Pablo Galindo Salgado <pablogsal@gmail.com>
2025-12-01 17:34:14 +00:00
Yashraj
52f9b5f580
gh-141004: Document descriptor and dict proxy type objects (GH-141803)
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-12-01 15:51:50 +00:00
Serhiy Storchaka
694922cf40
gh-119342: Fix a potential denial of service in plistlib (GH-119343)
Reading a specially prepared small Plist file could cause OOM because file's
read(n) preallocates a bytes object for reading the specified amount of
data. Now plistlib reads large data by chunks, therefore the upper limit of
consumed memory is proportional to the size of the input file.
2025-12-01 17:28:15 +02:00
Serhiy Storchaka
5a4c4a033a
gh-119451: Fix a potential denial of service in http.client (GH-119454)
Reading the whole body of the HTTP response could cause OOM if
the Content-Length value is too large even if the server does not send
a large amount of data. Now the HTTP client reads large data by chunks,
therefore the amount of consumed memory is proportional to the amount
of sent data.
2025-12-01 17:26:07 +02:00
Stan Ulbrych
d4fa70706c
gh-139707: Add mechanism for distributors to supply error messages for missing stdlib modules (GH-140783) 2025-12-01 14:36:17 +01:00
Adam Turner
b708485d1a
Docs: Upgrade Sphinx to 9.0 (#142114) 2025-12-01 11:16:37 +00:00
Gregory P. Smith
3e2c557493
gh-141473: Document not calling Popen.wait after Popen.communicate times out. (GH-142101)
Document not calling Popen.wait after Popen.communicate times out.

Closes #141473
2025-11-30 18:50:05 -08:00
Tadej Magajna
981ce0cf3a
gh-142066: Fix grammar in multiprocessing Pipes and Queues (GH-142121)
docs: Fix grammar in multiprocessing Pipes and Queues (gh-142066)
2025-11-30 18:14:20 -08:00
flovent
229ed3dd1f
gh-142067: Add missing default value for param in multiprocessing.Pipe's doc (GH-142109) 2025-11-30 13:10:01 -08:00
Thierry Martos
cd4d0ae75c
Improve clarity in tutorial introduction (#140669) 2025-11-30 12:47:31 +00:00
yihong
056d6c5ed9
gh-141999: Handle KeyboardInterrupt when sampling in the new tachyon profiler (#142000) 2025-11-30 02:49:13 +00:00
Pablo Galindo Salgado
ea51e745c7
gh-138122: Add thread status statistics to flamegraph profiler (#141900)
Co-authored-by: ivonastojanovic <80911834+ivonastojanovic@users.noreply.github.com>
2025-11-30 01:42:39 +00:00
Duprat
db098a475a
gh-133146: Add the old public get_value method to documentation and refactor code. (GH-133301)
also uses it within the internals in a few places.
2025-11-29 22:12:48 +00:00
Chris Eibl
f2ca1581ca
GH-141808: Do not generate the jit stencils twice in case of PGO builds on Windows. (GH-142043)
* do not build the jit stencils twice in case of PGO builds on Windows

* blurb it
2025-11-29 12:43:06 -08:00
Adam Turner
77399436bf
Docs: Prepare for Sphinx 9 (#142057) 2025-11-29 16:49:37 +02:00
Adam Turner
3c117380ab
GH-121970: Remove Docutils list monkeypatch (#142056) 2025-11-29 14:28:23 +00:00
Moshe Kaplan
cfcd52490d
GH-141963: Clarify argparse documentation (GH-141964)
Clarify argparse documentation

Tightens the phrasing for several argparse actions.
2025-11-28 23:23:34 -08:00
Hugo van Kemenade
890fe5aad5
Docs: multi-disk ZIP files -> multipart ZIP files (GH-141962)
* Remove some old currentlies
* multi-disk -> multipart
* Sentence case headings
2025-11-28 23:11:59 -08:00
Sebastian Pipping
440bcb9456
gh-141994: Warn of XXE vulnerability in documentation of SAX feature xml.sax.handler.feature_external_ges (GH-141996)
Doc/library/xml.sax.handler.rst: Warn of XXE with feature_external_ges

Related to commit baa9f33897
2025-11-28 23:08:17 -08:00
Victor Stinner
5e749d3743
Fix multiprocessing queue test_get() (GH-142024)
* Replace sleep() with support.sleeping_retry().
* Test get_nowait() first.
* Restore previously disabled test.

Fix the failure:

FAIL: test_get (test.test_multiprocessing_spawn.test_processes.WithProcessesTestQueue.test_get)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "Lib/test/_test_multiprocessing.py", line 1208, in test_get
    self.assertEqual(queue_empty(queue), False)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: True != False
2025-11-28 23:00:14 -08:00
Gregory P. Smith
5b1862bdd8
gh-87512: Fix subprocess using timeout= on Windows blocking with a large input= (GH-142058)
On Windows, Popen._communicate() previously wrote to stdin synchronously, which could block indefinitely if the subprocess didn't consume input= quickly and the pipe buffer filled up. The timeout= parameter was only checked when joining the reader threads, not during the stdin write.

This change moves the Windows stdin writing to a background thread (similar to how stdout/stderr are read in threads), allowing the timeout to be properly enforced. If timeout expires, TimeoutExpired is raised promptly and the writer thread continues in the background. Subsequent calls to communicate() will join the existing writer thread.

Adds test_communicate_timeout_large_input to verify that TimeoutExpired is raised promptly when communicate() is called with large input and a timeout, even when the subprocess doesn't consume stdin quickly.

This test already passed on POSIX (where select() is used) but failed on Windows where the stdin write blocks without checking the timeout.

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2025-11-28 22:07:03 -08:00
Gregory P. Smith
923056b2d4
gh-74389: gh-70560: subprocess.Popen.communicate() now ignores stdin.flush error when closed (GH-142061)
gh-70560: gh-74389: subprocess.Popen.communicate() now ignores stdin.flush error when closed

with a unittest and news entry.
2025-11-29 05:03:06 +00:00
Gregory P. Smith
cc6bc4c97f
GH-134453: Fix subprocess memoryview input handling on POSIX (GH-134949)
Fix inconsistent subprocess.Popen.communicate() behavior between Windows
and POSIX when using memoryview objects with non-byte elements as input.

On POSIX systems, the code was incorrectly comparing bytes written against
element count instead of byte count, causing data truncation for large
inputs with non-byte element types.

Changes:
- Cast memoryview inputs to byte view when input is already a memoryview
- Fix progress tracking to use len(input_view) instead of len(self._input)
- Add comprehensive test coverage for memoryview inputs

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* old-man-yells-at-ReST
* Update 2025-05-30-18-37-44.gh-issue-134453.kxkA-o.rst
* assertIsNone review feedback
* fix memoryview_nonbytes test to fail without our fix on main, and have a nicer error.

Thanks to Peter Bierma @ZeroIntensity for the code review.
2025-11-29 04:25:06 +00:00
Artur Jamro
526d7a8bb4
gh-141473: Fix subprocess.Popen.communicate to send input to stdin upon a subsequent post-timeout call (GH-141477)
* gh-141473: Fix subprocess.Popen.communicate to send input to stdin
* Docs: Clarify that `input` is one time only on `communicate()`
* NEWS entry
* Add a regression test.

---------

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2025-11-28 18:04:52 -08:00
Cody Maloney
d2d2e92110
Docs: Move to method references for bytearray.take_bytes (#142053) 2025-11-28 22:07:34 +01:00
dgpb
fa9519f8b2
gh-142025: Add c-analyzer include for pyexpat.c (GH-142026)
Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
2025-11-28 09:51:48 -08:00
Cody Maloney
5a7c9c6861
gh-141968: Use take_bytes in encodings.punycode (#141974)
Removes a copy going from bytearray to bytes.

Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-11-28 17:47:14 +00:00
Cody Maloney
3001464248
gh-141968: Use take_bytes in re._compiler (#141995)
Removes a copy going from bytearray to bytes.

Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-11-28 17:46:10 +00:00
dgpb
5ec03cf3b0
gh-133228: c-analyzer clang preprocessor (GH-133229)
* impl
* included 2 failures to tsvs next to similar entries
* added fix/hack for curses.h fails
* fix leftover from debug
2025-11-27 22:22:21 +00:00
Stefano Rivera
656a64b37f
gh-141930: Use the regular IO stack to write .pyc files for a better error message on failure (GH-141931)
* Use open() to write the bytecode
* Convert to unittest style asserts
* Tweak news, thanks @vstinner
* Tidy
* reword NEWS, avoid word "retried"
2025-11-27 19:17:59 +00:00
Miro Hrončok
69f54ce452
gh-140210: Make test_sysconfig.test_parse_makefile_renamed_vars ignore environment variables (#140213)
The test did not expect it could be run with e.g. CFLAGS set to a custom value.
2025-11-27 10:00:02 -08:00
SIVALANAGASHANKARNIVAS
e02801dc37
gh-140505: Fix 'parameters' to 'arguments' in xmlrpc.client.MultiCall docs (GH-141942)
Fix terminology: change 'parameters' to 'arguments' in MultiCall docs

Fixes #140505
2025-11-27 18:01:15 +01:00
Victor Stinner
9c4ff8a615
gh-130396: Export _Py_ReachedRecursionLimitWithMargin() (#142012)
test_peg_generator needs the function.
2025-11-27 12:22:15 +00:00
Victor Stinner
d5d9e89dde
gh-116008: Detect freed thread state in faulthandler (#141988)
Add _PyMem_IsULongFreed() function.
2025-11-27 12:35:00 +01:00
Victor Stinner
83d8134c5b
gh-127635: Use flexible array in tracemalloc (#141991)
Replace frames[1] with frames[] in tracemalloc_traceback structure.
2025-11-27 12:32:31 +01:00
Victor Stinner
7fe1a18b77
gh-130396: Remove _Py_ReachedRecursionLimitWithMargin() function (#141951)
Move the private function to the internal C API (pycore_ceval.h).
2025-11-27 12:32:00 +01:00
Alper
bc9e63dd9d
gh-116738: Fix thread-safety issue in re module for free threading (gh-141923)
Added atomic operations to `scanner_begin()` and `scanner_end()` to prevent
race conditions on the `executing` flag in free-threaded builds. Also added
tests for concurrent usage of the `re` module.

Without the atomic operations, `test_scanner_concurrent_access()` triggers
`assert(self->executing)` failures, or a thread sanitizer run emits errors.
2025-11-26 15:40:45 -05:00
Cody Maloney
9ac14288d7
gh-141968: use bytearray.take_bytes in encodings.idna (#141975) 2025-11-26 21:16:25 +05:30
Cody Maloney
9dbf77beb6
gh-141968: use bytearray.take_bytes in wave._byteswap (#141973) 2025-11-26 21:15:12 +05:30
Cody Maloney
2c1fdf3592
gh-141968: Use bytearray.take_bytes in base64 _b32encode and _b32decode (#141971) 2025-11-26 21:14:25 +05:30
Petr Viktorin
2ff8608b4d
gh-135676: Simplify docs on lexing names (GH-140464)
This simplifies the Lexical Analysis section on Names (but keeps it technically correct) by putting all the info about non-ASCII characters in a separate (and very technical) section.

It uses a mental model where the parser doesn't handle Unicode complexity “immediately”, but:

- parses any non-ASCII character (outside strings/comments) as part of a name, since these can't (yet) be e.g. operators
- normalizes the name
- validates the name, using the xid_start/xid_continue sets


Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Blaise Pabon <blaise@gmail.com>
Co-authored-by: Micha Albert <info@micha.zone>
Co-authored-by: KeithTheEE <kmurrayis@gmail.com>
2025-11-26 16:10:44 +01:00
Petr Viktorin
c359ea4c71
gh-141909: Correct version where Py_mod_gil was added (GH-141979) 2025-11-26 14:45:06 +00:00
Sergey Miryanov
2ea67caf31
GH-141861: Fix TRACE_RECORD if full (GH-141959) 2025-11-26 14:32:30 +00:00
Itamar Oren
27f62eb711
gh-140011: Delete importdl assertion that prevents importing embedded modules from packages (GH-141605) 2025-11-26 14:12:49 +01:00
Petr Viktorin
d7f0214f13
gh-140550: PEP 793 reference documentation (GH-141197)
* gh-140550: PEP 793 reference documentation

Since the PEP calls for soft-deprecation of the existing initialization
function, this reorganizes the relevant docs to put the new way of
doing things first, and de-emphasize the old.

Some bits, like the tutorial, are left out of this patch. (See the
issue for a list.)
2025-11-26 12:50:03 +00:00
Guo Ci
8c33c6143e
Correct indentation in stdtypes.rst (#141957) 2025-11-26 11:55:52 +05:30
Stan Ulbrych
33efd7178e
Remove `Misc/ACKS` check from patchcheck, documentation (#141960)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-11-26 00:00:00 +00:00
Stan Ulbrych
9f2a34af74
Remove references to `Misc/ACKS from CONTRIBUTING.md` (#141952)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-11-25 18:59:28 +00:00
Peter Bierma
a89ee4b9c2
gh-141004: Document missing PyThread* APIs (GH-141810)
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-11-25 12:53:18 -05:00
Petr Viktorin
202fce0dbd
gh-141909: Add PyModuleDef_Slot and earlier Py_mod_* constants to stable ABI manifest (#141910)
These were added to the limited API in 3.5.
Not including them in `Misc/stable_abi.toml` was a bug.
2025-11-25 15:16:49 +01:00
Stan Ulbrych
f445c452ea
gh-141004: Document PyOS_mystr(n)icmp (#141760)
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2025-11-25 14:44:52 +01:00
Petr Viktorin
226011ba12
gh-139165: Make Py_SIZE, Py_IS_TYPE,Py_ SET_SIZE regular functions in stable ABI (GH-139166)
* Make Py_{SIZE,IS_TYPE,SET_SIZE} regular functions in stable ABI

Group them together with Py_TYPE & Py_SET_TYPE to cut down
on repetitive preprocessor macros.
Format repetitive definitions in object.c more concisely.

Py_SET_TYPE is still left out of the Limited API.
2025-11-25 14:30:33 +01:00
Krishna Chaitanya
e6174ee981
gh-140911: Ensure that UserString.index() and UserString.rindex() accept UserString as argument (GH-140945) 2025-11-25 15:25:46 +02:00
Pablo Galindo Salgado
d07d3a3c57
gh-138122: Split Modules/_remote_debugging_module.c into multiple files (#141934)
gh-1381228: Split Modules/_remote_debugging_module.c into multiple files
2025-11-25 12:51:24 +00:00
Paresh Joshi
da1d468bea
gh-141781: Fix pdb.line_prefix binding (#141779) 2025-11-24 18:45:16 -08:00
Sergey Miryanov
dc62b62252
GH-141861: Fix invalid memory read in the ENTER_EXECUTOR (GH-141921) 2025-11-24 22:07:45 +00:00
SubbaraoGarlapati
369ce2b139
Fix implicit import in test_monitoring.py (gh-141795) 2025-11-24 14:48:28 -05:00
Christian Marangi
fee7782650
gh-141907: Better handle support for SHA3 for test_hashlib (GH-141908)
* test_hashlib: better handle support for SHA3

It's possible that the SSL library supports only SHA3 algo and doesn't
have SHAKE one.

The current test wrongly detect this and set both HASH and HASHXOF to
None expecting to have the extra SHA3 attributes present but this should
only be true for SHAKE algo.

To better handle this, move the HASH condition to a dedicated try-expect
condition and check if HASHXOF is None in the relevant code effectively
checking if SHA3 is supported by the SSL library but SHAKE algo needs to
use the sha3module one.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>

* rework the conditional import for all its attrs

---------

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2025-11-24 17:35:58 +00:00
Peter Bierma
e1f1df4082
gh-141004: Document stack effect C APIs (GH-141843)
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-11-24 12:18:50 -05:00
Peter Bierma
5f35702bb6
gh-141004: Document PyImport_Inittab (GH-141844)
Co-authored-by: Stan Ulbrych <stan@ulbrych.org>
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-11-24 16:38:18 +00:00
Sam Gross
71126ab19c
gh-129441: Fix some flakiness in test_instrumentation (gh-141881)
Most of the `self.assertTrue(self.called)` checks are flaky because
the worker threads may sometimes finish before the main thread calls
`self.during_threads()`.
2025-11-24 11:19:07 -05:00
Sam Gross
c490ffb7ac
gh-116749: Fix code comment for _PyConfig_GIL_DEFAULT (gh-141804) 2025-11-24 10:42:00 -05:00
Cody Maloney
b484c32d0a
gh-141863: use bytearray.take_bytes in asyncio streams for better performance (#141864) 2025-11-24 21:06:53 +05:30
Adorilson Bezerra
fb655527d8
gh-106318: Add examples for str.join() (#140315)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2025-11-24 16:53:25 +02:00
Adorilson Bezerra
0cde70bde0
gh-106318: Add example for str.format() (#137018) 2025-11-24 16:51:10 +02:00
Satyam Kumar Verman
9346e22dd0
gh-141831: Document behavior of functools.lru_cache with concurrent access (gh-141869) 2025-11-24 14:36:09 +00:00
Pablo Galindo Salgado
04e3670f6b
gh-138122: Fix permission error detection in tachyon's test (#141897) 2025-11-24 14:32:17 +00:00
Adorilson Bezerra
0387a8e0f7
gh-106318: Add example for str.isalpha() (#137557)
Co-authored-by: Éric <merwok@netwok.org>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-11-24 14:10:35 +00:00
Alexander Nordin
a4f4225213
gh-138199: Address potential confusion regarding threading in the asyncio HOWTO (GH-138200) 2025-11-24 14:08:49 +00:00
Adorilson Bezerra
0afcb51d17
gh-106318: Add example for str.isascii() (#137558)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-11-24 16:02:18 +02:00
Yashraj
e0773eacb7
gh-141004: Document Py_ARRAY_LENGTH (GH-141601)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-11-24 13:34:37 +00:00
Petr Viktorin
bf66bce4ee
gh-141780: Make PyModule_FromSlotsAndSpec enable GIL if needed (GH-141785) 2025-11-24 13:26:35 +01:00
Adorilson Bezerra
6462322840
gh-106318: Add example for str.isdecimal() (#137559)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-11-24 11:47:54 +00:00
Pablo Galindo Salgado
3eec46d3c3
gh-138122: Refactor the CLI of profiling.sampling into subcommands (#141813) 2025-11-24 11:45:08 +00:00
Duane Griffin
425f24e4fa
gh-135335: Simplify preload regression test using __main__ (GH-138686)
Simplify preload regression test using `__main__`

With the fix for gh-126631 `__main__` modules can be preloaded and the regression
test for gh-135335 can be simplified to just use a self-contained script rather
than requiring a module.

Note this assumes and implicitly tests that `__main__` is preloaded by default.
2025-11-23 15:37:15 -08:00
Mark Dufour
23b67aa037
math.dist documentation: add 'strict=True' to equivalent code (#141819) 2025-11-23 17:33:27 -06:00
Stan Ulbrych
4fe6e81d84
gh-141865: Fix translation of strings in changes.py extension (#141882) 2025-11-23 19:28:09 +02:00
yihong
ecb901dd87
Drop three unused imports (#141875) 2025-11-23 16:33:05 +00:00
Sam Gross
e457d60daa
gh-120158: Fix inconsistent monitoring state when setting events too frequently (gh-141845)
If we overflowed the global version counter (i.e., after 2*24 calls to
`_PyMonitoring_SetEvents`), we bailed out after setting global monitoring
events but before instrumenting code objects, which led to assertion errors
later on.

Also add a `time.sleep()` to `test_free_threading.test_monitoring` to avoid
overflowing the global version counter.
2025-11-23 10:07:17 -05:00
Gregory P. Smith
614a28b3da
gh-98552: Revert (unneeded, already done elsewhere) "flush std streams in the multiprocessing forkserver before fork (#141849)" (#141871)
Revert (unneeded, already done elsewhere) "gh-98552: flush std streams in the multiprocessing forkserver before fork (#141849)"

This reverts commit 58badb1711.
2025-11-23 09:52:26 +00:00
Gregory P. Smith
2746c698e3
[security] Add a cooldown period to dependabot (GH-141866)
See https://blog.yossarian.net/2025/11/21/We-should-all-be-using-dependency-cooldowns and the description in the comment.
2025-11-23 01:34:48 -08:00
Hugo van Kemenade
e73fbbacbb
gh-141679: Add colour to defaults in argparse help (#141680)
Co-authored-by: Savannah Ostrowski <savannah@python.org>
2025-11-23 00:26:50 +00:00
Brandt Bucher
227b9d326e
GH-140638: Add a GC "candidates" stat (GH-141814) 2025-11-22 21:59:14 +00:00
Serhiy Storchaka
425fd85ca3
gh-138525: Support single-dash long options and prefix_chars in BooleanOptionalAction (GH-138692)
-nofoo is generated for -foo.
++no-foo is generated for ++foo.
/nofoo is generated for /foo.
2025-11-22 20:54:02 +00:00
Adam Turner
cde19e565c
GH-101100: Resolve reference warnings in library/stdtypes.rst (#138420) 2025-11-22 19:23:29 +00:00
Weilin Du
d4e3829a74
gh-101100: Fix sphinx warnings in library/unittest.rst (#140109)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-11-22 21:16:09 +02:00
Gregory P. Smith
58badb1711
gh-98552: flush std streams in the multiprocessing forkserver before fork (#141849)
* flush std streams in the multiprocessing forkserver before fork

* NEWS
2025-11-22 18:29:51 +00:00
Andrew J. Hesford
08477dbf30
gh-141600: Fix musl version detection on Void Linux (GH-141602) 2025-11-22 12:17:40 -06:00
David Benjamin
c41fce08a5
gh-141801: Use accessors for ASN1_STRING fields in libssl (GH-141802)
* gh-141801: Use accessors for ASN1_STRING fields

While ASN1_STRING is currently exposed, it is better to use the
accessors. See https://github.com/openssl/openssl/issues/29117 where, if
the type were opaque, OpenSSL's X509 objects could be much more
memory-efficient.

* Update Modules/_ssl.c

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>

* Update Modules/_ssl.c

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>

---------

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-11-22 09:17:45 -08:00
Semyon Moroz
5c25bc5763
gh-131178: Add tests for pickletools command-line interface (#131287) 2025-11-22 19:17:06 +02:00
Chris Angelico
f21ed37daf
gh-141817: Add IPV6_HDRINCL constant to the socket module (#141818)
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-11-22 18:07:21 +01:00
Yongzi Li
dc9d2eea58
gh-141833: Remove the bad lines in test_attr_promotion_failure (GH-141841) 2025-11-23 00:27:05 +08:00
Pablo Galindo Salgado
92972aea0f
gh-140381: Make test_profiling tests deterministic to fix flakiness (#141731) 2025-11-21 21:36:30 +00:00
Sam Gross
2d50dd242e
gh-137422: Fix race condition in PyImport_AddModuleRef (gh-141822) 2025-11-21 13:30:33 -05:00
Cody Maloney
019c315a8e
gh-129559: add bytearray.resize thread safety test for free-threading (#141739) 2025-11-21 23:42:22 +05:30
Mikhail Efimov
a3b78a3ade
gh-141498: Change backoff counter to use prime numbers instead of powers of 2 (GH-141591) 2025-11-21 17:00:25 +00:00
Alper
fb26d9c2ef
gh-116738: Make csv module thread-safe (gh-141365)
Added a critical section to protect the states of `ReaderObj` and `WriterObj` in the free-threading build. Without the critical sections, both new free-threading tests were crashing.
2025-11-21 11:22:31 -05:00
Paresh Joshi
f15f6d0ba3
gh-141612: improve test_trampoline_works_with_forks coverage (#141613) 2025-11-21 16:01:26 +00:00
Kumar Aditya
49ff8b6cc0
gh-140795: fetch thread state once on fast path for critical sections (#141406) 2025-11-21 19:49:53 +05:30
Pablo Galindo Salgado
cb4c87df75
gh-141645: Add profiling/sampling/live_collector to the makefile and remove spurious file (#141820) 2025-11-21 13:34:04 +00:00
Sergey Miryanov
a8733cbc73
GH-139727: Add --enable-stackref-debug flag to build.bat to enable Py_STACKREF_DEBUG build on Windows (GH-139728) 2025-11-21 11:03:32 +00:00
Michael Kiper
20b69aac0d
gh-141729: Doc PyTypeObject.tp_vectorcall grammar fix (#141730)
[3.14] Doc PyTypeObject.tp_vectorcall grammar fix

Co-authored-by: makiper <michael.kiper@jpl.nasa.gov>
2025-11-21 07:24:10 +00:00
Pablo Galindo Salgado
07410da204
gh-141645: Refactor tachyon's live TUI tests to not use private fields (#141806) 2025-11-21 00:35:37 +00:00
Serhiy Storchaka
77cb39e0c7
gh-138697: Fix inferring dest from a single-dash long option in argparse (#138699)
* gh-138697: Fix inferring dest from a single-dash long option in argparse

If a short option and a single-dash long option are passed to add_argument(),
dest is now inferred from the single-dash long option.

* Make double-dash options taking priority over single-dash long options.

---------

Co-authored-by: Savannah Ostrowski <savannah@python.org>
2025-11-20 18:41:58 +00:00
Pablo Galindo Salgado
b3383085f9
gh-141645: Add a TUI mode to the new tachyon profiler (#141646) 2025-11-20 18:27:17 +00:00
Cody Maloney
e90061f5f1
gh-60107: Remove a copy from RawIOBase.read (#141532)
If the underlying I/O class keeps a reference to the memory, raise BufferError.

Co-authored-by: Victor Stinner <vstinner@python.org>
2025-11-20 17:37:04 +00:00
Victor Stinner
722f4bb8c9
gh-141784: Fix _remote_debugging_module.c compilation on 32-bit Linux (#141796)
Include Python.h before system headers to make sure that
_remote_debugging_module.c uses the same types (ABI) than Python.
2025-11-20 16:30:35 +00:00
Prithviraj Chaudhuri
b1558b6d3e
gh-140042: Removing unsafe call to sqlite3_shutdown (GH-141690) 2025-11-20 15:35:22 +01:00
Peter Bierma
4273616ebf
gh-141004: Document missing PyDateTime* APIs (GH-141543)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-11-20 08:48:10 -05:00
Peter Bierma
2da7ecc680
gh-141004: Document missing generator APIs (GH-141409)
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-11-20 08:46:27 -05:00
Peter Bierma
ce701032a3
gh-141004: Document Py_MakePendingCalls (GH-141137)
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-11-20 08:42:01 -05:00
Arseny Boykov
41b9ad5b38
gh-141757: Comply with pickle protocol in test_reduce_5tuple (GH-141759)
The 5th element of the __reduce__ tuple should be an iterator.
2025-11-20 10:57:05 +02:00
Cody Maloney
e265ce8a56
gh-139871: Optimize small takes in bytearray.take_bytes (GH-141741)
When less than half the buffer is taken just copy that small part out
rather than doing a big alloc + memmove + big shrink.
2025-11-20 08:49:05 +01:00
dr-carlos
a35c683da5
gh-141489: Simplify closure/freevar iteration in annotationlib._build_closure() (#141490) 2025-11-19 18:08:08 -10:00
Tian Gao
bc9b9d47f9
gh-141615: Check stdin instead of stdout for use_rawinput in pdb (#141616) 2025-11-19 18:41:25 -08:00
Guo Ci
e5adaafc52
[Docs] Fix typo in bdb: is_skipped_line to is_skipped_module (#141771) 2025-11-19 18:39:54 -08:00
Brett Cannon
ca1e86f9d9
Simplify setting CLI options for WASI builds (GH-141769)
This introduces a Wasmtime configuration file to get some CLI options out of the code for easier manipulation. It also allows for easier tweaking after the Makefile is generated.

As well, cut back on the flexibility of specifying HOSTRUNNER for simpler code. The flexibility was never used and so it didn't make sense to keep it around.
2025-11-19 15:57:44 -08:00
Guido van Rossum
b4344f7020
Remove GvR from '_stdauthor' in Doc/conf.py (#141765)
Co-authored-by: Guido van Rossum <gvanrossum@microsoft.com>
2025-11-19 22:30:01 +02:00
Ayappan Perumal
fbc31d14ff
Move the NEWS entry for gh-141659 to the correct section (GH-141744) 2025-11-19 22:12:10 +02:00
Stan Ulbrych
3149d64c93
gh-141004: Document Py_LOCAL and Py_LOCAL_INLINE (GH-141725) 2025-11-19 13:32:18 -05:00
Luciano Ramalho
01713b4342
gh-141721: Improve docstring for LastUpdatedOrderedDict example (gh141724) 2025-11-19 12:22:27 -06:00
Alex Crichton
9b69a55be3
gh-141172: Update to wasi-sdk-29 (GH-141684)
This commit updates CI and configuration from wasi-sdk-25 to wasi-sdk-29
which was released recently. This notably includes stubs for pthreads
which all return errors, so some adjustment in logic is necessary to
retain knowledge that WASI cannot yet spawn threads for example.

This additionally increases the wasm stack allowance to 32MiB from 16MiB
to accomodate the `test_recursive_pickle` test in the
`test_functools.py` file. It looks like the Clang/LLVM update that
happened in wasi-sdk-29 relative to wasi-sdk-25 is likely the cause of
this where presumably functions have more locals than before and/or a
slightly adjusted stack space requirement which overflows the stack.
2025-11-19 10:03:30 -08:00
Serhiy Storchaka
4bcab461c2
gh-41779: Allow defining the __dict__ and __weakref__ __slots__ for any class (GH-141755) 2025-11-19 17:11:37 +00:00
Brandt Bucher
598d4c64de
GH-140638: Add a GC "duration" stat (GH-141720) 2025-11-19 08:51:39 -08:00
Alexander Nordin
b3b63e8d6d
gh-138072: Small clarifications and phrasing improvements to asyncio HOWTO (#138073)
* - Small clarifications and phrasing improvements

* nit

* Apply suggestions from code review

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>

* clarify event loops when multi threading.

* nit

* Update Doc/howto/a-conceptual-overview-of-asyncio.rst

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>

* nit

* nit

* phrasing for threads & event loops.

* revert changes to event-loop/thread discussion.

* sentence case consistencty.

* slight re-arrange.

* Sentence case consistency.

* tweak language. non-negligible

---------

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-11-19 08:16:03 -06:00
Miro Hrončok
96f496a949
gh-141570: can_colorize: Expect fileno() to raise OSError, as documented (#141716)
In Fedora, we've been given a slightly incomplete reproducer for a problematic
Python 3.14 color-related change in argparse that leads to an exception when
Python is used from mod_wsgi: https://bugzilla.redhat.com/2414940

mod_wsgi replaces sys.stdout with a custom object that raises OSError on .fileno():

8460dbfcd5/src/server/wsgi_logger.c (L434-L440)

This should be supported, as the documentation of fileno explicitly says:

> An OSError is raised if the IO object does not use a file descriptor.

https://docs.python.org/3.14/library/io.html#io.IOBase.fileno

The previously expected exception inherits from OSError,
so it is still expected.

Fixes https://github.com/python/cpython/issues/141570

Co-authored-by: Cody Maloney <cmaloney@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-11-19 15:02:52 +01:00
Petr Viktorin
e2178743fe
gh-135953: Avoid BytesWarning when sampling profiler tests fail (GH-141719)
With `-bb`, this failed on BytesWarning: str() on a bytes instance
2025-11-19 14:43:42 +01:00
Serhiy Storchaka
95296a9d40
gh-140875: Fix handling of unclosed charrefs before EOF in HTMLParser (GH-140904) 2025-11-19 13:55:10 +02:00
da-woods
afa0badcc5
gh-141726: Add PyDict_SetDefaultRef() to the Stable ABI (#141727)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2025-11-19 11:38:10 +00:00
Guo Ci
52f70a6f60
Correct class name from PullDom to PullDOM (#141207) 2025-11-19 12:30:53 +02:00
Mark Shannon
c25a070759
GH-139653: Only raise an exception (or fatal error) when the stack pointer is about to overflow the stack. (GH-141711)
Only raises if the stack pointer is both below the limit *and* above the stack base.
This prevents false positives for user-space threads, as the stack pointer will be outside those bounds
if the stack has been swapped.
2025-11-19 10:16:24 +00:00
Hugo van Kemenade
5d1f8f2d03 Merge branch 'main' of https://github.com/python/cpython 2025-11-19 11:42:45 +02:00
Hugo van Kemenade
dbbf4b2e21 Post 3.15.0a2 2025-11-19 11:42:16 +02:00
Ayappan Perumal
92c5de73b8
gh-141659: Fix bad file descriptor error in subprocess on AIX (GH-141660)
/proc/self does not exist on AIX.
2025-11-19 09:37:09 +02:00
Russell Keith-Magee
7b0b708675
gh-141692: Add a slice-specific lib folder to iOS XCframeworks. (#141693)
Modifies the iOS XCframework to include a lib folder for each slice that
contains a symlinked version of the libPython dynamic library.
2025-11-19 09:48:51 +08:00
Edward Xu
ce79154176
gh-139103: fix free-threading dataclass.__init__ perf issue (gh-141596)
The dataclasses `__init__` function is generated dynamically by a call to `exec()` and so doesn't have deferred reference counting enabled. Enable deferred reference counting on functions when assigned as an attribute to type objects to avoid reference count contention when creating dataclass instances.
2025-11-19 00:57:59 +00:00
Thierry Martos
652c764a59
gh-140381: Increase slow_fibonacci call frequency in test_profiling (#140673) 2025-11-19 00:01:09 +00:00
Russell Keith-Magee
17636ba48c
gh-141691: Apply ruff rules to Apple folder. (#141694)
Add ruff configuration to run over the Apple build tooling and testbed script.
2025-11-18 22:39:21 +00:00
Brandt Bucher
4cfa695c95
GH-141686: Break cycles created by JSONEncoder.iterencode (GH-141687) 2025-11-18 09:51:18 -08:00
Shamil
daafacf005
gh-42400: Fix buffer overflow in _Py_wrealpath() for very long paths (#141529)
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-11-18 17:34:58 +01:00
Victor Stinner
600f3feb23
gh-141070: Add PyUnstable_Object_Dump() function (#141072)
* Promote _PyObject_Dump() as a public function.
* Keep _PyObject_Dump() alias to PyUnstable_Object_Dump()
  for backward compatibility.
* Replace _PyObject_Dump() with PyUnstable_Object_Dump().

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2025-11-18 16:13:13 +00:00
Petr Viktorin
4695ec109d
gh-138189: Link references to type slots (GH-141410)
Link references to type slots
2025-11-18 16:33:52 +01:00
Pablo Galindo Salgado
a52c39e260
gh-135953: Refactor test_sampling_profiler into multiple files (#141689) 2025-11-18 15:14:16 +00:00
Hugo van Kemenade
a62562859d Python 3.15.0a2 2025-11-18 16:51:17 +02:00
Hugo van Kemenade
f46785f8bc
gh-133879: Copyedit "What's new in Python 3.15" (#141717) 2025-11-18 16:42:13 +02:00
Mark Shannon
b420f6be53
GH-139109: Support switch/case dispatch with the tracing interpreter. (GH-141703) 2025-11-18 13:31:48 +00:00
Mariusz Felisiak
b87613f214
Add missing backticks in os and decimal docs (#141699) 2025-11-18 12:32:15 +02:00
Sergey B Kirpichev
630cd37bfa
gh-141004: Document Py_HUGE_VAL/IS_FINITE/IS_INFINITE/IS_NAN (#141544)
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2025-11-18 10:17:37 +01:00
Cody Maloney
58f3fe0d9b
gh-129005: Remove copies from _pyio using take_bytes (#141539)
Memory usage now matches that of _io for large files.
2025-11-18 10:10:32 +01:00
Pablo Galindo Salgado
4867f717e2
gh-140729: Fix subprocess handling in test_process_pool_executor_pickle (#141688) 2025-11-18 02:26:40 +00:00
Stan Ulbrych
16ea9505ce
gh-141004: Document Py_MEMCPY (GH-141676) 2025-11-17 17:52:13 -05:00
Peter Bierma
b3626321b6
gh-141004: Document PyODict* APIs (GH-141136) 2025-11-17 14:40:47 -05:00
Louis
5d2eb98a91
gh-140578: Delete unnecessary NEWS entry (#141427)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-11-17 19:47:00 +02:00
Krishna Chaitanya
6b1bdf6c7a
gh-141497: Make ipaddress.IP{v4,v6}Network.hosts() always returning an iterator (GH-141547) 2025-11-17 19:29:06 +02:00
Pablo Galindo Salgado
274a26cca8
gh-135953: Simplify GC markers in the tachyon profiler (#141666) 2025-11-17 16:32:08 +00:00
Semyon Moroz
cc6b62ac56
gh-130160: Add anchors to CLI Usage section for cmdline (#133182) 2025-11-17 14:51:21 +00:00
R.C.M
3d14805947
gh-130693: Support more options for search in tkinter.Text (GH-130848)
* Add parameters nolinestop and strictlimits in the tkinter.Text.search() method.
* Add the tkinter.Text.search_all() method.
* Add more tests for tkinter.Text.search().
* stopindex is now only ignored if it is None.
2025-11-17 14:42:26 +00:00
Stefano Rivera
f6dd9c12a8
GH-139914: Handle stack growth direction on HPPA (GH-140028)
Adapted from a patch for Python 3.14 submitted to the Debian BTS by John
https://bugs.debian.org/1105111#20

Co-authored-by: John David Anglin <dave.anglin@bell.net>
2025-11-17 14:41:22 +01:00
Brandt Bucher
336366fd7c
GH-140643: Add <native> and <GC> frames to the sampling profiler (#141108)
- Introduce a new field in the GC state to store the frame that initiated garbage collection.
- Update RemoteUnwinder to include options for including "<native>" and "<GC>" frames in the stack trace.
- Modify the sampling profiler to accept parameters for controlling the inclusion of native and GC frames.
- Enhance the stack collector to properly format and append these frames during profiling.
- Add tests to verify the correct behavior of the profiler with respect to native and GC frames, including options to exclude them.

Co-authored-by: Pablo Galindo Salgado <pablogsal@gmail.com>
2025-11-17 13:39:00 +00:00
Pablo Galindo Salgado
89a914c58d
gh-135953: Add GIL contention markers to sampling profiler Gecko format (#139485)
This commit enhances the Gecko format reporter in the sampling profiler
to include markers for GIL acquisition events.
2025-11-17 12:46:26 +00:00
yihong
994ab5c922
gh-140729: Add __mp_main__ as a duplicate for __main__ for pickle to work (#140735) 2025-11-17 12:43:14 +00:00
Thomas Ballard
20b64bdf23
Docs: Fix typo in socketserver documentation (#140956) 2025-11-17 13:47:28 +02:00
dereckduran
d527d3bf8b
gh-62480: De-personalize "Coping with mutable arguments" section in unittest.mock examples (#141323) 2025-11-17 13:44:44 +02:00
Tamzin Hadasa Kelly
df8091d516
gh-141650: Fix typo in xml.sax.saxutils.unescape documentation (#141652) 2025-11-17 13:35:01 +02:00
Stan Ulbrych
31ea3f3c76
gh-141018: Update .exe, .dll, .rtf and .jpg mime types in mimetypes (#141023) 2025-11-17 13:32:00 +02:00
SubbaraoGarlapati
7800b78067
fix memory order of _Py_atomic_store_uint_release (#141562) 2025-11-17 16:53:12 +05:30
Tian Gao
8be3b2f479
gh-136057: Allow step and next to step over for loops (#136160) 2025-11-16 13:57:07 -08:00
Peter Bierma
be699d6c7c
gh-141004: Document missing PyCFunction* and PyCMethod* APIs (GH-141253)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-11-16 19:25:50 +00:00
Tian Gao
5348c200f5
gh-125115 : Refactor the pdb parsing issue so positional arguments can pass through (#140933) 2025-11-16 10:58:28 -08:00
Stan Ulbrych
e33afa7ddb
gh-141004: Document the PyPickleBuffer_* C API (GH-141630)
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-11-16 13:50:54 -05:00
Ken Jin
ed73c909f2
gh-139109: JIT _EXIT_TRACE to ENTER_EXECUTOR rather than _DEOPT (GH-141573) 2025-11-15 20:19:41 +00:00
Shamil
85f3009d75
gh-141553: Fix incorrect function signatures in _testmultiphase (#141554) 2025-11-15 18:46:54 +01:00
Yongzi Li
ed81baf81f
gh-140458: xmlrpc.client raises Fault, does not returns it. (GH-140759) 2025-11-15 17:14:23 +01:00
Pablo Galindo Salgado
4ceb077c5c
gh-141579: Fix perf_jit backend in sys.activate_stack_trampoline() (#141580) 2025-11-15 02:23:54 +00:00
Takuya UESHIN
53d65c840e
gh-136442: Fix unittest to return exit code 5 when setUpClass raises an exception (#136487) 2025-11-14 16:59:51 -08:00
Guo Ci
453d886f85
GH-90344: replace single-call io.IncrementalNewlineDecoder usage with non-incremental newline decoders (GH-30276)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Brett Cannon <brett@python.org>
2025-11-15 00:13:37 +00:00
Raymond Hettinger
f0a8bc737a
gh-140938: Raise ValueError for infinite inputs to stdev/pstdev (GH-141531)
Raise ValueError for infinite inputs to stdev/pstdev

---

Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-11-14 23:25:45 +00:00
Mikhail Efimov
1281be1caf
gh-141367: Use CALL_LIST_APPEND instruction only for lists, not for list subclasses (GH-141398)
Co-authored-by: Ken Jin <kenjin4096@gmail.com>
2025-11-14 21:38:39 +00:00
Kumar Aditya
f26ed455d5
gh-114203: skip locking if object is already locked by two-mutex critical section (#141476) 2025-11-14 23:17:59 +05:30
Locked-chess-official
da7f4e4b22
gh-141488: Add Py_ prefix to Include/datetime.h macros (#141493) 2025-11-14 15:52:14 +00:00
Steve Dower
b101e9d36b
Add PyManager troubleshooting steps for direct launch of script files (GH-141530) 2025-11-14 15:23:01 +00:00
Petr Viktorin
eab7385858
gh-116146: Avoid empty braces in _testembed.c (GH-141556) 2025-11-14 15:05:42 +00:00
Victor Stinner
a415a1812c
gh-139653: Remove assertions in _Py_InitializeRecursionLimits() (#141551)
These checks were invalid and failed randomly on FreeBSD
and Alpine Linux.
2025-11-14 14:56:37 +00:00
Sergey Miryanov
fa245df4a0
GH-141509: Fix warning about remaining subinterpreters (GH-141528)
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-11-14 14:55:04 +00:00
Sergey Miryanov
10bec7c1eb
GH-141312: Allow only integers to longrangeiter_setstate state (GH-141317)
This fixes an assertion error when the new computed start is not an integer.
2025-11-14 14:52:01 +00:00
Petr Viktorin
49e74210cb
gh-139344: Remove pending removal notice for undeprecated importlib.resources API (GH-141507) 2025-11-14 15:50:03 +01:00
Serhiy Storchaka
8deaa9393e
gh-122255: Synchronize warnings in C and Python implementations of the warnings module (GH-122824)
In the linecache module and in the Python implementation of the
warnings module, a DeprecationWarning is issued when
m.__loader__ differs from m.__spec__.loader (like in the C
implementation of the warnings module).
2025-11-14 16:49:28 +02:00
Peter Bierma
c10fa5be61
gh-131229: Temporarily skip test_basic_multiple_interpreters_deleted_no_reset (GH-141552)
This is a temporary band-aid to unblock other PRs.

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-11-14 14:22:36 +00:00
Stan Ulbrych
ef90261be5
gh-141004: Document PyOS_InterruptOccurred (GH-141526) 2025-11-14 06:20:36 -05:00
Petr Viktorin
5ac0b55ebc
gh-141376: Remove exceptions from make smelly (GH-141392)
* Don't ignore initialized data and BSS
* Remove exceptions for _init and _fini
2025-11-14 11:22:18 +01:00
Victor Stinner
3bacae5598
gh-131510: Use PyUnstable_Unicode_GET_CACHED_HASH() (GH-141520)
Replace code that directly accesses PyASCIIObject.hash with
PyUnstable_Unicode_GET_CACHED_HASH().

Remove redundant "assert(PyUnicode_Check(op))" from
PyUnstable_Unicode_GET_CACHED_HASH(), _PyASCIIObject_CAST() already
implements the check.
2025-11-14 11:13:24 +01:00
Hugo van Kemenade
181a2f4f2e
gh-139596: Cease caching config.cache & ccache in GH Actions (#141451) 2025-11-14 11:59:19 +02:00
Itamar Oren
1e4e59bb37
gh-116146: Add C-API to create module from spec and initfunc (GH-139196)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-11-14 10:43:25 +01:00
Petr Viktorin
a4dd66275b
gh-140550: Use a bool for the Py_mod_gil value (GH-141519)
This needs a single bit, but was stored as a void* in the module
struct. This didn't matter due to packing, but now that there's
another bool in the struct, we can save a bit of memory by
making md_gil a bool.

Variables that changed type are renamed, to detect conflicts.
2025-11-14 10:38:49 +01:00
M Bussonnier
4885ecfbda
gh-140790: pdb: Initialize instance variables in Pdb.__init__ (#140791)
Initialize lineno, stack, curindex, curframe, currentbp, and _user_requested_quit attributes in `Pdb.__init__``.
2025-11-13 19:18:54 -08:00
Osama Abdelkader
a486d452c7
gh-140601: Add ResourceWarning to iterparse when not closed (GH-140603)
When iterparse() opens a file by filename and is not explicitly closed,
emit a ResourceWarning to alert developers of the resource leak.

Signed-off-by: Osama Abdelkader <osama.abdelkader@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-11-13 21:05:28 +02:00
dr-carlos
209eaff68c
gh-137969: Fix double evaluation of ForwardRefs which rely on globals (#140974) 2025-11-13 18:17:17 +00:00
Ken Jin
4fa80ce74c
gh-139109: A new tracing JIT compiler frontend for CPython (GH-140310)
This PR changes the current JIT model from trace projection to trace recording. Benchmarking: better pyperformance (about 1.7% overall) geomean versus current https://raw.githubusercontent.com/facebookexperimental/free-threading-benchmarking/refs/heads/main/results/bm-20251108-3.15.0a1%2B-7e2bc1d-JIT/bm-20251108-vultr-x86_64-Fidget%252dSpinner-tracing_jit-3.15.0a1%2B-7e2bc1d-vs-base.svg, 100% faster Richards on the most improved benchmark versus the current JIT. Slowdown of about 10-15% on the worst benchmark versus the current JIT. **Note: the fastest version isn't the one merged, as it relies on fixing bugs in the specializing interpreter, which is left to another PR**. The speedup in the merged version is about 1.1%. https://raw.githubusercontent.com/facebookexperimental/free-threading-benchmarking/refs/heads/main/results/bm-20251112-3.15.0a1%2B-f8a764a-JIT/bm-20251112-vultr-x86_64-Fidget%252dSpinner-tracing_jit-3.15.0a1%2B-f8a764a-vs-base.svg

Stats: 50% more uops executed, 30% more traces entered the last time we ran them. It also suggests our trace lengths for a real trace recording JIT are too short, as a lot of trace too long aborts https://github.com/facebookexperimental/free-threading-benchmarking/blob/main/results/bm-20251023-3.15.0a1%2B-eb73378-CLANG%2CJIT/bm-20251023-vultr-x86_64-Fidget%252dSpinner-tracing_jit-3.15.0a1%2B-eb73378-pystats-vs-base.md .

This new JIT frontend is already able to record/execute significantly more instructions than the previous JIT frontend. In this PR, we are now able to record through custom dunders, simple object creation, generators, etc. None of these were done by the old JIT frontend. Some custom dunders uops were discovered to be broken as part of this work gh-140277

The optimizer stack space check is disabled, as it's no longer valid to deal with underflow.

Pros:
* Ignoring the generated tracer code as it's automatically created, this is only additional 1k lines of code. The maintenance burden is handled by the DSL and code generator.
* `optimizer.c` is now significantly simpler, as we don't have to do strange things to recover the bytecode from a trace.
* The new JIT frontend is able to handle a lot more control-flow than the old one.
* Tracing is very low overhead. We use the tail calling interpreter/computed goto interpreter to switch between tracing mode and non-tracing mode. I call this mechanism dual dispatch, as we have two dispatch tables dispatching to each other. Specialization is still enabled while tracing.
* Better handling of polymorphism. We leverage the specializing interpreter for this.

Cons:
* (For now) requires tail calling interpreter or computed gotos. This means no Windows JIT for now :(. Not to fret, tail calling is coming soon to Windows though https://github.com/python/cpython/pull/139962

Design:
* After each instruction, the `record_previous_inst` function/label is executed. This does as the name suggests.
* The tracing interpreter lowers bytecode to uops directly so that it can obtain "fresh" values at the point of lowering.
* The tracing version behaves nearly identical to the normal interpreter, in fact it even has specialization! This allows it to run without much of a slowdown when tracing. The actual cost of tracing is only a function call and writes to memory.
* The tracing interpreter uses the specializing interpreter's deopt to naturally form the side exit chains. This allows it to side exit chain effectively, without repeating much code. We force a re-specializing when tracing a deopt.
* The tracing interpreter can even handle goto errors/exceptions, but I chose to disable them for now as it's not tested.
* Because we do not share interpreter dispatch, there is should be no significant slowdown to the original specializing interpreter on tailcall and computed got with JIT disabled. With JIT enabled, there might be a slowdown in the form of the JIT trying to trace.
* Things that could have dynamic instruction pointer effects are guarded on. The guard deopts to a new instruction --- `_DYNAMIC_EXIT`.
2025-11-13 18:08:32 +00:00
Stan Ulbrych
196f1519cd
gh-141004: Document PyErr_RangedSyntaxLocationObject (#141521)
PyErr_RangedSyntaxLocationObject
2025-11-13 17:58:47 +00:00
Serhiy Storchaka
b2b68d40f8
gh-140873: Add support of non-descriptor callables in functools.singledispatchmethod() (GH-140884) 2025-11-13 19:48:52 +02:00
Victor Stinner
b99db92dde
gh-139653: Add PyUnstable_ThreadState_SetStackProtection() (#139668)
Add PyUnstable_ThreadState_SetStackProtection() and
PyUnstable_ThreadState_ResetStackProtection() functions
to set the stack base address and stack size of a Python
thread state.

Co-authored-by: Petr Viktorin <encukou@gmail.com>
2025-11-13 17:30:50 +01:00
Peter Bierma
d7862e9b1b
gh-141004: Document PyCode_Optimize (GH-141378) 2025-11-13 10:07:57 -05:00
Peter Bierma
f72768f30e
gh-141004: Document C APIs for dictionary keys, values, and items (GH-141009)
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2025-11-13 15:02:21 +00:00
Mikhail Efimov
c2470b39fa
gh-137959: Fix TIER1_TO_TIER2 macro name in JIT InternalDocs (GH-141496)
JIT InternalDocs fix
2025-11-13 14:44:40 +00:00
Cody Maloney
732224e113
gh-139871: Add bytearray.take_bytes([n]) to efficiently extract bytes (GH-140128)
Update `bytearray` to contain a `bytes` and provide a zero-copy path to
"extract" the `bytes`. This allows making several code paths more efficient.

This does not move any codepaths to make use of this new API. The documentation
changes include common code patterns which can be made more efficient with
this API.

---

When just changing `bytearray` to contain `bytes` I ran pyperformance on a
`--with-lto --enable-optimizations --with-static-libpython` build and don't see
any major speedups or slowdowns with this; all seems to be in the noise of
my machine (Generally changes under 5% or benchmarks that don't touch
bytes/bytearray).


Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Maurycy Pawłowski-Wieroński <5383+maurycy@users.noreply.github.com>
2025-11-13 13:19:44 +00:00
Serhiy Storchaka
2fbd396666
gh-140601: Refactor ElementTree.iterparse() tests (GH-141499)
Split existing tests on smaller methods and move them to separate class.
Rename variable "content" to "it".
Use BytesIO instead of StringIO.
Add few more tests.
2025-11-13 13:37:01 +02:00
Serhiy Storchaka
d8e6bdc0d0
gh-135801: Add the module parameter to compile() etc (GH-139652)
Many functions related to compiling or parsing Python code, such as
compile(), ast.parse(), symtable.symtable(),
and importlib.abc.InspectLoader.source_to_code() now allow to pass
the module name used when filtering syntax warnings.
2025-11-13 13:21:32 +02:00
Shamil
63548b3699
gh-140260: fix data race in _struct module initialization with subinterpreters (#140909) 2025-11-13 16:31:31 +05:30
Gregory P. Smith
781cc68c3c
gh-137109: refactor warning about threads when forking (#141438)
* gh-137109: refactor warning about threads when forking

This splits the OS API specific functionality to get the number of threads out
from the fallback Python method and warning raising code itself.  This way the
OS APIs can be queried before we've run
`os.register_at_fork(after_in_parent=...)` registered functions which
themselves may (re)start threads that would otherwise be detected.

This is best effort.  If the OS APIs are either unavailable or fail, the
warning generating code still falls back to looking at the Python threading
state after the CPython interpreter world has been restarted and the
after_in_parent calls have been made.  The common case for most Linux and macOS
environments should work today.

This also lines up with the existing TODO refactoring, we may choose to expose
this API to get the number of OS threads in the `os` module in the future.

* NEWS entry

* avoid "function-prototype" compiler warning?
2025-11-12 18:15:16 -08:00
Peter Bierma
26b7df2430
gh-141004: Document PyRun_InteractiveOneObject (GH-141405) 2025-11-12 17:52:56 -05:00
Michael Cho
dc0987080e
gh-124111: Fix TCL 9 thread detection (GH-128103) 2025-11-12 22:16:58 +00:00
Russell Keith-Magee
558936bec1
gh-141442: Add escaping to iOS testbed arguments (#141443)
Xcode concatenates the test argument array, losing quoting in the process.
2025-11-13 05:41:26 +08:00
Mikhail Efimov
35ed3e4ced
gh-140936: Fix JIT assertion crash at finalization if some generator is alive (GH-140969) 2025-11-12 19:04:02 +00:00
Savannah Ostrowski
1f381a579c
Add details about JIT build infrastructure and updating dependencies to Tools/jit (#141167) 2025-11-12 18:26:50 +00:00
Bob Kline
fbcac79951
gh-141412: Use reliable target URL for urllib example (GH-141428)
The endpoint used for demonstrating reading URLs is no longer
stable. This change substitutes a target over which we have more
control.
2025-11-12 12:25:23 -06:00
Savannah Ostrowski
d162c42790
GH-140479: Update JIT builds to use LLVM 21 (#140973) 2025-11-12 18:09:25 +00:00
Peter Bierma
9cd5427d96
gh-141004: Document PyType_SUPPORTS_WEAKREFS (GH-141408)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2025-11-12 11:38:17 -05:00
Stan Ulbrych
f1330b35b8
gh-141004: Document Py_MATH_{E, PI, TAU} constants (#141373) 2025-11-12 17:37:54 +01:00
M Bussonnier
2ac738d325
gh-132657: add regression test for PySet_Contains with unhashable type (#141411) 2025-11-12 20:50:08 +05:30
Stan Ulbrych
88aeff8eab
gh-87710: Update mime type for `.ai` (#141239) 2025-11-12 16:22:01 +02:00
yihong
f963864cb5
gh-141464: a typo in profiling sampling when can not run warning in linux (#141465) 2025-11-12 14:45:43 +02:00
Sergey B Kirpichev
e2026731f5
gh-141004: soft-deprecate Py_INFINITY macro (#141033)
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-11-12 13:44:49 +01:00
Rani Pinchuk
c6f3dd6a50
gh-98896: resource_tracker: use json&base64 to allow arbitrary shared memory names (GH-138473) 2025-11-12 13:35:01 +01:00
Jacob Austin Lincoln
70748bdbea
gh-131116: Fix inspect.getdoc() to work with cached_property objects (GH-131165) 2025-11-12 10:07:21 +00:00
Sergey B Kirpichev
23d85a2a3f
gh-141042: fix sNaN's packing for mixed floating-point formats (#141107) 2025-11-12 11:06:29 +01:00
Cody Maloney
7d54374f9c
gh-141311: Avoid assertion in BytesIO.readinto() (GH-141333)
Fix error in assertion which causes failure if pos is equal to PY_SSIZE_T_MAX.
Fix undefined behavior in read() and readinto() if pos is larger that the size
of the underlying buffer.
2025-11-12 11:57:05 +02:00
Sergey B Kirpichev
20f53df07d
gh-141370: document undefined behavior of Py_ABS() (GH-141439) 2025-11-12 11:50:44 +02:00
Cody Maloney
6f988b08d1
gh-85524: Raise "UnsupportedOperation" on FileIO.readall (#141214)
io.UnsupportedOperation is a subclass of OSError and recommended by
io.IOBase for this case; matches other read methods on io.FileIO.
2025-11-12 10:37:48 +01:00
Petr Viktorin
909f76dab9
gh-141376: Rename _AsyncioDebug to _Py_AsyncioDebug (GH-141391) 2025-11-12 09:42:56 +01:00
Mark Byrne
35908265b0
gh-75593: Add support of bytes and path-like paths in wave.open() (GH-140951) 2025-11-12 10:20:55 +02:00
Kumar Aditya
f1b7961ccf
GH-116946: revert eliminate the need for the GC in the _thread.lock and _thread.RLock (#141448)
Revert "GH-116946: eliminate the need for the GC in the `_thread.lock` and `_thread.RLock` (#141268)"

This reverts commit fbebca289d.
2025-11-12 07:21:43 +00:00
Kumar Aditya
ef474cfafb
gh-103847: fix cancellation safety of asyncio.create_subprocess_exec (#140805) 2025-11-12 10:47:38 +05:30
Sergey Miryanov
fbebca289d
GH-116946: eliminate the need for the GC in the _thread.lock and _thread.RLock (#141268) 2025-11-12 10:29:48 +05:30
Adam Turner
9ce99c6c19
GH-137618: Require Python 3.10 to Python 3.15 for PYTHON_FOR_REGEN (GH-137619)
* Require Python 3.11 to Python 3.15 for PYTHON_FOR_REGEN

* NEWS

* keep allowing python 3.10

---------

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2025-11-12 00:53:21 +00:00
Alejandro Cabello Jiménez
df6676549c
gh-137928: remove redundant size validation in multiprocessing.heap (GH-137929)
remove redundant size check, malloc does it

---------

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2025-11-12 00:36:43 +00:00
Jan-Eric Nitschke
0e88be6f55
gh-138621: Increase test coverage for csv.DictReader and csv.Sniffer (GH-138622)
* Increase test coverage for csv.DictReader and csv.Sniffer

Previously there were no tests for the DictReader fieldnames
setter, the case where a StopIteration was encountered when trying
to determine the fieldnames from the content or the case where
Sniffer could not find a delimiter.

* Revert whitespace change to comment

* Add a test that csv.Sniffer.has_header checks up to 20 rows

* Replace name and age with letter and offset

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>

* Address review comment

---------

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
2025-11-12 00:32:26 +00:00
Maurycy Pawłowski-Wieroński
0d7b48a8f5
gh-137952: update csv.Sniffer().has_header() docs to describe the actual off-by-onish behavior (GH-137953)
* checks 21, not 20
* Say "header" instead of "first row" to disambiguate per review.

---------

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Maurycy Pawłowski-Wieroński <maurycy@maurycy.com>
2025-11-12 00:03:14 +00:00
yihong
f5c2a41f9a
gh-138775: fix handle python -m base64 stdin correct with EOF signal (GH-138776)
* fix: handle  stdin correct with EOF single.
* fix: flollow the comments when pipe stdin use buffer
* Apply suggestions from code review
* fix: apply review comments in Lib/base64.py
* fix: address comments
* Reword comment and NEWS entry.

---------

Signed-off-by: yihong0618 <zouzou0208@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2025-11-11 23:47:57 +00:00
Serhiy Storchaka
4359706ac8
gh-120950: Fix overflow in math.log() with large int-like argument (GH-121011)
Handling of arbitrary large int-like argument is now consistent with
handling arbitrary large int arguments.
2025-11-12 00:27:13 +02:00
J Berg
9e7340cd3b
gh-139462: Make the ProcessPoolExecutor BrokenProcessPool exception report which child process terminated (GH-139486)
Report which process terminated as cause of BPE
2025-11-11 22:09:58 +00:00
Serhiy Storchaka
7906f4d96a
gh-132686: Add parameters inherit_class_doc and fallback_to_class_doc for inspect.getdoc() (GH-132691) 2025-11-12 00:01:25 +02:00
Adam Turner
c744ccb2c9
GH-139596: Cease caching config.cache & ccache in GH Actions (GH-139623)
* Cease caching config.cache in GH Actions\
* Remove ccache action
2025-11-11 13:51:22 -08:00
Mohsin Mehmood
af80fac425
gh-141314: Fix TextIOWrapper.tell() assertion failure with standalone carriage return (GH-141331)
The assertion was checking wrong variable (skip_back vs skip_bytes).
2025-11-11 23:49:54 +02:00
Peter Bierma
37e2762ee1
gh-141004: Document PyBytes_Repr and PyBytes_DecodeEscape (GH-141407)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2025-11-11 15:32:54 -05:00
Alper
c13b59204a
gh-116738: use PyMutex in lzma module (#140711)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-11-12 02:01:55 +05:30
Peter Bierma
2befce86e6
gh-141004: Document PyFile_OpenCode and PyFile_OpenCodeObject (GH-141413)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2025-11-11 15:31:29 -05:00
Alper
298e9074cd
gh-140476: optimize PySet_Add for frozenset in free-threading (#140440)
Avoids critical section in `PySet_Add` when adding items to newly created frozensets.

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-11-12 01:57:21 +05:30
Aniket
b5196fa15a
gh-137339: Clarify host and port parameter behavior in smtplib.SMTP{_SSL} initialization (#137340)
This also documents the previously undocumented default_port parameter.

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2025-11-11 15:25:26 -05:00
Mikhail Efimov
2fb2b82161
gh-141367: Use actual SPECIALIZATION_THRESHOLD value in specialization related test (GH-141417) 2025-11-11 20:16:46 +00:00
Steve Dower
336154f4b0
Add documentation for Python install manager's install_dir, global_dir and download_dir (GH-140223) 2025-11-11 20:02:49 +00:00
Marco Barbosa
c903d76832
gh-139533: fix refs to code without proper markups on turtledemo doc (GH-139534)
gh-139533: fix refs to code without proper markups on turtledemo documentation
2025-11-11 11:35:55 -08:00
yihong
0f09bda643
gh-140193: Forward port test_exec_set_nomemory_hang from 3.13 (GH-140187)
* chore: test_exec_set_nomemory_hang from 3.13

Signed-off-by: yihong0618 <zouzou0208@gmail.com>

* fix: apply comments

Signed-off-by: yihong0618 <zouzou0208@gmail.com>

* Update Lib/test/test_exceptions.py

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>

* Update Lib/test/test_exceptions.py

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>

* fix: windows too long name 60 times is enough

Signed-off-by: yihong0618 <zouzou0208@gmail.com>

---------

Signed-off-by: yihong0618 <zouzou0208@gmail.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-11-11 11:27:56 -08:00
Tan Long
713edbcebf
gh-141415: Remove unused variables and comment in _pyrepl.windows_console.py (#141416) 2025-11-11 14:27:21 -05:00
Peter Bierma
759a048d4b
gh-141004: Document PyType_Unwatch (GH-141414) 2025-11-11 12:22:16 -05:00
John Franey
d890aba748
gh-140942: Add MIME type for .cjs extension (#140937)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-11-11 14:33:56 +00:00
Kumar Aditya
7211a34fe1
gh-132657: optimize PySet_Contains for frozenset (#141183) 2025-11-11 20:02:32 +05:30
Petr Viktorin
799326b0a9
gh-141169: Re-raise exception from findfuncptr (GH-141349) 2025-11-11 13:52:13 +01:00
Sergey B Kirpichev
d69447445c
gh-141004: document Py_INFINITY and Py_NAN macros (#141145)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2025-11-11 11:13:59 +01:00
Victor Stinner
8435a2278f
gh-141376: Fix exported symbols (GH-141377)
* gh-141376: Fix exported symbols

* _io module: add "_Py_" prefix to "spec" variables. For example,
  rename bufferedrandom_spec to _Py_bufferedrandom_spec.
* typevarobject.c: add "static" to "spec" and "slots" variables.
* import.c: add "static" to "pkgcontext" variable.

* No longer export textiowrapper_slots
2025-11-11 09:21:24 +01:00
Krishna Chaitanya
92741c59f8
gh-140379: add hyperlinks to list and set (GH-140399)
add hyperlinks to list and set
2025-11-10 22:02:46 -08:00
Victor Stinner
9cb8c52d5e
gh-140485: Catch ChildProcessError in multiprocessing resource tracker (GH-141132) 2025-11-10 20:59:16 -08:00
Louis
46b58e1bb9
gh-140578: Doc: Remove sencence implying that concurrent.futures.ThreadPoolExecutor does not exist (#140689)
* Doc: Remove sencence implying that concurrent.futures.ThreadPoolExecutor does not exist

Closes #140578

* Add NEWS.d entry for gh-140578

---------

Co-authored-by: Louis Paternault <spalax@gresille.org>
2025-11-10 20:50:30 -08:00
Peter Bierma
86513f6c2e
gh-141004: Document missing frame APIs (GH-141189)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2025-11-10 21:35:47 +00:00
Stan Ulbrych
ed0a5fd8ca
gh-141004: Document PyType_FastSubclass (GH-141313)
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-11-10 12:46:41 -05:00
Sergey Miryanov
f835552946
GH-141212: Fix possible memory leak in gc_mark_span_push (gh-141213) 2025-11-10 11:19:13 -05:00
Sergey B Kirpichev
88953d5deb
gh-141004: Deprecate Py_MATH_El and Py_MATH_PIl macros (#141035)
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-11-10 16:36:01 +01:00
dr-carlos
55ea132313
gh-141174: Improve annotationlib._Stringifier test coverage (#141220)
* Test `_Stringifier.__convert_to_ast()` for containers

* Test partial evaluation of `ForwardRef`s in `_Stringifier`
2025-11-10 06:56:45 -08:00
Yongzi Li
59b793b0dd
gh-141343: Fix swapped words in sorted doc (GH-141348) 2025-11-10 08:55:15 -06:00
dr-carlos
1110e8f6a4
gh-141174: Improve annotationlib.call_annotate_function() test coverage (#141176)
* Test passing unsupported Format values to call_annotate_function()

* Test call_evaluate_function with fake globals that raise errors

* Fix typo and comparison in test_fake_global_evaluation
2025-11-10 06:54:50 -08:00
dr-carlos
19b573025e
gh-141174: Improve ForwardRef test coverage (#141175)
* Test unsupported format in ForwardRef.evaluate()

* Test dict cell closure with multiple variables

* Test all options in ForwardRef repr

* Test ForwardRef being a final class
2025-11-10 14:53:40 +00:00
Victor Stinner
68266c1f01
gh-141341: Rename COMPILER macro to _Py_COMPILER on Windows (#141342) 2025-11-10 15:50:51 +01:00
dr-carlos
06b62282c7
gh-141174: Improve annotationlib.get_annotations() test coverage (#141286)
* Test `get_annotations(format=Format.VALUE)` for stringized annotations on custom objects

* Test `get_annotations(format=Format.VALUE)` for stringized annotations on wrapped partial functions

* Update test_stringized_annotations_with_star_unpack() to actually test stringized annotations

* Test __annotate__ returning a non-dict

* Test passing globals and locals to stringized `get_annotations()`
2025-11-10 14:45:22 +00:00
David Ellis
12837c6363
gh-137530: generate an __annotate__ function for dataclasses __init__ (GH-137711) 2025-11-10 14:57:11 +01:00
Petr Viktorin
9f5152441d
gh-136702: Clear codec caches for refleak tests; use test.support helpers (GH-141345)
This should fix refleak buildbots.
2025-11-10 14:42:18 +01:00
Stan Ulbrych
13fa313beb
gh-139707: Specify winreg, msvcrt and winsound module availability in docs (GH-140429) 2025-11-10 14:37:34 +01:00
Karina Souza
6d710a79ea
gh-140500: Update download.html instructions (#141320)
Co-authored-by: Joseph Anthony Pasquale Holsten <joseph@josephholsten.com>
2025-11-10 14:39:49 +02:00
Stan Ulbrych
df19261621
gh-141004: Document pyctype.h macros (GH-141272) 2025-11-10 05:05:06 -05:00
Stan Ulbrych
9b0179fa87
gh-141004: Document Py_DTSF_* macros (GH-141310) 2025-11-09 19:43:03 -05:00
KarnbirKhera
b618731781
gh-62480: De-personalize "Partial mocking" section in unittest.mock examples (#141321)
* Refine some wording in unittest partial mock doc

Some of the descriptions were addressed in first person,
but have now been changed to address the user reading the documentation instead.

Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
2025-11-09 17:45:38 -06:00
Elena O
ec85d3cbfe
gh-62480: De-personalize "Mocking Unbound Methods" section in unittest.mock examples (#141322)
* Rewrite Mocking Unbound Methods paragraph to second person

Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-11-09 17:42:22 -06:00
Stan Ulbrych
14c62227f9
gh-141004: Document PySuper_Type (GH-141315) 2025-11-09 14:53:56 -05:00
Lakshya Upadhyaya
6f20ea1e2d
gh-140980: document SET_FUNCTION_ATTRIBUTE flag for annotate function (#141306) 2025-11-09 19:59:06 +01:00
Peter Bierma
807db68ddd
gh-141004: Document PyClassMethod* and PyStaticMethod* APIs (GH-141296) 2025-11-09 13:03:38 -05:00
Peter Bierma
18529b580b
gh-141004: Document PyFunction_SetKwDefaults (GH-141294) 2025-11-09 12:49:17 -05:00
Peter Bierma
b5a0c72492
gh-141004: Document PyExceptionInstance* APIs (GH-141301)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2025-11-09 17:09:09 +00:00
Peter Bierma
8dd8498286
gh-141004: Document Py_func_type_input (GH-141273) 2025-11-09 16:21:44 +00:00
Bénédikt Tran
dbe40904a7
gh-141004: document curses C API (#141254) 2025-11-09 15:44:26 +00:00
Stan Ulbrych
60155329a0
gh-141004: Document PyWeakref_CheckRefExact (GH-141279) 2025-11-09 10:32:39 -05:00
Peter Bierma
1d738dea63
gh-141004: Document deprecated aliases for memory allocation (GH-141146) 2025-11-09 10:06:38 -05:00
Bénédikt Tran
ae1f435071
gh-111389: replace deprecated occurrences of _PyHASH_* macros (#141236) 2025-11-09 15:14:08 +01:00
Bénédikt Tran
3ce2d57b2f
gh-100218: correctly set errno when socket.if_{nametoindex,indextoname} raise OSError (#140905)
Previously, socket.if_nametoindex() and socket.if_indextoname() could raise
an `OSError` with a `None` errno. Now, the errno from libc is propagated.
2025-11-09 13:45:38 +01:00
Bénédikt Tran
0c77e7c23b
gh-140530: fix a reference leak in an error path for raise exc from cause (#140908)
Fix a reference leak in `raise E from T` when `T` is an exception
subtype for which `T.__new__` does not return an exception instance.
2025-11-09 13:41:08 +01:00
Stan Ulbrych
5ba0a1aa1f
gh-136702: Deprecate passing non-ascii *encoding* (str) to encodings.normalize_encoding (#140030)
Closes #136702
2025-11-09 13:37:34 +01:00
Chilla Kalyan
7ae440f262
gh-141127: Clarify o?s.symlink() documentation for argument order (#141144) 2025-11-09 09:57:34 +01:00
Mohsin Mehmood
b36f01d03f
gh-141186: document asyncio.Task cancellation propagation behavior (#141249) 2025-11-09 10:19:29 +05:30
Stan Ulbrych
0ac890bea7
gh-141004: Document Py_BUILD_ASSERT* macros (GH-141266) 2025-11-08 14:22:05 -05:00
Stan Ulbrych
545299773b
gh-141004: Document the PyDoc_VAR macro (GH-141263) 2025-11-08 13:12:03 -05:00
Peter Bierma
5e5fc0404e
gh-141004: Document PyBUF_WRITEABLE (GH-141255) 2025-11-08 12:29:31 -05:00
Peter Bierma
be1c72a45d
gh-141004: Document PyErr_ProgramTextObject and PyErr_ProgramText (GH-141250)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2025-11-08 10:47:09 -05:00
莯凛
6545a4e8f8
gh-141246: Link to correct Windows docs in time.sleep() doc (#141248) 2025-11-08 15:56:48 +01:00
Bénédikt Tran
87942d911b
gh-141004: correctly document Py_HASH_* and PyHASH_* as hash_info attributes (#141233) 2025-11-08 12:22:02 +00:00
Naitree Zhu
9c3994663b
gh-139741: Make dist-pdf docs archive build work for macOS (#140837) 2025-11-08 12:19:42 +02:00
Serhiy Storchaka
610377056b
gh-140615: Update docstrings in the fcntl module (GH-140619)
* Refer to bytes objects or bytes-like objects instead of strings.
* Remove backticks -- they do not have effect on formatting.
* Re-wrap lines to ensure the pydoc output fits in 80 coluimns.
* Remove references to the 1024 bytes limit.
2025-11-08 12:17:59 +02:00
Serhiy Storchaka
7e90bac3cc
gh-140793: Improve documentatation and tests for the ensure_ascii option in the json module (GH-140906)
* Document that ensure_ascii=True forces escaping not only non-ASCII, but also
  non-printable characters (the only affected ASCII character is U+007F).
* Ensure that the help output for the json module does not exceed 80
  columns (except one long line in an example and generated lines).
* Add more tests.
2025-11-08 12:07:27 +02:00
Bénédikt Tran
8cec3d3a9d
gh-141004: fix versionadded typo for Py_HASH_SIPHASH13 (#141223) 2025-11-08 09:10:27 +00:00
Brandon Hubacher
c1785129c3
fix typos in contextvars asyncio support example docs (#141219)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-11-08 09:08:19 +00:00
Steve Dower
cd0b3e5d12
gh-140849: Update bundled liblzma to 5.8.1 on Windows (#141022) 2025-11-07 22:28:01 -08:00
Peter Bierma
d13ee0ae18
gh-141004: Document PyTraceBack* APIs (GH-141192)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2025-11-07 13:46:47 -05:00
Bénédikt Tran
3989e12d39
gh-141004: Document Py_HASH_* macros (#141205) 2025-11-07 19:25:32 +01:00
Peter Bierma
9420795b47
gh-141004: Document PyErr_WarnExplicitFormat (GH-141187) 2025-11-07 11:19:14 -05:00
Peter Bierma
7af9b5354d
gh-141004: Document PyCapsule_Type (GH-141079) 2025-11-07 09:09:38 -05:00
W. H. Wang
920286d6b2
Update NaNs handling description in c-api/float.rst (#141179)
Clarified the behavior of NaNs on IEEE platforms regarding signaling and quiet NaNs.
2025-11-07 14:34:49 +01:00
Petr Viktorin
ffd64737d0
Clarify argument/result ownership/validity for PyModule_* functions (GH-141159)
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-11-07 14:17:47 +01:00
Benel Tayar
a7bf27f7f5
gh-141141: Make base64.b85decode() thread safe (GH-141149) 2025-11-07 10:47:25 +00:00
Bénédikt Tran
9a19900673
gh-140734: fix off-by-one error when comparing to _SUN_PATH_MAX (#140903)
The limit includes a NULL terminator.
2025-11-07 09:54:02 +00:00
yihong
c77441ef1d
gh-141125: delete unused import textwrap in interpreter.py (#141126) 2025-11-06 16:02:47 -08:00
Savannah Ostrowski
42d0140860
GH-136895: Fixes for pulling LLVM as a release artifact (#141002) 2025-11-06 11:58:01 -08:00
Rodrigo Girão Serrão
9bf5100037
Minor documentation improvements (#140626) 2025-11-06 19:11:50 +02:00
Serhiy Storchaka
e95e783dff
Remove duplicated tests in test_base64 (gh-125346) (GH-141153) 2025-11-06 16:48:58 +00:00
Peter Bierma
0b260305d3
gh-141004: Document Py_GetRecursionLimit and Py_SetRecursionLimit (GH-141151)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2025-11-06 16:37:52 +00:00
AN Long
bea0d3d12b
gh-140826: Update winreg's docstring (GH-141050) 2025-11-06 17:33:30 +02:00
Dino Viehland
13f09a60f4
gh-141150: Don't rely on implicit conversion from void * to pointer in _PyModule… (#141147)
Don't rely on implicit conversion from void * to pointer in _PyModule_GetToken
2025-11-06 07:16:56 -08:00
Victor Stinner
2e5e6fd380
gh-134745: Use "pymutex" for sys.thread_info on Windows (#141140) 2025-11-06 16:10:39 +01:00
Peter Bierma
bcc524f82d
gh-141004: Document PyLong_FromPid and PyLong_AsPid (GH-141028)
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-11-06 09:01:48 -05:00
Stan Ulbrych
54110e20e0
gh-141004: Document Py_hexdigits (GH-141059)
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-11-06 08:48:42 -05:00
Peter Bierma
1697cb5710
gh-141004: Document built-in iterator types in the C API (GH-141006)
Adds documentation for each of the following:

- PyEnum_Type
- PyFilter_Type
- PyMap_Type
- PyReversed_Type
- PyZip_Type

In addition, PyRange_Type and PyRange_Check are also documented.
2025-11-06 07:29:04 -05:00
Petr Viktorin
d2ce6d708a
gh-139707: Add docs for optional modules (GH-140171)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Emma Smith <emma@emmatyping.dev>
Co-authored-by: Author: Terry Jan Reedy <tjreedy@udel.edu>
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-11-06 11:49:44 +01:00
Lysandros Nikolaou
86ab7bb87a
gh-137232: Update free-threading HOWTOs with up-to-date info for 3.14 (#140817) 2025-11-06 11:20:02 +01:00
Serhiy Storchaka
13360efd38
gh-125346: Add more base64 tests (GH-141061)
Add more tests for the altchars argument of b64decode() and for the map01
argument of b32decode().
2025-11-06 11:34:32 +02:00
Stan Ulbrych
4e6e208be9
Minor fixes to idle.rst and regenerate help.html (#140037) 2025-11-06 03:21:02 -05:00
Terry Jan Reedy
6a7c969d00
gh-129876: Move misplaced IDLE news item (#141118) 2025-11-06 03:08:24 -05:00
Stan Ulbrych
d6c89a2df2
gh-140939: Fix memory leak in _PyBytes_FormatEx error path (#140957) 2025-11-06 11:20:57 +05:30
RayXu
9037a386c6
docs: fix a grammatical error in function.rst (#140990) 2025-11-06 11:18:30 +05:30
Bartosz Sławecki
8822166200
gh-140569: recommend the new REPL in the asyncio REPL docs (#140570)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-11-06 11:09:07 +05:30
Kumar Aditya
101c9c0a21
gh-118516: clarify that subprocess are automatically killed if transport gets garbage collected (#140997) 2025-11-06 10:21:13 +05:30
Savannah Ostrowski
95f6e1275b
GH-108009: Add clarification of parser and argument defaults in argparse docs (#124154)
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
2025-11-05 22:46:30 +00:00
Peter Bierma
f0ab07f22c
gh-141004: Document PyDict_GET_SIZE (GH-141078) 2025-11-05 17:32:12 -05:00
Zenith
227f4abacd
gh-76007: remove curses.__version__ doc (#141052) 2025-11-06 00:00:36 +02:00
Peter Bierma
5b02c6e920
gh-141004: Document Py_RETURN_NAN and Py_RETURN_INF (GH-141029)
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
2025-11-05 17:00:26 -05:00
AN Long
11fc411f98
gh-140916: Remove unused codes in winreg.c (#140934) 2025-11-05 22:49:45 +01:00
Edward Xu
b83f379a97
gh-133467: Fix typeobject tp_base race in free threading (gh-140549) 2025-11-05 16:20:40 -05:00
Victor Stinner
986bb0a1a2
gh-83714: Fix stat_nanosecond_timestamp() for 32-bit time_t (#141069) 2025-11-05 21:16:37 +01:00
Victor Stinner
f458ac01ba
Fix compiler warnings in remote debugging (#141060)
Example of fixed warnings on 32-bit Windows:

    Python\remote_debugging.c(24,53): warning C4244: 'function':
    conversion from 'uint64_t' to 'uintptr_t', possible loss of data

    Modules\_remote_debugging_module.c(789,44): warning C4244:
    'function': conversion from 'uint64_t' to 'size_t', possible loss
    of data
2025-11-05 20:18:45 +01:00
Sachin Shah
1d25b751c5
gh-140650: Fix write(), flush() and close() methods of io.BufferedWriter (GH-140653)
They could raise SystemError or crash when getting the "closed" attribute
or converting it to boolean raises an exception.
2025-11-05 21:15:27 +02:00
Mikhail Efimov
3cb1ab0e5d
gh-131527: Stackref debug borrow checker (#140599)
Add borrow checking to the stackref debug mode

---------

Co-authored-by: mpage <mpage@meta.com>
2025-11-05 11:12:56 -08:00
Sebastian Pipping
baa9f33897
gh-139313: Improve docs on XML security (GH-139460)
Clarify that:
- it takes parsing for an attack
- that some doors are closed by default
- only Expat version 2.7.2 has all the fixes
- use of the bundle depends on configuration
2025-11-05 20:59:59 +02:00
Victor Stinner
4ac16dd109
Fix a compiler warning in _randommodule.c (#141058)
The test just before the cast ensures that the cast cannot overflow.

Fix the warning on 32-bit Windows:

    Modules\_randommodule.c(525,28): warning C4244: '=': conversion
    from 'uint64_t' to 'Py_ssize_t', possible loss of data
2025-11-05 18:00:32 +00:00
Victor Stinner
8d55faf2d6
Remove internal _PyTime_AsLong() function (#141053)
* Replace _PyTime_AsLong() with PyLong_FromInt64()
* Replace _PyTime_FromLong() with PyLong_AsInt64().
2025-11-05 18:37:06 +01:00
Victor Stinner
30ab627aab
gh-83714: Fix a compiler warning in stat_nanosecond_timestamp() (#141043)
Disable the fast path on systems with 32-bit long.
2025-11-05 18:31:35 +01:00
Victor Stinner
579b2f8910
gh-140550: Run make regen-limited-abi (#141056) 2025-11-05 16:57:06 +00:00
Peter Bierma
3f6aca1be4
gh-141004: Document PyMemoryView_Type (GH-141034) 2025-11-05 11:45:13 -05:00
Peter Bierma
35528fccdc
gh-141004: Document missing iterator types in the C API (GH-141010)
Add documentation for each of the following:

- PyByteArrayIter_Type
- PyBytesIter_Type
- PyListIter_Type
- PyListRevIter_Type
- PySetIter_Type
- PyTupleIter_Type
- PyRangeIter_Type
- PyLongRangeIter_Type
- PyDictIterKey_Type
- PyDictRevIterKey_Type
- PyDictIterValue_Type
- PyDictRevIterValue_Type
- PyDictIterItem_Type
- PyDictRevIterItem_Type

---------

Co-authored-by: Petr Viktorin <encukou@gmail.com>
2025-11-05 09:13:57 -05:00
Petr Viktorin
589a03a8ce
gh-140550: Initial implementation of PEP 793 – PyModExport (GH-140556)
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-11-05 12:31:42 +01:00
Petr Viktorin
f2bce51b98
gh-140691: urllib.request: Close FTP control socket if data socket can't connect (GH-140835)
Co-authored-by: codenamenam <bluetire27@gmail.com>
2025-11-05 11:52:11 +01:00
Lê Nam Khánh
335d83ec04
Fix typo in Apple/__main__.py (#141038)
Corrected a typo in a return value docstring.
2025-11-05 15:23:25 +08:00
Clifford Gama
1ae900424b
Docs: Fix cached calls count in factorial example (gh-140882) 2025-11-05 00:29:25 +00:00
alex
fa02422918
gh-141007: update string module source code link (#141008)
In 3.14, the former string.py became `__init__.py` within a new `string` directory that also contains a new submodule file, `templatelib.py`.
2025-11-04 19:05:49 -05:00
Miro Hrončok
d5b00c74b3
gh-140454: Normalize the JIT stencils filename on Linux to avoid mismatches between the Makefile and the generator (#140823) 2025-11-04 14:29:15 -08:00
Petr Viktorin
d81e1ef0f3
gh-138189: Document type slots, and other constants, as part of Limited API (GH-138190)
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-11-04 22:58:53 +01:00
Stan Ulbrych
bfe54810c4
gh-141004: Document Py_UNICODE_{HIGH, LOW}_SURROGATE functions (GH-141019) 2025-11-04 16:19:06 -05:00
Filip Łajszczak
ce1bb85d28
gh-139434: Update selected RFC 2822 references to RFC 5322 (#139435)
Update selected RFC 2822 references to RFC 5322

RFC 2822 was obsoleted by RFC 5322 in 2008. This updates references
to use the current standard in documentation, docstrings, and comments.

It preserves RFC 2822 references in legacy API components to maintain their
historical context.

RFC 822 → RFC 2822 → RFC 5322 progression is explained where relevant.

In some places specific sections of RFC are referenced where it seems helpful.

Scout rule was applied in some places and RFC mentions format was
normalized in doc strings and comments.
2025-11-04 14:46:07 -05:00
Guo Ci
97d8dda980
Docs: Fix typo in email.headerregistry.rst (#140965)
Fix missing 'Header' suffix on header class name in `email.headerregistry.rst`
2025-11-04 14:29:13 -05:00
Vinay Sajip
66c86c6563
gh-134817: Restore accidentally deleted line in documentation. (GH-141013) 2025-11-04 18:29:44 +00:00
Brett Cannon
8a7dbb7a68
Document that returning sys.monitoring.DISABLE in response to a global event raises ValueError (#140726)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2025-11-04 10:28:17 -08:00
Savannah Ostrowski
40096da95a
GH-139946: Colorize error and warning messages in argparse (#140695)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-11-04 16:31:35 +00:00
Serhiy Storchaka
1326d2a808
gh-140979: Fix off-by-one error in the RE code validator (GH-140984)
It was too lenient and allowed MARK opcodes with too large value.
2025-11-04 17:49:44 +02:00
Abhishek Tiwari
fa9c3eefd4
gh-140797: Forbid capturing groups in re.Scanner lexicon patterns (GH-140944) 2025-11-04 12:54:28 +02:00
Victor Stinner
a84181c31b
gh-140815: Fix faulthandler for invalid/freed frame (#140921)
faulthandler now detects if a frame or a code object is invalid or
freed.

Add helper functions:

* _PyCode_SafeAddr2Line()
* _PyFrame_SafeGetCode()
* _PyFrame_SafeGetLasti()

_PyMem_IsPtrFreed() now detects pointers in [-0xff, 0xff] range
as freed.
2025-11-04 11:48:28 +01:00
commitWithTisha
08115d241a
Fix minor typo: 'web site' -> 'website' (GH-140561) 2025-11-04 10:23:49 +01:00
Ken Jin
947bb4642c
gh-140889: Bump tailcall and JIT CI to llvm 20 (#140963) 2025-11-03 12:37:29 -08:00
Petr Viktorin
3f2b83e959
Fix minor typos and wording in C API docs (#140955) 2025-11-03 22:04:46 +02:00
Savannah Ostrowski
57f4d09a6f
JIT: Fix compiler warning from visibility attribute in typedef (#139981) 2025-11-03 19:46:53 +00:00
Neil Schemenauer
c98c5b3449
gh-131253: free-threaded build support for pystats (gh-137189)
Allow the --enable-pystats build option to be used with free-threading.  The
stats are now stored on a per-interpreter basis, rather than process global.
For free-threaded builds, the stats structure is allocated per-thread and
then periodically merged into the per-interpreter stats structure (on thread
exit or when the reporting function is called). Most of the pystats related
code has be moved into the file Python/pystats.c.
2025-11-03 11:36:37 -08:00
Hugo van Kemenade
cf1a2c1ee4
gh-133600: Run Tools/wasm/wasi on CI instead of deprecated Tools/wasm/wasi.py (#140907) 2025-11-03 21:26:09 +02:00
Ken Jin
9791a506c2
gh-140889: Test tailcall and JIT in CI (GH-140891) 2025-11-03 19:07:55 +00:00
Savannah Ostrowski
4e2ff4ac4c
GH-136895: Update JIT builds to use LLVM 20 (#140329)
Co-authored-by: Emma Harper Smith <emma@emmatyping.dev>
2025-11-03 10:01:44 -08:00
Yongzi Li
b373d3494c
Docs: Fix a typo in idle.rst (Chitespace -> Whitespace) (GH-140946)
Fix typo in idle.rst
2025-11-03 16:48:10 +01:00
Stan Ulbrych
478b8dab0b
Docs: Fix typo in codecs documentation (GH-140883) 2025-11-03 16:47:52 +01:00
Jelle Zijlstra
b1027d4762
gh-138151: Fix annotationlib handling of multiple nonlocals (#138164) 2025-11-03 07:22:32 -08:00
Jelle Zijlstra
d590685297
gh-133879: Clean up What's New for 3.15 (#140435)
Clean up What's New for 3.15

A bit early but I was reading through it and noticed some issues:

- A few improvements were listed in the removals section
- The "Porting to 3.15" section in the C API chapter had some
  changes that aren't about the C API
- Some other typos and wording fixes
2025-11-03 06:54:23 -08:00
Jelle Zijlstra
7a9437d986
gh-140348: Fix using | on unusual objects plus Unions (#140383) 2025-11-03 06:50:37 -08:00
AN Long
248ce9fa8c
gh-140826: Compare winreg.HKEYType by the internal handle value (GH-140843) 2025-11-03 10:14:22 +02:00
Jelle Zijlstra
349de57839
Revert "gh-137969: Fix evaluation of ref.evaluate(format=Format.FORWARDREF) objects (#138075)" (#140930)
This reverts commit 63e01d6bae.
2025-11-02 21:35:15 -08:00
Frost Ming
121c219e30
Remove redundant sys.exit(2) call in pdb CLI (#139948) 2025-11-02 18:47:18 -08:00
dr-carlos
63e01d6bae
gh-137969: Fix evaluation of ref.evaluate(format=Format.FORWARDREF) objects (#138075)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2025-11-02 17:20:30 -08:00
dr-carlos
e66f87ca73
gh-138425: Correctly partially evaluate global generics with undefined params in ref.evaluate(format=Format.FORWARDREF) (#138430)
Co-authored-by: sobolevn <mail@sobolevn.me>
2025-11-02 15:15:47 -08:00
Krishna Chaitanya
31de83d5e2
gh-140693: Improve argparse documentation about controlling color (#140737) 2025-11-02 13:58:16 -08:00
Sebastian Rittau
9e5628ad68
gh-140808: Remove __class_getitem__ from mailbox._ProxyFile (#140838)
Co-authored-by: Emma Smith <emma@emmatyping.dev>
2025-11-02 13:56:59 -08:00
Jiucheng(Oliver)
6d45cd8dbb
gh-135307: Fix email error when policy max_line_length is set to 0 or None (#135367)
RDM: Like the change made in a earlier PR to the folder, we can/must use 'maxlen' as a stand in for 'unlimited' when computing line lengths when max_line_length is 0 or None; otherwise the computation results in a traceback.
2025-11-02 09:32:14 -05:00
RayXu
173cc53d9f
Docs: avoid informal formulation in Doc/c-api/conversion.rst (#140898) 2025-11-02 13:49:49 +00:00
Sergey Miryanov
da65f38a94
gh-134786: raise error if Py_TPFLAGS_MANAGED_WEAKREF or Py_TPFLAGS_MANAGED_DICT is used without Py_TPFLAGS_HAVE_GC set (#135863) 2025-11-02 16:34:49 +05:30
RayXu
d12cbf2865
Docs: fix some grammatical errors in Doc/c-api/dict.rst (#140899) 2025-11-02 09:31:26 +01:00
Krishna Chaitanya
2f60b8f02f
gh-140513: Fail to compile if _Py_TAIL_CALL_INTERP is set but preserve_none and musttail do not exist. (GH-140548)
Co-authored-by: Chris Eibl <138194463+chris-eibl@users.noreply.github.com>
2025-11-01 16:41:23 +00:00
Dino Viehland
b1554146c2
gh-140868: Don't rely on undefined left shift behavior in assert (#140869)
Don't rely on undefined left shift behavior in assert
2025-11-01 12:23:58 -04:00
Ken Jin
f701f98052
gh-140312: Set lltrace on JIT debug builds (GH-140313)
Co-authored-by: Mark Shannon <mark@hotpy.org>
2025-11-01 16:22:59 +00:00
Damian Shaw
d440a0f96c
gh-140874: Upgrade bundled pip to 25.3 (GH-140876)
Upgrade bundled pip to 25.3
2025-11-01 10:25:19 +00:00
Filipe Laíns
ede5693be1
GH-119668: expose importlib.machinery.NamespacePath (#119669)
* GH-119668: expose importlib.NamespacePath

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

* add news

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

* add to docs

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

* Apply suggestions from code review

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>

* Fix news (importlib.NamespacePath > importlib.machinery.NamespacePath)

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

* Link to module.__path__ in NamespacePath docs

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

* Mention the path argument in the documentation

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

* Simplify docs text

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

* Highlight argument names in docs text

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

* Update Lib/importlib/_bootstrap_external.py

Co-authored-by: Brett Cannon <brett@python.org>

* Rewrite NamespacePath's doc

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

* Specify path_finder's type in the NamespacePath docstring

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

* Fix doc tests

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

* Apply suggestions from code review

Co-authored-by: Barry Warsaw <barry@python.org>

* Fix doc lint

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

* Update Doc/library/importlib.rst

Co-authored-by: Brett Cannon <brett@python.org>

---------

Signed-off-by: Filipe Laíns <lains@riseup.net>
Co-authored-by: Brett Cannon <brett@python.org>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Barry Warsaw <barry@python.org>
2025-11-01 00:39:48 +00:00
Serhiy Storchaka
a17c57eee5
gh-137836: Support more RAWTEXT and PLAINTEXT elements in HTMLParser (GH-137837)
* the "plaintext" element
* the RAWTEXT elements "xmp", "iframe", "noembed" and "noframes"
* optionally RAWTEXT (if scripting=True) element "noscript"
2025-10-31 17:44:02 +02:00
Pål Grønås Drange
07912f8632
gh-140212: Add html for year-month option in Calendar (#140230)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-10-31 17:28:53 +02:00
Serhiy Storchaka
dcf3cc5796
gh-81313: Add the math.integer module (PEP-791) (GH-133909) 2025-10-31 16:13:43 +02:00
Bénédikt Tran
680a5d070f
gh-136063: fix quadratic-complexity parsing in email.message._parseparam (GH-136072) 2025-10-31 14:50:40 +01:00
Serhiy Storchaka
f029e8db62
gh-136065: Fix quadratic complexity in os.path.expandvars() (GH-134952)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2025-10-31 14:49:51 +01:00
R. David Murray
81cec22a9b
gh-57665: Remove 'response_class' from getresponse docstring. (#140707)
Remove 'response_class' from getresponse docstring.

This variable is not documented as part of the API in the standard
library documentation; it should be considered as an implementation
detail and as such should not be included in the doc string.

Closes #57665.
2025-10-31 06:09:22 -07:00
Semyon Moroz
e733dc90f3
gh-131885: Document * for code.InteractiveConsole (#132029) 2025-10-31 11:16:32 +01:00
Mikhail Efimov
d17f28fed5
gh-140373: Correctly emit PY_UNWIND event when generator is closed (GH-140767) 2025-10-31 10:09:22 +00:00
Brett Cannon
ac1ffd7785
Move WASI CI over to Arm runners (GH-140810) 2025-10-30 15:29:39 -07:00
Brett Cannon
abd19eddee
Make printing log lines to the terminal a little cleaner when building WASI (GH-140772) 2025-10-30 10:35:53 -07:00
Guo Ci
e4deefbb2f
gh-140766: [Enum] add show_flag_values and bin to enum.__all__ (GH-140765)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2025-10-30 10:32:55 -07:00
Brett Cannon
95a3564869
GH-140768: Warn when the WASI SDK version doesn't match the supported version (GH-140769) 2025-10-30 09:32:18 -07:00
yihong
4e6dba0ef7
gh-139246: zero-width word paste can be wrong in default repl (GH-139254)
Signed-off-by: yihong0618 <zouzou0208@gmail.com>
Co-authored-by: grayjk <grayjk@gmail.com>
2025-10-30 16:14:06 +01:00
Stan Ulbrych
a3ce2f77f0
gh-55531: Implement normalize_encoding in C (#136643)
Closes gh-55531
2025-10-30 15:31:47 +01:00
Serhiy Storchaka
6826166280
gh-135801: Improve filtering by module in warn_explicit() without module argument (GH-140151)
* Try to match the module name pattern with module names constructed
  starting from different parent directories of the filename.
  E.g., for "/path/to/package/module" try to match with
  "path.to.package.module", "to.package.module", "package.module" and
  "module".
* Ignore trailing "/__init__.py".
* Ignore trailing ".pyw" on Windows.
* Keep matching with the full filename (without optional ".py" extension)
  for compatibility.
* Only ignore the case of the ".py" extension on Windows.
2025-10-30 15:55:39 +02:00
Victor Stinner
efc37ba49e
gh-139353: Add Objects/unicode_writer.c file (#139911)
Move the public PyUnicodeWriter API and the private _PyUnicodeWriter
API to a new Objects/unicode_writer.c file.

Rename a few helper functions to share them between unicodeobject.c
and unicode_writer.c, such as resize_compact() or unicode_result().
2025-10-30 14:36:15 +01:00
Petr Viktorin
75a1cbdd38
gh-140748: socket_helper.transient_internet: Unwrap UrlError.__cause__ (GH-140749) 2025-10-30 12:14:17 +01:00
Stan Ulbrych
134adb32e8
gh-139188: Remove Tools/tz/zdump.py script (GH-139189) 2025-10-30 12:12:45 +01:00
Serhiy Storchaka
09b1f10ef7
gh-140481: Improve error message when trying to iterate a Tk widget, image or font (GH-140501) 2025-10-30 13:11:56 +02:00
Serhiy Storchaka
ad0a3f733b
gh-131927: Do not emit PEP 765 warnings in ast.parse() (GH-139642)
ast.parse() no longer emits syntax warnings for
return/break/continue in finally (see PEP-765) -- they are only
emitted during compilation.
2025-10-30 13:00:42 +02:00
Stan Ulbrych
2a904263aa
gh-131885: Update unicodedata function signatures to use / (#140270) 2025-10-30 10:54:03 +00:00
Serhiy Storchaka
327dbbedff
gh-138162: Fix logging.LoggerAdapter with merge_extra=True and without the extra argument (GH-140511) 2025-10-30 12:52:02 +02:00
Stan Ulbrych
622d97b8bb
gh-139198: Remove Tools/scripts/checkpip.py script (GH-139199)
Commit
2025-10-30 11:50:16 +01:00
Donghee Na
c45e6e1bb3
gh-137821: Improve Argument Clinic definitions in the `_json` module (#140780) 2025-10-30 10:32:08 +00:00
Stan Ulbrych
dbe3950a76
gh-129117: Add unicodedata.isxidstart() function (#140269)
Expose `_PyUnicode_IsXidContinue/Start` in `unicodedata`:
add isxidstart() and isxidcontinue() functions.

Co-authored-by: Victor Stinner <vstinner@python.org>
2025-10-30 10:18:12 +00:00
Yoonho Hann
25bd72d683
gh-137821: Convert _json module to use Argument Clinic (gh-140778) 2025-10-30 09:42:09 +00:00
Guo Ci
b85e10fd12
gh-120057: add os.reload_environ to __all__ (#140763)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2025-10-29 21:21:26 +00:00
Stan Ulbrych
c74793c450
gh-140741: Fix test added in gh-140745 (#140760)
Commit
2025-10-29 16:10:58 +00:00
Mikhail Efimov
8706167474
gh-140576: Fixed crash produced by lexer in case of dedented zero byte (#140583) 2025-10-29 13:27:35 +00:00
Cody Maloney
6ff62ac4fb
gh-140082: Forward colorizing from libregrtest to unittest (#140083)
libregrtest redirects test output to a file as part of its operation.
When `unittest` checks to see if it should colorize with
`isatty(sys.stdout)` that fails resulting in no colorizing of the
unittest output.

Update `libregrtest` to set `FORCE_COLOR=1` when redirecting test output
so that unittest will do color printing.

Co-authored-by: Victor Stinner <vstinner@python.org>
2025-10-29 13:33:44 +01:00
Victor Stinner
376559bf54
gh-140702: Log color and GHA env vars in test.pythoninfo (#140747) 2025-10-29 13:29:10 +01:00
Stan Ulbrych
d3aa5f689c
gh-140741: Fix profiling.sampling handling of error raised by target (#140745) 2025-10-29 11:38:28 +00:00
Mikhail Efimov
02202c117b
gh-140551: Fix dict crash if clear is called at lookup stage (#140558)
Co-authored-by: Inada Naoki <songofacandy@gmail.com>
2025-10-29 14:36:23 +05:30
Russell Keith-Magee
9f8d005d29
gh-140702: Add test skip for Unix Datagram tests on iOS when on Github Actions (#140740)
Exposes the GITHUB_ACTIONS environment variable to iOS simulator test runs, and
uses this variable to skip a Unix Datagram socketserver test that is unreliable
in the iOS GitHub Actions environment.

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-10-29 08:33:04 +00:00
Frost Ming
058bc182b9
gh-139940: Handle RuntimeError when attaching to a non-existing process in pdb. (#139941) 2025-10-28 23:12:12 -07:00
tconley1428
c41f84ff61
gh-140228: Avoid making unnecessary syscalls in linecache for frozen modules (#140377) 2025-10-28 23:06:22 -07:00
Maciej Olko
ce4b0ede16
gh-139588: Increase maximum LaTeX list depth (#140709)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-10-28 19:56:23 +00:00
Victor Stinner
c6d4c79c9a
gh-140657: Don't rerun test_import single phase init test (GH-140712)
test_basic_multiple_interpreters_main_no_reset() leaks memory:
import_in_subinterp() is called with postcleanup=False.
2025-10-28 18:05:03 +01:00
Victor Stinner
80f20f58b2
gh-125434: Fix non-ASCII thread names in faulthandler on Windows (#140700)
Add _Py_DumpWideString() function to dump a wide string as ASCII. It
supports surrogate pairs.

Replace _Py_EncodeLocaleRaw() with _Py_DumpWideString()
in write_thread_name().
2025-10-28 14:41:51 +01:00
Peter Bierma
2cefa70eb9
gh-140544: Always assume that thread locals are available (GH-140690)
Python has required thread local support since 3.12 (see GH-103324). By assuming that thread locals are always supported, we can improve the performance of third-party extensions by allowing them to access the attached thread and interpreter states directly.
2025-10-28 09:07:19 -04:00
Mikhail Efimov
88ad41fa34
gh-139951: Tests on tuple GC tracking (#140575) 2025-10-28 10:55:41 +01:00
Sergey Miryanov
d26686a7f8
GH-140590: Fix setstate for functools.partial C-module (GH-140671)
Co-authored-by: Mikhail Efimov <efimov.mikhail@gmail.com>
2025-10-28 10:28:32 +01:00
Russell Keith-Magee
f4e6370582
gh-140189: Add CI job to test iOS builds. (#140190)
Adds a CI configuration to test iOS builds on every build.

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-10-28 13:46:38 +08:00
Kumar Aditya
f5394c257c
gh-140544: fix build for including pycore_pystate.h when HAVE_THREAD_LOCAL is not defined (#140623) 2025-10-28 01:40:41 +05:30
Serhiy Storchaka
364ae607d8
gh-140634: Fix a reference counting bug in os.sched_param.__reduce__() (GH-140667) 2025-10-27 21:42:32 +02:00
Ken Jin
a716091227
gh-140104: Set next_instr properly in the JIT during exceptions (GH-140233)
Co-authored-by: devdanzin <74280297+devdanzin@users.noreply.github.com>
Co-authored-by: Chris Eibl <138194463+chris-eibl@users.noreply.github.com>
2025-10-27 18:26:47 +00:00
Cody Maloney
0f0a362768
gh-140607: Validate returned byte count in RawIOBase.read (#140611)
While `RawIOBase.readinto` should return a count of bytes between 0 and
the length of the given buffer, it is not required to. Add validation
inside RawIOBase.read() that the returned byte count is valid.

Co-authored-by: Shamil <ashm.tech@proton.me>
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-10-27 18:06:46 +00:00
Victor Stinner
313145eab5
gh-125434: Display thread name in faulthandler on Windows (#140675) 2025-10-27 18:41:18 +01:00
alm
1753ccb432
gh-138050: [WIP] JIT - Streamline MAKE_WARM - move coldness check to executor creation (GH-138240) 2025-10-27 16:37:37 +00:00
Stan Ulbrych
e03d8e4f50
gh-79922: Remove always false test skips in test_time (#136202) 2025-10-27 15:09:25 +00:00
Alper
9479a62a51
gh-116738: Use PyMutex for bz2 module (gh-140555)
The methods are already wrapped with a lock, which makes them thread-safe in
free-threaded build. This replaces `PyThread_acquire_lock` with `PyMutex` and
removes some macros and allocation handling code.

Also add a test for free-threading to ensure we aren't getting data races and
that the locking is working.
2025-10-27 09:52:30 -04:00
Itamar Oren
e8b5cb8f33
gh-140641: Break out of inittab search on match (GH-140642) 2025-10-27 15:18:58 +02:00
Victor Stinner
c636477523
gh-140487: Fix Py_RETURN_NOTIMPLEMENTED in limited C API 3.11 (GH-140636)
Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE have already been
fixed by commit 9258f3da91 (issue gh-134989).
2025-10-27 12:59:56 +01:00
Petr Viktorin
18e4a89e42
gh-134160: Add more comments for the xxlimited module (GH-140214) 2025-10-27 11:39:42 +01:00
RayXu
d12086e822
Docs: Replace "encoder" with "decoder" in Doc/c-api/codec.rst (#140613) 2025-10-27 10:43:24 +01:00
Petr Viktorin
3416e7c8dc
gh-140633: AppleFrameworkLoader: Ignore AttributeError when setting __file__ (GH-140635) 2025-10-27 10:09:22 +01:00
Shamil
7d70a147f5
Remove dead stores to 'size' in UTF-8 decoder (unicodeobject.c) (#140637) 2025-10-27 11:55:57 +03:00
da-woods
f5da369e20
Fix typo in TLS docs (#140640) 2025-10-27 10:28:30 +05:30
Brian Schubert
3dab11f888
gh-138944: Fix SyntaxError message for invalid syntax following valid import-as statement (#138945) 2025-10-26 22:35:21 +00:00
yihong
9d34623eb1
gh-140609: delete unused _stdlib_enums in enum.py (#140618)
Signed-off-by: yihong0618 <zouzou0208@gmail.com>
2025-10-26 18:37:31 +01:00
Bartosz Sławecki
06c779474c
gh-137568: Ignore startup file in test_dumb_terminal_exits_cleanly (GH-140295) 2025-10-26 10:48:03 -04:00
Sebastian Pipping
e34a5e3304
gh-140593: Fix a memory leak in function my_ElementDeclHandler of pyexpat (#140602)
Ensure that the memory allocated for the content model
passed to `my_ElementDeclHandler` is freed in all error
paths.
2025-10-26 13:45:32 +00:00
Bénédikt Tran
37827c1752
gh-133346: add tests for _colorize.Theme (#139687) 2025-10-26 12:07:31 +00:00
Bénédikt Tran
387ac2d2f3
gh-133346: make _colorize.Argparse kw-only constructible (#140620)
Other themes are kw-only constructible.
2025-10-26 11:33:57 +00:00
Stan Ulbrych
00026d19c2
gh-76007: Deprecate __version__ attribute in decimal (#140302)
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-10-26 12:01:04 +01:00
RayXu
33b2ca80bb
Docs: Fix a grammatical error in Doc/c-api/codec.rst (#140612) 2025-10-26 10:39:32 +01:00
Zachary Ware
421a475c87
gh-124694: Add versionadded note to InterpreterPoolExecutor (#140468) 2025-10-25 18:29:46 -05:00
RayXu
d74a96366d
Fix typo in Doc/c-api/code.rst (#140586) 2025-10-25 17:34:45 +02:00
Shamil
2a1c9bd616
Remove unreachable break statements in _ctypes_test.c (#140585) 2025-10-25 14:59:12 +00:00
Kumar Aditya
df07364106
gh-140544: use faster _PyInterpreterState_GET for type lock (#140584) 2025-10-25 14:53:26 +00:00
Kumar Aditya
ef4665f918
gh-140544: store pointer to interpreter state as a thread local for fast access (#140573) 2025-10-25 19:56:07 +05:30
RayXu
4ad599501f
Docs: Fix a grammatical error in Doc/c-api/capsule.rst (GH-140577)
"who" -> "which"
2025-10-25 09:54:52 -04:00
Mikhail Efimov
d78d7a50b0
Add missing NEWS entry for gh-140517 (GH-140560) 2025-10-24 22:53:00 +03:00
Tapeline
4f8e7b5ac5
gh-136327: Fix inconsistent `TypeError` messages regarding invalid values after * and ** (#136395) 2025-10-24 19:12:49 +00:00
Barry Warsaw
b3c713a0af
gh-140482: Preserve and restore stty echo as a test environment (#140519)
gh-140482: Restore `stty echo` as a test environment
2025-10-24 11:07:08 -07:00
Miša Jakovljević
44b6eead21
gh-140463: Fix typo in xmlrpc.client documentation (GH-140552)
Fix typo in xmlrpc.client documentation
2025-10-24 18:04:43 +02:00
Mikhail Efimov
be5af997f3
gh-140517: fix leak in map_next in strict mode (#140543) 2025-10-24 21:29:16 +05:30
Kumar Aditya
95e5d59630
gh-140414: add fastpath for current running loop in asyncio.all_tasks (#140542)
Optimize `asyncio.all_tasks()` for the common case where the event loop is running in the current thread by avoiding stop-the-world pauses and locking.

This optimization is already present for `asyncio.current_task()` so we do the same for `asyncio.all_tasks()`.
2025-10-24 20:02:17 +05:30
Kumar Aditya
ebf9938496
gh-140544: cleanup HAVE_THREAD_LOCAL checks in pystate.c (#140547) 2025-10-24 14:23:06 +00:00
Petr Viktorin
289360ae63
Document that PyModule_GetDef can return NULL with or without setting an exception (GH-140529) 2025-10-24 15:28:48 +02:00
RayXu
fc2e23c2ed
Docs: Fix a grammatical error in Doc/c-api/arg.rst (GH-140525)
"have" -> "has"
2025-10-24 08:17:52 -04:00
Jiseok CHOI
aa4b5a77f3
gh-136535: Tests: Correct Py_TPFLAGS_MANAGED_DICT in test_class.py (gh-136538) 2025-10-24 20:20:09 +09:00
sobolevn
92c0c45563
gh-138857: Improve error message for case outside of match (#138858)
* gh-138857: Improve error message for `case` outside of `match`

---------

Co-authored-by: Bartosz Sławecki <bartosz@ilikepython.com>
2025-10-24 11:20:54 +02:00
Tan Long
161b3064ef
gh-133390: sqlite3 CLI completion for tables, columns, indices, triggers, views, functions, schemata (GH-136101) 2025-10-24 08:26:36 +02:00
Victor Stinner
5d2edf72d2
gh-83714: Set os.statx().stx_mode to None if missing from stx_mask (#140484)
* Set stx_mode to None if STATX_TYPE|STATX_MODE is missing from
  stx_mask.
* Enhance os.statx() tests.
* statx_result structure: remove atime_sec, btime_sec, ctime_sec and
  mtime_sec members. Compute them on demand when stx_atime,
  stx_btime, stx_ctime and stx_mtime are read.
* Doc: fix statx members sorting.
2025-10-23 22:35:17 +02:00
Abhishek Tiwari
f0291c3f2d
gh-140443: Use fma in loghelper to improve accuracy of log for very large integers (#140469)
* gh-140443:use fma in loghelper to improve accuracy of log for very large integers

Use fused multiply-add in log_helper() for huge ints.

Saving a rounding here is remarkably effective. Across some millions
of randomized test cases with ints up to a billion bits, on Windows
and using log10, the ULP error distribution was dramatically
flattened, and its range was nearly cut in half. In fact, the largest
error Tim saw was under 0.6 ULP.

---------

Co-authored-by: abhi210 <27881020+Abhi210@users.noreply.github.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2025-10-23 12:05:12 -05:00
Mikhail Efimov
918a9ac9f4
gh-135125: Fix Py_STACKREF_DEBUG build (GH-139475)
* Use the same pattern of refcounting for stackrefs as in production build
2025-10-23 17:00:23 +01:00
Mark Shannon
61e759c2ee
GH-135904: JIT compiler: Support 19 bit branch instructions on AArch64 for Mach-O. (GH-140453)
* Insert labels into assembly for custom relocation during stencil creation.
2025-10-23 16:45:57 +01:00
Stan Ulbrych
95953b692d
gh-140471: Fix buffer overflow in AST node initialization with malformed _fields (#140506) 2025-10-23 15:35:21 +00:00
Bartosz Sławecki
1a3da2c070
gh-140438: properly run the asyncio REPL tests (#140298) 2025-10-23 20:53:23 +05:30
Sam Gross
574405c19e
gh-140431: Fix GC crash due to partially initialized coroutines (gh-140470)
The `make_gen()` function creates and tracks generator/coro objects, but
doesn't fully initialize all the fields. At a minimum, we need to
initialize all the fields that may be accessed by gen_traverse because
the call to `compute_cr_origin()` can trigger a GC.
2025-10-23 10:18:13 -04:00
George Ogden
4d0849426f
gh-138774: use value to ast.unparse code when str is None in ast.Interpolation (#139415) 2025-10-23 13:56:05 +00:00
Maurycy Pawłowski-Wieroński
6be6f8ff59
gh-137627: Make csv.Sniffer.sniff() delimiter detection 1.6x faster (#137628)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-10-23 15:28:29 +03:00
Stan Ulbrych
aa9d0a61d5
gh-140474: Fix memory leak in array.array (GH-140478) 2025-10-23 05:49:27 -04:00
Brett Cannon
bd2c7e8c8b
GH-140472: Create a WASI devcontainer configuration (GH-140473) 2025-10-22 16:11:48 -07:00
Brett Cannon
e5f4299f13
GH-140475: Support WASI SDK 25 (#140477)
As well, bump the version of Wasmtime used in CI.
2025-10-22 14:34:37 -07:00
Bartosz Sławecki
b3b0d75069
gh-140253: Improve the syntax error from an ill-positioned double-star subpattern (#140254) 2025-10-22 21:29:14 +03:00
Stefano Rivera
76fea5596c
gh-130317: Fix SNaN broken tests on HP PA RISC (#140452)
While looking at #140028, I found some unrelated test regressions in the
3.14 cycle. These seem to all come from #130317. From what I can tell,
that made Python more correct than it was before. According to [0], HP PA
RISC uses 1 for SNaN and thus a 0 for QNaN.

[0]: https://grouper.ieee.org/groups/1788/email/msg03272.html
2025-10-22 18:36:12 +02:00
Jakob
d2f3cfd384
gh-140448: Default suggest_on_error to True in argparse.ArgumentParser (#140450) 2025-10-22 16:15:26 +00:00
Alper
d51be28876
gh-116738: Add critical section to dbm/gdbm context manager (gh-140391) 2025-10-22 11:16:28 -04:00
Sergey Miryanov
a4709e525f
GH-139193: Fix dump_stack when PYTHON_LLTRACE=4 (GH-139384) 2025-10-22 14:14:25 +01:00
Petr Viktorin
e53e9eb2f1
gh-83714: Only use STATX_MNT_ID & STATX_SUBVOL if they're defined (GH-140446) 2025-10-22 12:42:51 +02:00
Victor Stinner
7339cf7899
gh-83714: Use "stx_" prefix for all os.statx_result members (#140432)
Rename stx_birthtime to stx_btime, and rename stx_birthtime_ns to
stx_btime_ns.
2025-10-22 11:48:37 +02:00
Alper
b3a38438d8
gh-116738: Make _suggestions module thread-safe (gh-140321) 2025-10-22 09:14:48 +09:00
Russell Keith-Magee
29b38b7aae
gh-55258: Skip tests of stdout status on mobile platforms (#140401)
Skip tests of stdout status on mobile platforms.
2025-10-22 07:12:26 +08:00
Emma Smith
a8edca62fc
gh-132835: Add defensive NULL checks to MRO resolution (GH-134763)
Currently, there are a few places where tp_mro could theoretically
become NULL, but do not in practice. This commit adds defensive checks for
NULL values to ensure that any changes do not introduce a crash and that
state invariants are upheld.

The assertions added in this commit are all instances where a NULL value would get passed to something not expecting a NULL, so it is better to catch an assertion failure than crash later on.

There are a few cases where it is OK for the return of lookup_tp_mro to be NULL, such as when passed to is_subtype_with_mro, which handles this explicitly.
2025-10-21 14:48:29 -07:00
Stan Ulbrych
02c1abfc54
gh-69528: Distinguish between file modes "wb+" and "rb+" (GH-137834)
Co-authored-by: Xiang Zhang <angwerzx@126.com>
2025-10-21 20:33:30 +03:00
Jeffrey Bosboom
60df1d7e0c
gh-83714: Check for struct statx members in configure (#140402)
Some systems have the definitions of the mask bits without having the
corresponding members in struct statx.  Add configure checks for members
added after Linux 4.11 (when statx itself was added).
2025-10-21 18:13:14 +02:00
Adam Turner
b4d2307367
Use `sphinxext-opengraph` v0.13.0 (GH-140425) 2025-10-21 16:02:43 +00:00
David Ellis
95c257e2e6
gh-138764: annotationlib: Make call_annotate_function fallback to using VALUE annotations if both the requested format and VALUE_WITH_FAKE_GLOBALS are not implemented (#138803) 2025-10-21 15:57:43 +00:00
Jeffrey Bosboom
c788bfb80e
gh-140239: Check for statx on Android (#140395)
Android has Linux's statx, but MACHDEP is "android" on Android, so
configure doesn't check for statx on Android.  Base the check for statx
on ac_sys_system instead, which is "Linux-android" on Android, "Linux"
on other Linux distributions, and "AIX" on AIX (which has an
incompatible function named statx).
2025-10-21 17:54:00 +02:00
Mark Shannon
0c01090ad9
GH-139951: Fix major GC performance regression (GH-140262)
* Count number of actually tracked objects, instead of trackable objects. This ensures that untracking tuples has the desired effect of reducing GC overhead

* Do not track most untrackable tuples during creation. This prevents large numbers of small tuples causing execessive GCs.
2025-10-21 15:22:15 +01:00
Adam Turner
4adf08ae46
GH-139436: Remove references to downloadable PDF documentation (#140416) 2025-10-21 13:37:06 +01:00
Peter Bierma
71db05a12d
gh-140406: Fix memory leak upon __hash__ returning a non-integer (GH-140411) 2025-10-21 08:10:01 -04:00
Victor Stinner
fe4b60208e
gh-83714: Fix os.statx() tests on tmpfs: st_birthtime can be None (#140407) 2025-10-21 10:24:49 +00:00
Cycloctane
5c41666ec4
gh-133951: Add venv changes to documentation and whatsnew (GH-139704) 2025-10-21 10:52:57 +02:00
Shamil
e8e0f411ba
gh-140398: fix memory leaks in readline module when PySys_Audit fails (#140400) 2025-10-21 13:24:34 +05:30
Stan Ulbrych
47d2f68df2
gh-139707: Better ModuleNotFoundError message for missing stdlib modules (GH-140219) 2025-10-21 09:12:04 +02:00
Pål Grønås Drange
b2f9fb9db2
gh-140358: Bring back elapsed time and unreachable count to gc debug output (#140359) 2025-10-21 00:54:44 +01:00
sobolevn
e09837fcbf
gh-133601: Remove deprecated typing.no_type_check_decorator (#133602) 2025-10-20 21:10:44 +00:00
Sam Bull
a752f58d6b
[Docs] Add missing note about Required/NotRequired/ReadOnly in get_type_hints() (#139565)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2025-10-20 20:09:33 +00:00
Christoph Walcher
c6be6e4537
gh-138891: fix star-unpack in get_annotations (#138951) 2025-10-20 19:55:08 +00:00
yihong
d467f24d0f
gh-133656: Remove unused import and private global in Lib/zipimport.py (GH-140325) 2025-10-20 19:43:10 +00:00
Serhiy Storchaka
38d4b436ca
gh-63161: Fix tokenize.detect_encoding() (GH-139446)
* Support non-UTF-8 shebang and comments if non-UTF-8 encoding is specified.
* Detect decoding error for non-UTF-8 encoding.
* Detect null bytes in source code.
2025-10-20 20:08:47 +03:00
Victor Stinner
3222ea0f14
gh-83714: Set os.statx() members to None if missing from stx_mask (#140216) 2025-10-20 17:59:12 +02:00
Ned Batchelder
237dca52ba
Docs: replace an esoteric Von Neumann mention (#137598)
* Docs: replace an esoteric Von Neumann mention

* oops, don't need to edit topics.py
2025-10-20 10:01:20 -04:00
Sam Gross
f11ec6e643
gh-140263: Fix data race in test_lock_two_threads (gh-140264)
Clang-20 detects a data race between the unlock and the non-atomic
read of the lock state. Use a relaxed load for the assertion to avoid
the race.
2025-10-20 09:58:05 -04:00
Charlie Lin
e4f6445f30
gh-140166: Use application/texinfo as sole MIME type for .texi and .texinfo files (#140165)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2025-10-20 16:14:23 +03:00
Hugo van Kemenade
99c3c63d2b
gh-76007: Deprecate __version__ attribute in imaplib (#140299)
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-10-20 15:20:44 +03:00
Furkan Onder
faa169afa0
gh-66646: Explain __base__ attribute in the docs (GH-102554)
Co-authored-by: Éric <merwok@netwok.org>
2025-10-20 14:15:30 +02:00
Mikhail Efimov
5d0abb6971
gh-139951: Test on GC collection disabled if threshold is zero (GH-140304) 2025-10-20 11:45:07 +01:00
Shamil
a615fb49c9
gh-140301: Fix memory leak in subinterpreter PyConfig cleanup (#140303)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-10-20 09:29:23 +00:00
mdehoon
baf45159e5
fix typo in comments PyOS_CallInputHook -> PyOS_InputHook (#140237) 2025-10-20 14:25:57 +05:30
Brandon Hubacher
7babe31443
Remove typo in `functools.lru_cache` docs (#140278) 2025-10-20 14:25:01 +05:30
Peter Holloway
3c2781dc5f
Fix typo in PyIter_Send docs (#140336) 2025-10-20 14:23:57 +05:30
Weilin Du
9c18f75e7c
gh-101100: Fix sphinx warnings in library/resource.rst (#140023) 2025-10-20 10:15:40 +03:00
Stan Ulbrych
091e8513bb
zlib.rst: Link to constants and deduplicate text (GH-140115)
* Link to compression setting constants from compression functions
* De-duplicate descriptions of the constants

Co-authored-by: Victor Stinner <vstinner@python.org>
2025-10-19 21:22:39 -07:00
Ned Batchelder
ed672f7a8a
docs: be clearer that glob results are unordered (#140184)
* docs: be clearer that glob results are unordered

* trim down the opening paragraph
2025-10-19 16:16:35 -04:00
Shamil
f9323213c9
gh-140306: Fix memory leaks in cross-interpreter data handling (GH-140307) 2025-10-19 22:24:28 +03:00
stratakis
bad8d6de37
gh-101525: [BOLT] Add GCC's LTO-generated function clones, with computed gotos, to BOLT skip list (gh-139840) 2025-10-19 23:23:49 +09:00
Stan Ulbrych
790cdae5a0
Lib/idlelib/idle_test/__init__.py: remove commented out duplicate code (#140259) 2025-10-19 00:16:13 -04:00
Marat Khagazheev
115a04b802
gh-138997: Remove false justify fill option from Tkinter docs (#139023)
Co-authored-by: marat <khagazheev@artlebedev.ru>
2025-10-18 23:45:52 -04:00
Shamil
bedaea0598
gh-139269: Fix unaligned memory access in JIT code patching functions (GH-139271)
* Use memcpy for patching values instead of direct assignment


Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-10-19 00:20:04 +01:00
Parham MohammadAlizadeh
920de7ccdc
gh-128571: Document UTF-16/32 native byte order (#139974)
Closes #128571

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2025-10-18 20:47:04 +02:00
Frost Ming
d86ad870cc
gh-140251: colorize import statement formatting in asyncio console (#140252) 2025-10-18 20:05:24 +05:30
Kumar Aditya
58c44c2bf2
gh-140067: Fix memory leak in sub-interpreter creation (#140111) (#140261)
Fix memory leak in sub-interpreter creation caused by overwriting of the previously used `_malloced` field. Now the pointer is stored in the first word of the memory block to avoid it being overwritten accidentally. 

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-10-18 16:36:58 +05:30
Shamil
c8729c9909
gh-140257: fix data race on eval_breaker during finalization (#140265) 2025-10-18 16:31:53 +05:30
Serhiy Storchaka
78e1d65a4d
gh-140241: Fix documentation for the registry parameter of warnings.warn_explicit() (GH-140242)
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2025-10-18 13:55:26 +03:00
Serhiy Storchaka
936de256a9
Move the NEWS entry for gh-140272 to the correct place (GH-140290) 2025-10-18 10:54:40 +00:00
Shamil
f937468e7c
gh-140272: Fix memory leak in _gdbm.gdbm.clear() (GH-140274) 2025-10-18 09:27:58 +00:00
Barney Gale
1bfe86caaa
GH-139174: Prepare pathlib.Path.info for new methods (part 2) (#140155)
Merge `_Info`, `_StatResultInfo` and `_DirEntryInfo` into a single `_Info`
class. No other changes.

This will allow us to use a cached `os.stat()` result from our upcoming
`_Info.stat()` method even when we have a backing `os.DirEntry`.
2025-10-18 02:13:25 +01:00
Barney Gale
f4e51f253a
GH-133789: Fix unpickling of pathlib objects pickled in Python 3.13 (#133831)
In Python 3.13 (but not 3.12 or 3.14), pathlib classes are defined in
`pathlib._local` rather than `pathlib`. In hindsight this was a mistake,
but it was difficult to predict how the abstract/local split would pan out.

In this patch we re-introduce `pathlib._local` as a stub module that
re-exports the classes from `pathlib`. This allows path objects pickled in
3.13 to be unpicked in 3.14+
2025-10-17 21:57:51 +00:00
Ayappan Perumal
92025ea2c8
gh-140239: Check statx availability only on Linux (#140249) 2025-10-17 19:40:16 +02:00
Serhiy Storchaka
fbf0843e39
gh-135801: Add tests for filtering warnings by module (GH-140240) 2025-10-17 14:21:39 +03:00
Tomasz Dądela
67c98ad8ef
gh-133059: Update documentation of preallocated integer range in long.rst (GH-140231) 2025-10-17 06:32:02 -04:00
Mark Shannon
f1883852ed
GH-135904: Implement assembler optimization for AArch64. (GH-139855) 2025-10-17 11:26:17 +01:00
Albert N
999ab8926b
gh-133059: Fix Tools/build/deepfreeze.py for new nsmallposints (#139906) 2025-10-17 11:48:53 +03:00
Stan Ulbrych
869bb6948e
Standardize translation of Doc/bugs.rst (GH-137449) 2025-10-17 08:55:12 +02:00
Alper
9a87ce8b57
gh-116738: test uuid module thread safety in free-threading (#140068) 2025-10-16 23:57:51 +05:30
Tan Long
2ebd0cdb16
Remove duplicate words in the documentation (#140221) 2025-10-16 18:27:00 +01:00
Maurycy Pawłowski-Wieroński
459d493ce3
gh-140149: Use PyBytesWriter in _build_concatenated_bytes() (#140150)
Use PyBytesWriter in action_helpers.c _build_concatenated_bytes().
3x faster bytes concat in the parser.

Co-authored-by: Victor Stinner <vstinner@python.org>
2025-10-16 19:24:34 +02:00
wangxiaolei
5f357f3b0d
gh-140078: fix typo in tkinter docs (#140081)
Remove extraneous word.
2025-10-16 11:02:38 -04:00
bzoracler
379fd020a0
gh-138859: Account for ParamSpec defaults that are not lists … (#138868) 2025-10-16 05:30:36 -07:00
Jeffrey Bosboom
5a31024da4
gh-83714: Check for struct statx.stx_atomic_write_unit_max_opt in configure (#140185)
stx_atomic_write_unit_max_opt was added in Linux 6.16, but is controlled
by the STATX_WRITE_ATOMIC mask bit added in Linux 6.11.  That's safe at
runtime because all kernels clear the reserved space in struct statx and
zero is a valid value for stx_atomic_write_unit_max_opt, and it avoids
allocating another mask bit, which are a limited resource.  But it also
means the kernel headers don't provide a way to check whether
stx_atomic_write_unit_max_opt exists, so add a configure check.
2025-10-16 13:40:47 +02:00
Petr Viktorin
ea4cc585cd
gh-139817: Fix refleak in TypeAliasType(qualname=non_string) (GH-140197) 2025-10-16 11:04:04 +00:00
Victor Stinner
4641925bf2
Set type names earlier in posixmodule.c (#140168) 2025-10-16 12:54:57 +02:00
Stan Ulbrych
7ac94fcb1d
gh-140170: Fix test_site with -s flag (GH-140179)
Commit
2025-10-16 12:49:08 +03:00
Serhiy Storchaka
2a2bc82cef
gh-130567: Remove optimistic allocation in locale.strxfrm() (GH-137143)
On modern systems, the result of wcsxfrm() is much larger the size of
the input string (from 4+2*n on Windows to 4+5*n on Linux for simple
ASCII strings), so optimistic allocation of the buffer of the same size
never works.

The exception is if the locale is "C" (or unset), but in that case the `wcsxfrm`
call should be fast (and calling `locale.strxfrm()` doesn't make too much
sense in the first place).
2025-10-16 09:54:41 +02:00
Jonathan Protzenko
3a81313019
gh-140120: Refresh HACL* to fix an hmac memory leak (GH-140188)
This pulls an updated version of HACL* that fixes the memory leak reported in #140120, via an upstream fix.
2025-10-16 05:25:51 +00:00
Malcolm Smith
7f371ed84b
gh-140041: Fix import of ctypes on Android and Cygwin when ABI flags are present (#140178)
Use sysconfig to determine the full name of libpython, rather than hardcoding
a library name that doesn't have ABI flags.
2025-10-16 05:40:39 +08:00
Alex Waygood
65d1a14d59
gh-139817: typing docs: Fix indentation of .. versionadded:: note for TypeAliasType.__qualname__ (#140177) 2025-10-15 20:18:39 +00:00
Bartosz Sławecki
bcced02604
gh-140141: Properly break exception chain in importlib.metadata.Distribution.from_name (#140142) 2025-10-15 12:49:14 -04:00
Mikhail Efimov
f673f0e7b4
gh-139817: Attribute __qualname__ is added to TypeAliasType (#139919) 2025-10-15 09:08:17 -07:00
Victor Stinner
5213f1b684
gh-83714: Disable os.statx_result.stx_atomic_write_unit_max_opt (#140162)
Fix building on Centos 9 x86-64 buildbot.
2025-10-15 17:38:34 +02:00
Stan Ulbrych
1624c646b0
gh-140065: Lexical analysis: Correct note about leading zeros in floating point numbers (GH-140066) 2025-10-15 15:15:45 +00:00
Victor Stinner
728d239e57
gh-140153: Fix Py_REFCNT() definition on limited C API 3.11-3.13 (#140158) 2025-10-15 16:36:49 +02:00
Maurycy Pawłowski-Wieroński
d301587369
gh-140135: Use PyBytesWriter in io.RawIOBase.readall(); 4x faster (#140139) 2025-10-15 14:04:17 +00:00
Pablo Galindo Salgado
0c66da8de4
gh-140137: Handle empty collections in profiling.sampling (#140154) 2025-10-15 14:59:12 +01:00
yihong
a05aece543
gh-140080: Clear atexit callbacks when memory allocation fails during finalization (GH-140103)
This fixes a regression introduced by GH-136004, in which finalization would hang while executing atexit handlers if the system was out of memory.

---------

Signed-off-by: yihong0618 <zouzou0208@gmail.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-10-15 09:49:55 -04:00
Sergey Miryanov
32c264982e
gh-140061: Use _PyObject_IsUniquelyReferenced() to check if objects are uniquely referenced (gh-140062)
The previous `Py_REFCNT(x) == 1` checks can have data races in the free
threaded build. `_PyObject_IsUniquelyReferenced(x)` is a more conservative
check that is safe in the free threaded build and is identical to
`Py_REFCNT(x) == 1` in the default GIL-enabled build.
2025-10-15 09:48:21 -04:00
Jeffrey Bosboom
fe9ac7fc8c
gh-83714: Implement os.statx() function (#139178)
Co-authored-by: Cody Maloney <cmaloney@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-10-15 13:44:08 +00:00
Bénédikt Tran
27acaf1cb7
gh-139327: consolidate sqlite3_finalize and sqlite3_reset usages (GH-139329) 2025-10-15 15:18:07 +02:00
Victor Stinner
4126d9f1ab
gh-129813: Enhance PyBytesWriter documentation (#140152)
Co-authored-by: Antoine Pitrou <pitrou@free.fr>
2025-10-15 14:54:18 +02:00
Stan Ulbrych
46f11b36ad
gh-76007: Deprecate zlib.__version__ attribute (#140130) 2025-10-15 13:18:48 +02:00
Cody Maloney
6416e6ebe5
gh-129559: Remove extra dot in bytearray.resize AC (#140134) 2025-10-15 02:39:17 +00:00
Peter Bierma
0bcb1c25f7
Revert "gh-140067: Fix memory leak in sub-interpreter creation (#140111)" (#140140)
This reverts commit 59547a251f.
2025-10-15 07:16:43 +05:30
Neil Schemenauer
1e1f435196
gh-140126: Fix compile error if --with-assertions is enabled (#140133)
The `types_world_is_stopped()` function needs to be defined if NDEBUG
is not defined.
2025-10-14 23:34:30 +00:00
Stan Ulbrych
2ca3c85054
Update documented minimum required zlib library version (#140116) 2025-10-15 00:16:00 +02:00
SarahPythonista
c50d794c7b
Improve the comment in URLError (#139874)
Clarify that it It overrides `__init__` and `__str__`.
2025-10-14 12:31:21 -07:00
Emma Smith
f262297d52
gh-139877: Use PyBytesWriter in pycore_blocks_output_buffer.h (#139976)
Previously, the _BlocksOutputBuffer code creates a list of bytes objects to handle the output data from compression libraries. This ends up being slow due to the output buffer code needing to copy each bytes element of the list into the final bytes object buffer at the end of compression.

The new PyBytesWriter API introduced in PEP 782 is an ergonomic and fast method of writing data into a buffer that will later turn into a bytes object. Benchmarks show that using the PyBytesWriter API is 10-30% faster for decompression across a variety of settings. The performance gains are greatest when the decompressor is very performant, such as for Zstandard (and likely zlib-ng). Otherwise the decompressor can bottleneck decompression and the gains are more modest, but still sizable (e.g. 10% faster for zlib)!

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-10-14 10:03:55 -07:00
Serhiy Storchaka
404425575c
Add mention of other fixed bug in the gh-139640 NEWS entry (GH-140122) 2025-10-14 18:56:19 +03:00
Maurycy Pawłowski-Wieroński
3490a99046
Correct a simple NULL-check in optimizer.c's uop_item() (GH-140069) 2025-10-14 16:18:20 +01:00
Serhiy Storchaka
279db6bede
gh-139640: Fix swallowing syntax warnings in different modules (GH-139755)
Revert GH-131993.

Fix swallowing some syntax warnings in different modules if they accidentally
have the same message and are emitted from the same line.
2025-10-14 17:48:09 +03:00
Hugo van Kemenade
1ff6d69fbe Merge branch 'main' of https://github.com/python/cpython 2025-10-14 17:45:22 +03:00
Shamil
59547a251f
gh-140067: Fix memory leak in sub-interpreter creation (#140111)
Fix memory leak in sub-interpreter creation caused by overwriting of the previously used `_malloced` field. Now the pointer is stored in the first word of the memory block to avoid it being overwritten accidentally. 

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-10-14 14:42:17 +00:00
Hugo van Kemenade
348a26ff0e Merge branch 'main' of https://github.com/python/cpython 2025-10-14 17:41:22 +03:00
Hugo van Kemenade
983c8db61e Post 3.15.0a1 2025-10-14 17:36:01 +03:00
Adorilson Bezerra
07e617ecc2
gh-106318: Add examples for str.istitle() (#140046) 2025-10-14 17:19:27 +03:00
Stan Ulbrych
87eadce3e0
gh-101828: Fix jisx0213 codecs removing null characters (gh-139340) 2025-10-14 22:55:00 +09:00
Sergey Miryanov
ded59f7e8e
GH-140058: Clear key and value if PyTuple_New fails in dictiter_iternextitem (#140059) 2025-10-14 18:15:39 +05:30
Sergey B Kirpichev
6ecf77dbde
gh-102431: Clarify constraints on operands of Decimal logical operations (GH-102836)
Sync C/Python implementation of the decimal: logical_ops for contexts.
2025-10-14 11:02:02 +00:00
Hugo van Kemenade
aeff92d86a Python 3.15.0a1 2025-10-14 13:46:08 +03:00
Hugo van Kemenade
f71c96cf2d
gh-133879: Copyedit "What's new in Python 3.15" (#140007) 2025-10-14 13:32:55 +03:00
Wulian233
5976432138
gh-137634: Modernize calendar.HTMLCalendar output (#137635) 2025-10-14 13:25:12 +03:00
Gil Forcada Codinachs
253534515c
gh-139958: Add TOML MIME type (#139959)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2025-10-14 13:20:14 +03:00
Sebastian Pipping
0c17473513
gh-90949: Recommend hasattr with Expat security methods (#139800) 2025-10-14 13:18:09 +03:00
Doug Hoskisson
13e9c2d18d
gh-114827: clarify threading.Event.wait timeout behavior (#114834)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-10-14 11:34:53 +03:00
Stan Ulbrych
e6102f0755
gh-82575: Adjust time.get_clock_info *adjustable* attribute doc (#135920) 2025-10-14 11:30:56 +03:00
Aziz
025b4034d6
gh-137871: Clarify cmath.nan documentation by linking to math module (#137876)
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
2025-10-14 11:24:43 +03:00
Irit Katriel
fb25d6b35c
gh-97914: Reword misleading sentence on conditional expressions (#139064)
Co-authored-by: Gilles Peiffer <gilles.peiffer.yt@gmail.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-10-14 11:21:13 +03:00
Morteza24
362fd59dc8
gh-138072: Fix typos and grammatical errors and improve clarity in asyncio howto document (#138895) 2025-10-14 11:19:35 +03:00
Loïc Simon
7caa591bb9
gh-102247: Improve documentation of http.HTTPStatus members update (#133190) 2025-10-14 11:18:17 +03:00
Stan Ulbrych
207f977bc7
gh-138993: Dedent credits text (#138994) 2025-10-14 11:15:17 +03:00
Weilin Du
6ca91834b8
gh-101100: Fix sphinx warnings in library/smtplib.rst (#139991)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-10-14 11:12:24 +03:00
Rafael Fontenelle
f70082b477
gh-70765: Remove unnecessary extra backtick from Changelog entry (#140071) 2025-10-14 11:05:59 +03:00
Ned Deily
8e0bf4fe5d
gh-115119: Update macOS installer to use libmpdecimal 4.0.1. (#140077) 2025-10-14 00:48:27 -04:00
Ned Deily
4e342ea642
gh-124111: Update macOS installer to use Tcl/Tk 9.0.2. (#140076) 2025-10-14 00:42:23 -04:00
Ned Deily
65a6d196a1
gh-132339: Update macOS installer version of OpenSSL to 3.5.4. (#140075) 2025-10-14 00:28:46 -04:00
Hugo van Kemenade
9c1279d5de
gh-124111: test macOS CI with Tk 9 (#137424)
Co-authored-by: Ned Deily <nad@python.org>
2025-10-14 00:00:58 -04:00
Mikhail Efimov
be60e4b4f3
gh-140000: Traverse name attribute for TypeVar, TypeVarTuple, TypeAliasType, ParamSpec (#140016) 2025-10-13 13:10:39 -07:00
Steve Dower
c46265d94a
gh-139810: Always generate -dev tags for PyManager packages (GH-139814) 2025-10-13 20:43:14 +01:00
Kumar Aditya
6481539a6d
gh-125996: fix thread safety of collections.OrderedDict (#133734) 2025-10-13 22:55:07 +05:30
Serhiy Storchaka
525dcfe523
gh-138772: Fix and improve documentation for turtle color functions (GH-139325)
Use multiple signatures for clarity.
Explain different forms of bgcolor() in details.
Fix outdated docstrings.
2025-10-13 18:32:16 +03:00
Hugo van Kemenade
88fc0a0fdc
Using Python on Windows: Free-threaded is supported from 3.14 (#139992) 2025-10-13 17:18:45 +03:00
Stan Ulbrych
1a82568568
gh-139823: Check if zlib is available in ensurepip (GH-139954) 2025-10-13 16:01:06 +02:00
Mikhail Efimov
52996aaa78
gh-107073: fix relevant typo in PyObject_ClearManagedDict (#140032) 2025-10-13 13:23:09 +02:00
mdehoon
a00655b877
gh-140001: Remove obsolete TCL_WIN_SOCKET macro (from Tcl 7.x) from _tkinter.c (GH-139998)
Co-authored-by: Michiel Jan Laurens de Hoon <mdehoon@Michiels-MacBook-Air.local>
2025-10-13 13:29:42 +03:00
Pieter Eendebak
e6aa515296
gh-140009: Improve performance of list_extend_dictitems by using PyTuple_FromArray (#140010) 2025-10-13 15:58:25 +05:30
Bartosz Sławecki
0344db8d60
gh-131189: Remove curses mention from PYTHON_BASIC_REPL docs (#140022)
The `curses` dependency for the default REPL has been removed
in 09dfb50f1b.
2025-10-13 10:40:39 +02:00
Arseniy Krupchik
bb85af343f
gh-136438: Make sure test.test_pydoc.test_pydoc pass with all optimization levels (#136479)
test_pydoc.test_pydoc now passes with -OO
2025-10-12 15:17:41 -07:00
Victor Stinner
5f91d5d9a4
gh-112075: Remove _PyObject_SetManagedDict() function (#139737)
Move it to the internal C API and no longer export it.
2025-10-12 19:32:10 +02:00
Savannah Ostrowski
0fc5c56815
GH-139979: Add @force_not_colorized_test_class to TestOptionalHelpVersionActions (#139980) 2025-10-12 09:51:13 -07:00
Bartosz Sławecki
68622be935
gh-139155: Remove "dictionaries are sorted by key" note in pprint docs (GH-139159) 2025-10-12 12:48:22 -04:00
Bénédikt Tran
6710156bd2
gh-139988: fix a leak when failing to create a Union type (#139990) 2025-10-12 12:51:44 +02:00
Alper
a18843dbfb
gh-116738: test dbm.gnu module on FT Python build (#138467) 2025-10-12 13:12:10 +05:30
sobolevn
d6dd64ac65
gh-138044: Fix importlib.resources.files deprecation docs (#139632) 2025-10-12 01:52:01 +03:00
Victor Stinner
35e9d41a9c
gh-139482: Add posix._clearenv() function (#139965) 2025-10-11 22:58:43 +02:00
Victor Stinner
166cdaa6fb
gh-111489: Remove _PyTuple_FromArray() alias (#139973)
Replace _PyTuple_FromArray() with PyTuple_FromArray().
Remove pycore_tuple.h includes.
2025-10-11 22:58:14 +02:00
Weilin Du
447c7a89fb
gh-101100: Fix Sphinx warnings in Doc/library/signal.rst (GH-139930) 2025-10-11 14:26:48 -04:00
Bénédikt Tran
cdd3eee7fc
gh-139929: fix incorrect OpenSSL version-based guard in _ssl.c (GH-139945)
fix OpenSSL version-based guards
2025-10-11 10:34:08 -07:00
Stan Ulbrych
5776d0d2e0
gh-139905: Provide suggestion in error message if Generic.__init_subclass__ was not called (#139943) 2025-10-11 15:14:29 +00:00
Bénédikt Tran
2eb32add92
gh-139935: do not skip test on real errors in os.getlogin (#139953) 2025-10-11 16:31:34 +02:00
yihong
897a36badd
gh-139935: fix test_os.test_getlogin on some platforms (#139936)
This amends 4e7e2dd043 to catch errors
that `os.getlogin` can raise as specified by POSIX and Linux/glibc [1].

[1]: https://man7.org/linux/man-pages/man3/getlogin.3.html#ERRORS

---------

Signed-off-by: yihong0618 <zouzou0208@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-10-11 12:32:57 +00:00
Stan Ulbrych
d4e5802588
gh-96491: Deduplicate version in IDLE shell title (#139841)
Saving to a file added both the filename and repeated the version.
---------

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2025-10-10 21:37:48 -04:00
Dino Viehland
ff7bb565d8
gh-139924: Add PyFunction_PYFUNC_EVENT_MODIFY_QUALNAME event for function watchers (#139925)
Add PyFunction_PYFUNC_EVENT_MODIFY_QUALNAME event for function watchers
2025-10-10 15:25:38 -07:00
Sam Gross
d9b4eef71e
gh-139001: Fix thread-safety issue in pathlib.Path (gh-139066)
Don't cache the joined path in `_raw_path` because the caching isn't thread safe.
2025-10-10 17:20:18 -04:00
Stan Ulbrych
aa840f500c
gh-138843: Removing "Unpacking" section from Download page (GH-139918) 2025-10-10 14:22:34 -05:00
Barney Gale
49aaee7978
pathlib ABCs: restore relative_to() and is_relative_to() (#138853)
Restore `JoinablePath.[is_]relative_to()`, which were deleted in
ef63cca494. These methods are too useful to
forgo. Restore old tests, and add new tests covering path classes with
non-overridden `__eq__()` and `__hash__()`.

Slightly simplify `PurePath.relative_to()` while we're in the area.

No change to public APIs, because the pathlib ABCs are still private.
2025-10-10 19:08:55 +01:00
Kumar Aditya
b881df47ff
gh-139894: fix incorrect sharing of current task while forking in asyncio (#139897)
Fix incorrect sharing of current task with the forked child process by clearing thread state's current task and current loop in `PyOS_AfterFork_Child`.
2025-10-10 21:58:23 +05:30
Stan Ulbrych
c7f1da97eb
gh-101100: Document zlib public constants to fix reference warnings (#139835)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-10-10 15:32:44 +00:00
Weilin Du
302f19d1f1
gh-139843: Document signals (SIGSTOP, SIGVTALRM, SIGPROF) to fix sphinx references (GH-139896) 2025-10-10 11:28:38 -04:00
Serhiy Storchaka
1c598e0436
gh-139065: Fix trailing space before long word in textwrap (GH-139070)
Fix trailing space before a wrapped long word if the line length with
a space is exactly "width".
2025-10-10 16:29:18 +03:00
Serhiy Storchaka
5c942f11cd
gh-63161: Fix PEP 263 support (GH-139481)
* Support non-UTF-8 shebang and comments if non-UTF-8 encoding is specified.
* Detect decoding error in comments for UTF-8 encoding.
* Include the decoding error position for default encoding in SyntaxError.
2025-10-10 12:51:19 +00:00
Victor Stinner
d0b18b19fa
gh-129813: Fix PyBytesWriter tests (#139892) 2025-10-10 13:01:06 +02:00
Victor Stinner
4c119714d5
gh-139353: Add Objects/unicode_format.c file (#139491)
* Move PyUnicode_Format() implementation from unicodeobject.c
  to unicode_format.c.
* Replace unicode_modifiable() with _PyUnicode_IsModifiable()
* Add empty lines to have two empty lines between functions.
2025-10-10 12:52:59 +02:00
Nadeshiko Manju
7cafd76a7f
gh-139184: Set O_CLOEXEC for master_fd when calling os.forkpty() (#139408)
Signed-off-by: Manjusaka <me@manjusaka.me>
Co-authored-by: Shamil <ashm.tech@proton.me>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-10-10 10:56:10 +02:00
Serhiy Storchaka
f4104f5d74
gh-139783: Fix inspect.getsourcelines() for the case when a decorator is followed by a comment or an empty line (GH-139836) 2025-10-10 10:51:24 +03:00
Victor Stinner
e31c22dbf9
gh-111489: Add PyTuple_FromArray() function (#139691) 2025-10-10 08:54:12 +02:00
Stan Ulbrych
8f14bddeae
gh-139823: Extend list of optional dependencies in configure.rst (#139826)
Co-authored-by: Emma Smith <emma@emmatyping.dev>
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-10-10 06:48:09 +00:00
Weilin Du
1f87d528a1
gh-139843: Document signal.SIGQUIT to fix Sphinx references (#139844) 2025-10-10 08:24:41 +02:00
Filipe Laíns
9e15770d62
GH-78870: copy test from GH-20439 (#139884)
Signed-off-by: Filipe Laíns <lains@riseup.net>
2025-10-10 05:52:13 +00:00
partev
33f32d6740
Replace obsolete platforms with more recent examples (#132455)
Co-authored-by: Filipe Laíns 🇵🇸 <lains@riseup.net>
2025-10-10 05:38:13 +00:00
Shahar Naveh
744ec1d6c3
gh-138614: site._get_path to respect non-default implementation name (#138610)
* `site._get_path` to respect non-default implementation name

* Add news entry

* Remove NEWS entry
2025-10-10 06:08:51 +01:00
adam j hartz
34503111fe
gh-137025: Update Emscripten Build Docs (#137312)
Update Emscripten build docs to point at the devguide as the primary reference
for managing an Emscripten build.
2025-10-10 06:36:40 +08:00
Timothée Mazzucotelli
f575dd9ef8
gh-139842: Clarify __module__ description in typing.rst (#139863) 2025-10-09 18:53:42 +01:00
Kirill Podoprigora
04461510fb
gh-139672: Remove references to passlib (#139673) 2025-10-09 20:13:38 +03:00
Savannah Ostrowski
9fc4366f09
GH-139809: Fix argparse subcommand prog not respecting color environment variables (#139818) 2025-10-09 16:53:14 +00:00
yihong
a310b3a99d
gh-139845: do not print twice in default asyncio REPL (#139846)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-10-09 15:24:52 +00:00
yihong
b8c8b8f1d3
gh-139391: properly handle signal.signal() in UnixConsole when called from a non-main thread (#139392) 2025-10-09 14:58:01 +00:00
DeepWzh
81959a0364
gh-133400: Fixed Ctrl+D (^D) behavior in :mod:_pyrepl module (GH-133883)
Co-authored-by: adam j hartz <adam@smatz.net>
2025-10-09 16:16:48 +02:00
Stan Ulbrych
d2deb8fdef
gh-101100: Fix reference warnings in c-api/init.rst documenting PyGILState_STATE (#139572) 2025-10-09 12:34:35 +03:00
Anuradha Agrawal
6fd1418341
gh-139742: Add support for Python 3.14 t-string prefixes in IDLE colorizer and tests (#139756)
Add 't' prefix to colorizer.py stringprefix regex to support Python 3.14 template strings.
Add t prefixes to test_colorizer.py source test text and adjust line numbers on test methods.
---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2025-10-09 05:24:53 -04:00
Bénédikt Tran
197c610a1e
gh-88046: remove impossible conditional import for _ssl.RAND_egd (#139648)
`_ssl.RAND_egd` was removed in b8d0fa035d.
2025-10-09 11:14:36 +02:00
Peter
65089406a5
gh-139743: Avoid import-time print in test_sqlite3 (GH-139746) 2025-10-09 11:00:37 +03:00
Alper
7f155f9c46
gh-116738: make mmap module thread-safe (#139237) 2025-10-09 12:00:47 +05:30
Stan Ulbrych
e7e3d1d4a8
gh-139805: Bump test_repl_eio timeout for slow builtbots (#139807) 2025-10-09 00:34:40 +02:00
sobolevn
678e0b818c
gh-139590: Stricter ruff rules for Tools/wasm (#139752) 2025-10-09 01:13:27 +03:00
Victor Stinner
a2850a3a91
gh-70030: Remove _PyCode_ConstantKey() function (#139735)
Move the function to the internal C API and no longer export it.
2025-10-08 22:33:45 +02:00
Jacob Coffee
6954077fde
Remove Cirrus macOS runners from CI (#139799)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-10-08 19:14:05 +00:00
Cody Maloney
fa60354245
gh-101100: Resolve some os sphinx reference warnings (#139636) 2025-10-08 23:53:27 +05:30
Stan Ulbrych
d9cb191df8
gh-138843: Clean up downloads page (#138844)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-10-08 19:14:09 +03:00
ed
72e370c910
gh-139736: Fix argparse indentation overshoot (#139738)
Co-authored-by: Savannah Ostrowski <savannahostrowski@gmail.com>
2025-10-08 15:36:53 +00:00
Stan Ulbrych
99fd525632
gh-101100: Fix all Sphinx warnings in Doc/library/subprocess.rst (#139576) 2025-10-08 18:26:22 +03:00
Bénédikt Tran
b04a57deef
gh-139748: fix leaks in AC error paths when using unicode FS-based converters (#139765) 2025-10-08 20:52:44 +05:30
Wulian233
570d17259f
gh-139769: Update PCBuild/find_python.bat to allow discovery of Python 3.14 (GH-139770)
Enable 3.14 py.exe can be use on PCBuild
2025-10-08 16:00:54 +01:00
Petr Viktorin
59a6f9d8c5
gh-135676: Add a summary of source characters (GH-138194)
Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Blaise Pabon <blaise@gmail.com>
Co-authored-by: Micha Albert <info@micha.zone>
Co-authored-by: KeithTheEE <kmurrayis@gmail.com>
2025-10-08 16:34:19 +02:00
Kumar Aditya
49fb46f555
gh-139774: use relaxed atomics for datetime hashes (#139775) 2025-10-08 19:49:54 +05:30
Cody Maloney
8b9606a2c5
gh-139452: Clarify redirect_stdout, stderr behavior (gh-139490) 2025-10-08 08:28:29 -05:00
Victor Stinner
3d3f126e86
gh-139353: Rename formatter_unicode.c to unicode_formatter.c (#139723)
* Move Python/formatter_unicode.c to Objects/unicode_formatter.c.
* Move Objects/stringlib/localeutil.h content into
  unicode_formatter.c. Remove localeutil.h.
* Move _PyUnicode_InsertThousandsGrouping() to unicode_formatter.c
  and mark the function as static.
* Rename unicode_fill() to _PyUnicode_Fill() and export it in
  pycore_unicodeobject.h.
* Move MAX_UNICODE to pycore_unicodeobject.h as _Py_MAX_UNICODE.
2025-10-08 14:56:00 +02:00
Rogdham
5cea843594
gh-137589: Zipfile tests: close file objects (GH-138080)
Zipfile tests: close file objects
2025-10-08 14:29:37 +02:00
Victor Stinner
c4e7d245d6
gh-138342: Move _PyObject_VisitType() to the internal C API (#139734) 2025-10-08 12:10:58 +02:00
Savannah Ostrowski
a15aeec29e
GH-139590: Run ruff format on pre-commit for Tools/wasm (#139591)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-10-08 02:25:06 +00:00
Zachary Ware
c53c55b6ed
Remove long-obsolete PCbuild/field3.py script (GH-139739)
As far as I can tell, it has not actually been used since 2003.
2025-10-08 00:29:43 +00:00
Victor Stinner
85ec35d2ab
gh-79315: Add Include/cpython/structseq.h header (#139730) 2025-10-08 01:19:50 +02:00
Victor Stinner
5a77f02d72
gh-79315: Remove Include/pylock.h and Include/monitoring.h (#139731)
Keep Include/cpython/pylock.h and Include/cpython/monitoring.h.
2025-10-08 00:49:24 +02:00
Victor Stinner
1cf22600f1
gh-79315: Add Include/cpython/sliceobject.h header (#139729) 2025-10-08 00:48:18 +02:00
Victor Stinner
f962e1eacf
gh-79315: Add Include/cpython/marshal.h header (#139725) 2025-10-07 23:49:08 +02:00
Cornelius Roemer
25edfa7cf1
Doc: Improve clarity for subinterpreters in What's New in 3.14 (#139221)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-10-07 18:53:27 +00:00
Stan Ulbrych
d396a32b3d
gh-139698: Fix typo in What's New 3.14 (#139699) 2025-10-07 23:09:45 +05:30
Serhiy Storchaka
162997bb70
gh-139700: Check consistency of the zip64 end of central directory record (GH-139702)
Support records with "zip64 extensible data" if there are no bytes
prepended to the ZIP file.
2025-10-07 20:15:26 +03:00
Tomasz Pytel
539461d9ec
gh-139516: Fix lambda colon start format spec in f-string in tokenizer (#139657) 2025-10-07 17:28:15 +01:00
danigm
96c59a6e42
gh-138497: Support LLVM_VERSION configuration via env (#138498)
Co-authored-by: Savannah Ostrowski <savannah@python.org>
2025-10-07 07:54:31 -07:00
Mark Shannon
7094f09f54
GH-139291: Fix C stack limits by factoring out finding hardware stack limits (GH-139294) 2025-10-07 15:04:37 +02:00
Adam Turner
0e2cdd313b
gh-139436: Remove `dist-pdf` from the docs archives rebuild target (#139437) 2025-10-07 13:29:18 +01:00
Adam Turner
134ff810cf
GH-123299: Announce final release in What's New in Python 3.14 (#139631)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-10-07 08:49:59 +00:00
Ned Deily
6d804e4efb
gh-124111: Update macOS installer to use Tcl/Tk 8.6.17. (#139682) 2025-10-07 00:53:05 -04:00
Zachary Ware
23410f0a9e
gh-139573: Update macOS installer to use OpenSSL 3.0.18 (#139575) 2025-10-06 22:17:09 -04:00
Alyssa Coghlan
331158065b
Add warnings filter suggestions to PEP 765 entry in What's New (#139658)
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-10-06 20:41:08 +01:00
Furkan Onder
171f787a29
gh-138854: Skip test_script_shadowing_stdlib_cwd_failure on AIX (GH-138855) 2025-10-06 17:42:26 +00:00
sobolevn
7c70cc5c23
gh-133210: Fix test_inspect without docstrings (#139651) 2025-10-06 19:48:50 +03:00
Sebastian Pipping
55a44ccf5e
gh-139400: Move NEWS item from section "Core and Builtins" to section "Security" (GH-139606) (#139664) 2025-10-06 16:55:58 +02:00
Mikhail Efimov
708de26e31
gh-133210: Fix test_pydoc without docstrings (#139654) 2025-10-06 16:51:10 +02:00
Cycloctane
69cfad0b3e
gh-116488: Mention dict.get in the data structures tutorial (GH-139643) 2025-10-06 09:04:59 -04:00
Cycloctane
b73aaffb3d
gh-133951: Fix purelib packages not found in test_peg_generator TestCParser (GH-139607)
also includes purelib in TestCParser import context
2025-10-06 14:40:48 +02:00
yihong
36a6c2cdfa
gh-139646: fix typo in pickletools error message (#139647)
Signed-off-by: yihong0618 <zouzou0208@gmail.com>
2025-10-06 10:52:45 +00:00
Furkan Onder
6f3dae0dc5
gh-139624: Skip problematic locales on AIX in test_date_locale2 (GH-139625) 2025-10-06 11:38:01 +02:00
Malcolm Smith
a9b0506d8d
gh-137242: Allow Android testbed to take all Python command-line options (#138805)
Modifies the Android test runner to ensure that all valid Python command line
options are preserved when running the test suite.
2025-10-06 13:19:48 +08:00
Adam Turner
3195da0b1a
gh-105812: Use the `:deco:` role in place of manual decorator markup (#139619) 2025-10-05 21:15:36 +01:00
Adam Turner
46de475af7
GH-123299: Copyedit 3.14 What's New: Trivia (#139618) 2025-10-05 22:45:58 +03:00
Skip Montanaro
d1ca001d35
gh-127330: Comment correction in _ssl.c (#139603) 2025-10-05 19:15:46 +01:00
George Ogden
dadbb2662a
Replace ambiguous word "pound" by "hash" in difflib docs (#139601) 2025-10-05 17:10:24 +00:00
Adam Turner
5389234fca
GH-123299: Copyedit 3.14 What's New: New Features (#139543)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-10-05 20:05:29 +03:00
Bénédikt Tran
1fe89d324e
gh-70765: fix an HTTP/0.9 flaky test post GH-139514 (#139610)
Fix a flaky test introduced in 13dc2fde8c.

After a single HTTP/0.9 request, both client and server are expected to
close the connection on their side. In particular, if a client sends two
requests with the same connection, only the first one should be handled.

In the tests, it might happen that checking for the second request to be
ignored did not take into account that the server may have already closed
the connection. This flaky behavior was first observed on macOS CI workers
but could not be reproduced locally on a Linux machine.
2025-10-05 16:51:16 +00:00
Sebastian Pipping
6edb2ddb5f
gh-139400: Make sure that parent parsers outlive their subparsers in pyexpat (#139403)
* Modules/pyexpat.c: Disallow collection of in-use parent parsers.

Within libexpat, a parser created via `XML_ExternalEntityParserCreate`
is relying on its parent parser throughout its entire lifetime.
Prior to this fix, is was possible for the parent parser to be
garbage-collected too early.
2025-10-05 17:37:42 +02:00
Bénédikt Tran
13dc2fde8c
gh-70765: avoid waiting for HTTP headers when parsing HTTP/0.9 requests (#139514) 2025-10-05 12:03:25 +00:00
Jost Migenda
29616f3d2c
gh-118767: Remove `bool(NotImplemented)` from pending-removal document (#139526) 2025-10-05 14:03:54 +03:00
Victor Stinner
efd223da0c
gh-64327: Remove skipped pydoc tests (#139512)
Tests skipped since 2014:
since commit a46ef70bdf.
2025-10-05 12:49:03 +02:00
Bénédikt Tran
41712c4e09
gh-139310: skip test_aead_aes_gcm for Linux kernel between 6.16.0 and 6.17.x (#139552)
Currently, Fedora 42 uses a custom Linux Kernel 6.16.9 that backported an upstream change
from 6.17-rc7 [1,3] but not its subsequent fix [2]. Until the issue is resolved upstream,
we skip the failing test `test_socket.test_aead_aes_gcm` for kernel versions between 6.16
and 6.17.x.

[1] 1b34cbbf4f
[2] d0ca0df179.
[3] 45bcf60fe4
2025-10-05 10:27:16 +02:00
Russell Keith-Magee
20758f9bb1
gh-139573: Update OpenSSL version used in iOS builds (#139582)
Update OpenSSL version used in iOS builds.
2025-10-05 08:03:41 +03:00
Savannah Ostrowski
9964320d15
GH-137218: Fix unnecessary recompile of Programs/_freeze_module (#139241) 2025-10-04 20:05:37 -07:00
Zachary Ware
063cef9999
gh-139573: Update Windows builds to use OpenSSL 3.0.18 (GH-139574) 2025-10-04 19:56:59 -05:00
Zachary Ware
98e748b3a0
gh-139573: Update OpenSSL in CI (GH-139577) 2025-10-04 19:43:17 -05:00
Malcolm Smith
0f0fc5a163
gh-139573: Update Android to OpenSSL 3.0.18 (#139562)
Update Android to OpenSSL 3.0.18.
2025-10-05 08:15:29 +08:00
Dave Peck
880c9526f9
gh-138558: Improve description of `Interpolation.expression` (#139187)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-10-04 22:06:56 +01:00
Kumar Aditya
0b2168275e
gh-138703: clarify data buffer requirement of asyncio.StreamWriter.write (#139564) 2025-10-04 21:44:05 +05:30
rowanbudge
04a2f80a60
gh-101100: Fix some Sphinx reference warnings in `whatsnew/2.6.rst` (#139236)
Co-authored-by: rowanvil <rowan@anvil.works>
Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
2025-10-04 15:59:39 +00:00
Filipe Laíns 🇵🇸
f191db2e0e
Add FFY00 to CODEOWNERS for generate-build-details (#139561)
Signed-off-by: Filipe Laíns <lains@riseup.net>
2025-10-04 15:25:07 +01:00
Sebastian Pipping
fc48a3c9ca
gh-90949: Fix an "unused function" compiler warning introduced in GH-139234 (#139558)
Fix a compiler warning `-Wunused-function` after f04bea44c3.

The `set_invalid_arg` function in `Modules/pyexpat.c` may be unused if the underlying Expat
version is less than 2.4.0.
2025-10-04 14:19:06 +00:00
Serhiy Storchaka
9e3542a6c2
gh-136097: Fix sysconfig._parse_makefile() (#136166)
* Fix potential infinite recursion.
* Fix a bug when reference can cross boundaries of substitutions, e.g.
  a=$(
  b=$(a)a)
* Fix potential quadratic complexity.
* Fix KeyError for undefined CFLAGS, LDFLAGS, or CPPFLAGS.
* Fix infinite recursion when keep_unresolved=False.
* Unify behavior with keep_unresolved=False for bogus $ occurred before
  and after variable references.
2025-10-04 14:57:12 +01:00
Furkan Onder
ae6e7f572c
gh-139308: Skip test_special_chars_csh on NetBSD due to csh variable expansion issue (#139341)
Skip test_special_chars_csh on NetBSD due to csh variable expansion issue

Co-authored-by: Filipe Laíns 🇵🇸 <lains@riseup.net>
2025-10-04 13:56:43 +00:00
Cycloctane
a7a485558c
gh-133951: Remove lib64->lib symlink in venv creation (#137139)
* Remove lib64->lib symlink in venv directory

* fix test

* remove unused import

* add news
2025-10-04 14:55:17 +01:00
Semyon Moroz
8d17d79299
gh-138044: Remove deprecated parameter alias for importlib.resources.files (#138059) 2025-10-04 14:53:43 +01:00
Ho Kim
db53ca30d7
gh-138489: Add missing build-details.json step for building wasm (#139302)
* fix: add missing `build-details.json` step for building wasm

Signed-off-by: Ho Kim <ho.kim@ulagbulag.io>

* gh-138489: Add missing build-details.json step for building wasm

Signed-off-by: Ho Kim <ho.kim@ulagbulag.io>

* Update Makefile.pre.in

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>

---------

Signed-off-by: Ho Kim <ho.kim@ulagbulag.io>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-10-04 14:26:20 +01:00
Adam Turner
c33dc154b4
GH-123299: Copyedit 3.14 What's New: New and Improved Modules (#139530) 2025-10-04 15:58:51 +03:00
Stan Ulbrych
37d16f7f62
Replace workflow with project automations (#136831)
Remove unnecessary workflow
2025-10-04 07:09:37 +02:00
sobolevn
18d4e2ecd4
gh-133210: Fix test_types with --without-doc-strings (#139548) 2025-10-03 21:52:45 +00:00
Jacob Coffee
1ae9250364
gh-137638: Use macos-15-intel in GitHub Actions (#139154)
Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) <wk.cvs.github@sydorenko.org.ua>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-10-03 19:49:03 +00:00
Dino Viehland
ff0cf0af10
gh-139525: Don't specialize functions which have a modified vectorcall (#139524)
Don't specialize functions which have a modified vectorcall
2025-10-03 09:58:32 -07:00
Stan Ulbrych
12805ef9da
Python/codecs.c: Remove unused forward declaration (#139511) 2025-10-03 13:33:49 +02:00
Sergey Miryanov
e6e376a760
gh-132042: Remove resolve_slotdups() to speedup class creation (#132156)
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: sobolevn <mail@sobolevn.me>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-10-03 11:58:00 +02:00
Kumar Aditya
aa99a7c70c
gh-105987: unskip test_issue105987 from test_asyncio.test_eager_task_factory (#139538) 2025-10-03 07:18:57 +00:00
Angela Liss
fd7dac0430
gh-137840: Implement PEP 728 (closed and extra_items in typing.TypedDict) (#137933)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2025-10-02 22:50:19 -07:00
Victor Stinner
4e7e2dd043
gh-139322: Reenable test_os.test_getlogin() (#139498)
Fix also getlogin() errno.
2025-10-02 20:51:57 +00:00
Alex Willmer
fb114cf497
gh-139495: Fix hashlib.file_digest() versionchanged description of BlockingIOError (GH-139496)
* Fix `hashlib.file_digest()` versionchanged description of `BlockingIOError`

The sentence was missing a negation and contradicted the other two
descriptions in the same commit. I believe code behaviour is correct.

* fixup! Fix `hashlib.file_digest()` versionchanged description of `BlockingIOError`

* Remove unncessary NEWS.d entry
2025-10-02 12:50:36 -07:00
Victor Stinner
af01b46866
gh-139322: Remove redundant test_os.Win32ErrorTests (#139477)
test_os.OSErrorTests already covers the OSError class and is more
complete than Win32ErrorTests.
2025-10-02 20:46:25 +02:00
Victor Stinner
9bf69659e1
gh-55258: Reenable support test_get_original_stdout() (#139499) 2025-10-02 18:10:36 +02:00
Victor Stinner
ea4027e179
gh-139504: Catch BrokenPipeError in ssl test_client_sigalgs_mismatch() (#139505)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-10-02 18:08:29 +02:00
Victor Stinner
16da633dfe
Remove @tiran from CODEOWNERS (#139513)
Christian Heimes is now inactive for 2 years.
2025-10-02 18:05:37 +02:00
Victor Stinner
8797e1a8c3
gh-77476: Remove urllib HTTP test (#139502)
Remove test_sites_no_connection_close() which is skipped since 2018
(commit 36d56ea826).
2025-10-02 17:30:08 +02:00
Eric Snow
46a1f0a9ff
gh-135944: Add a "Runtime Components" Section to the Execution Model Docs (gh-135945)
The section provides a brief overview of the Python runtime's execution environment.  It is meant to be implementation agnostic,
2025-10-02 09:13:22 -06:00
Victor Stinner
6826ebf986
gh-89745: Remove test_embed.test_init_read_set() (#139500)
Since Python 3.11, it's no longer possible to call PyConfig_Read() to
get the path configuration, and then modify the path configuration.
2025-10-02 16:52:10 +02:00
Adam Turner
60655cd6fa
GH-123299: Copyedit 3.14 What's New: Other Language Changes (#139425) 2025-10-02 15:51:48 +01:00
Victor Stinner
c985822d86
gh-135329: Use longer timeout in pyrepl test_repl_eio() (#139503)
Replace hardcoded 5 seconds with support.SHORT_TIMEOUT.

Fix the following error on slow CI such as GitHub Action UBSan:

test test_pyrepl failed -- Traceback (most recent call last):
  File "Lib/test/test_pyrepl/test_unix_console.py", line 362, in test_repl_eio
    _, err = proc.communicate(timeout=5)  # sleep for pty to settle
             ~~~~~~~~~~~~~~~~^^^^^^^^^^^
  File "Lib/subprocess.py", line 1219, in communicate
    stdout, stderr = self._communicate(input, endtime, timeout)
                     ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
  File "Lib/subprocess.py", line 2126, in _communicate
    self._check_timeout(endtime, orig_timeout, stdout, stderr)
    ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "Lib/subprocess.py", line 1266, in _check_timeout
    raise TimeoutExpired(
    ...<2 lines>...
            stderr=b''.join(stderr_seq) if stderr_seq else None)
subprocess.TimeoutExpired: Command '[...]' timed out after 5 seconds
2025-10-02 16:44:02 +02:00
Peter
f3d7faeafa
gh-139487: add missing imports for standalone doctest Enum examples (#139488) 2025-10-02 12:28:29 +02:00
ivonastojanovic
75b1afe562
gh-135953: Add Gecko reporter to sampling profiler (#139364)
Signed-off-by: Pablo Galindo Salgado <pablogsal@gmail.com>
Co-authored-by: Pablo Galindo Salgado <pablogsal@gmail.com>
2025-10-01 21:18:54 +01:00
Kumar Aditya
76b07c035c
gh-116946: partial revert gh-139073 for thread handle type (#139474) 2025-10-01 17:49:31 +00:00
Victor Stinner
0158890005
gh-139322: Create test_os package (#139453)
* Move test_posix.py and test_os.py to Lib/test/test_os/.
* Split Windows specific test cases to a new test_windows.py file.
2025-10-01 16:42:45 +02:00
Nadeshiko Manju
f39dea3bae
gh-123828: Fix data race in _interpchannels._waiting_release (GH-124107) 2025-10-01 11:34:47 +00:00
Bénédikt Tran
d0a3eff9d6
gh-139327: fix some reference leaks in sqlite3 error branches (#139328) 2025-10-01 11:10:12 +02:00
Ken Jin
d936dbeb1f
gh-139210: Move gh-139210 patch NEWS file to correct section (#139469)
Move gh-139210 patch NEWS file to correct section
2025-10-01 09:48:37 +01:00
Sergey Miryanov
1588413ca7
gh-116946: remove unnecessary gc from immutable types (#139073) 2025-10-01 13:15:58 +05:30
Cody Maloney
ce23eeaa2b
gh-138013: Split BufferedIO tests from test_io.test_general (#139454)
The last remaining set of tests to split out that are focused on one
specific implementation portion (`bufferedio.c`).

test_io.test_general is now largely tests around `io.open` and module
properties (ex. pickling, class hierarchy, module members, etc).

This closes #138013.
2025-10-01 09:06:26 +02:00
Victor Stinner
536787591a
Fix typo in tracemalloc.c (#139450) 2025-10-01 08:58:18 +02:00
yihong
22f7ccfad6
gh-138899: fix sys.ps1 in asyncio repl (#138900) 2025-10-01 11:19:49 +05:30
Hugo van Kemenade
800d856bc7
gh-92266: Update pre-commit (#139411) 2025-10-01 08:40:54 +03:00
Petr Viktorin
80cdf3ef74
Document that PyInterpreterState_GetDict returns a borrowed reference (#139451) 2025-10-01 09:46:06 +05:30
Adam Turner
98a41af5b0
GH-123299: Copyedit 3.14 What's New: Deprecated (#139433) 2025-09-30 18:18:13 +00:00
Ken Jin
c86eb4d3ac
gh-139210: Fix use-after-free in xml.etree.ElementTree.iterparse() (GH-139211) 2025-09-30 20:50:50 +03:00
Cody Maloney
f752fde452
gh-138013: Split TextIO tests from test_io.test_general (#139173)
gh-138013: Split TextIO tests from test_general

These tests take 1.3 seconds on my dev machine, match fairly closely
with testing `textio.c` implementation only.
2025-09-30 17:37:15 +02:00
Petr Viktorin
01157e0cdf
gh-139116: tracemalloc: Detach thread state when acquiring tables_lock (GH-139449)
* gh-139116: tracemalloc: Detach thread state when acquiring tables_lock

This prevents a deadlock when:

- One thread is in `_PyTraceMalloc_Stop`, with `TABLES_LOCK` held, calling
  `PyRefTracer_SetTracer` which wants to stop the world
- Another is thread in `PyTraceMalloc_Track`, just attached thread state, waiting
  for `TABLES_LOCK`

Detaching the thread state while waiting for `TABLES_LOCK` allows
`PyRefTracer_SetTracer` to stop the world.


Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-09-30 16:43:49 +02:00
Serhiy Storchaka
b2f5ad0c6d
gh-63161: Add more tests for source encoding (#139440) 2025-09-30 12:20:17 +03:00
Bénédikt Tran
bc172ee830
gh-139283: correctly handle size limit in cursor.fetchmany() (#139296)
Passing a negative or zero size to `cursor.fetchmany()` made it fetch all rows
instead of none.

While this could be considered a security vulnerability, it was decided to treat
this issue as a regular bug as passing a non-sanitized *size* value in the first
place is not recommended.
2025-09-30 11:18:55 +02:00
AN Long
bd1ada6df3
gh-138092: Allow calling mmap.flush with offset only (#138093) 2025-09-30 11:08:50 +02:00
Adam Turner
6b5f15698a
Remove link to the PDF downloads (#139142) 2025-09-29 18:59:25 +01:00
Serhiy Storchaka
1b8dcdacc7
gh-130567: Enable previously skipped locale tests on FreeBSD and macOS (GH-138652) 2025-09-29 17:32:38 +02:00
Adam Turner
8bfdda21a3
GH-123299: Copyedit 3.14 What's New: CPython bytecode changes (#139402)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-09-29 15:11:54 +00:00
Denis Sergeev
9c6a1f847b
gh-139146: Check calloc() results in _testembed.c::test_pre_initialization_sys_options (#139147)
Reported by: Dmitrii Chuprov <cheese@altlinux.org>
Signed-off-by: Denis Sergeev <zeff@altlinux.org>
2025-09-29 10:40:36 +00:00
Hugo van Kemenade
872eafd2b0
gh-76007: Deprecate __version__ attribute (#138675)
Co-authored-by: AN Long <aisk@users.noreply.github.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2025-09-29 12:03:23 +03:00
Gordon Messmer
408154d64a
gh-78319: Fix implementation of IMAP APPEND UTF8 (GH-9436)
Make UTF8 support for the IMAP APPEND command RFC 6855 compliant.
2025-09-29 09:03:06 +03:00
Jeff Epler
d3e3b2b0ac
Edit outdated comment (#121152)
A comment about a possible relaxation of how bytes URLs are treated
in Python 3.3 is no longer relevant or useful.
2025-09-28 14:55:44 -07:00
Russell Keith-Magee
195d13c85e
gh-132006: Add support for handling XCPrivacy manifests (#139163)
Adds a PrivacyInfo.xcprivacy file when packaging `_hashlib` and `_ssl` modules
for iOS (based on the original OpenSSL sources); and adds handling to the build
script to allow any app to add `xcprivacy` handling for a binary module.
2025-09-29 05:50:46 +08:00
Bénédikt Tran
3779f2b95e
gh-139393: fix _CALL_LEN JIT tests for tuples (#139394)
Fix a regression introduced in 7ce25edb8f
where `_PY_NSMALLPOSINTS` was changed from 257 to 1025.
2025-09-28 19:30:44 +02:00
Yongzi Li
519bc470fc
gh-135447: Document the `NOT_TAKEN & POP_ITER` bytecode instructions (#135803)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Ken Jin <kenjin4096@gmail.com>
2025-09-28 16:46:01 +00:00
yihong
e18dda96c9
gh-139374: colorize traceback when using timeit command-line interface (#139375)
---------

Signed-off-by: yihong0618 <zouzou0208@gmail.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-09-28 11:49:18 +00:00
Bénédikt Tran
666112376d
gh-90949: expose Expat API to tune exponential expansion protections (#139368)
Expose the XML Expat 2.7.2 APIs to tune protections against
"billion laughs" [1] attacks.

The exposed APIs are available on Expat parsers, that is,
parsers created by `xml.parsers.expat.ParserCreate()`, as:

- `parser.SetBillionLaughsAttackProtectionActivationThreshold(threshold)`, and
- `parser.SetBillionLaughsAttackProtectionMaximumAmplification(max_factor)`.

This completes the work in f04bea44c3,
and improves the existing related documentation.

[1]: https://en.wikipedia.org/wiki/Billion_laughs_attack
2025-09-28 08:27:04 +00:00
Stan Ulbrych
48d0d0dd97
gh-139312: Update bundled libexpat to 2.7.3 (GH-139319)
+ Blurb
+ Update sbom.spdx.json
2025-09-26 19:44:36 -07:00
Jacob Bower
93ac3525b9
gh-139276: Remove generator type check in _testcapimodule.c:raise_SIGINT_then_send_None (#139252)
* Remove generator type check in raise_SIGINT_then_send_None

In the Cinder JIT we use a different type for generators, which breaks
the test which uses this function.

In general I believe the intent with generators is they have the right
structure rather than type, so a failure to find the 'send()' method is arguably
more correct if the wrong object is used.

* Also stop using PyGenObject type
2025-09-26 11:52:10 -07:00
Bénédikt Tran
68a1778b77
gh-90949: amend GH-139234 in prevision of future mitigation API (#139366)
Fix some typos left in f04bea44c3,
and simplify some internal functions to ease maintenance of future
mitigation APIs.
2025-09-26 17:59:40 +00:00
Tian Gao
8288f3693f
gh-139289: Lazy import rlcompleter to fix the refleak (#139305) 2025-09-26 22:17:02 +08:00
Bénédikt Tran
f04bea44c3
gh-90949: add Expat API to prevent XML deadly allocations (CVE-2025-59375) (#139234)
Expose the XML Expat 2.7.2 mitigation APIs to disallow use of
disproportional amounts of dynamic memory from within an Expat
parser (see CVE-2025-59375 for instance).

The exposed APIs are available on Expat parsers, that is,
parsers created by `xml.parsers.expat.ParserCreate()`, as:

- `parser.SetAllocTrackerActivationThreshold(threshold)`, and
- `parser.SetAllocTrackerMaximumAmplification(max_factor)`.
2025-09-26 14:13:56 +00:00
sobolevn
0aab07ccf7
gh-115119: Defer --with-system-libmpdec removal to 3.16 (#139318) 2025-09-26 14:21:38 +03:00
Sebastian Pipping
6fa1e552e0
gh-127502: Fix typo in XML security notes (#139335) 2025-09-26 11:59:08 +02:00
Raymond Hettinger
7909b30493
gh-138682: Add symmetric difference to Counter (gh-138766) 2025-09-26 00:04:49 -05:00
Seth Michael Larson
89b5571025
gh-139330: Check expat version/checksum in SBOM with refresh.sh
Check expat version/checksum in SBOM with refresh.sh
2025-09-25 17:13:45 +00:00
Pablo Galindo Salgado
bc7b511376
gh-138122: Allow to filter by thread in tachyon's flamegraph (#139216) 2025-09-25 15:34:57 +01:00
Jan-Eric Nitschke
2462807b70
gh-138772: Add tests for Turtle.dot() signature (GH-138773) 2025-09-25 16:46:12 +03:00
Victor Stinner
e9c538dd54
gh-139156: Optimize _PyUnicode_EncodeCharmap() (#139306)
Specialize _PyUnicode_EncodeCharmap() for EncodingMapType which is
used by Python codecs such as iso8859_15.
2025-09-25 11:42:16 +02:00
Pablo Galindo Salgado
1963e70100
gh-139275: Fix compilation of Modules/_remote_debugging_module.c when the system doesn't have process_vm_readv (#139307) 2025-09-25 00:16:44 +01:00
dgpb
7ce25edb8f
gh-133059: Increase the small positive integer cache to 1024 (GH-133160) 2025-09-24 17:05:30 -04:00
yihong
e45d535208
gh-139292: avoid extra tailing blank line in python -m inspect -d <target> (#139293)
Signed-off-by: yihong0618 <zouzou0208@gmail.com>
2025-09-24 14:52:11 -04:00
Victor Stinner
8d83b7df3f
gh-139156: Optimize the UTF-7 encoder (#139253)
Remove base64SetO and base64WhiteSpace parameters.
2025-09-24 17:57:29 +02:00
Victor Stinner
c7b11b7546
gh-139156: Use PyBytesWriter in PyUnicode_EncodeCodePage() (#139259)
Replace PyBytes_FromStringAndSize() and _PyBytes_Resize() with the
PyBytesWriter API.
2025-09-24 16:39:40 +02:00
Victor Stinner
c9a79a02a8
gh-139156: Use PyBytesWriter in _PyUnicode_EncodeCharmap() (#139251)
Replace PyBytes_FromStringAndSize() and _PyBytes_Resize() with the
PyBytesWriter API.

Add _PyBytesWriter_GetSize() and _PyBytesWriter_GetData() static
inline functions.
2025-09-24 16:15:34 +02:00
sobolevn
06703d6637
Remove .. deprecated-removed notes for typing.{NamedTuple, TypedDict} (#139298) 2025-09-24 16:24:58 +03:00
Rok Mandeljc
7016044de9
gh-139231: Fix estimation of available stack size for recursion limit on macOS (GH-139232)
Use `pthread_get_stackaddr_np()` and `pthread_get_stacksize_np()` to determine the stack address and size.
2025-09-24 11:57:00 +01:00
Bénédikt Tran
a5e0562350
gh-133644: remove PyWeakref_GetObject and PyWeakref_GET_OBJECT (GH-133657) 2025-09-24 11:25:56 +02:00
Stan Ulbrych
30f849250b
gh-83336: Add alias for consistency to utf-8-sig (#136530)
Closes #83336
2025-09-24 10:38:57 +02:00
Donghee Na
c4f21d7c7c
gh-133171: Re-enable JUMP_BACKWARD to free-threading build (gh-137800) 2025-09-24 14:19:17 +09:00
Tian Gao
c8624cd367
gh-138860: Lazy import rlcompleter in pdb to avoid deadlock in subprocess (#139185) 2025-09-24 11:46:05 +08:00
Barney Gale
9e6493849e
GH-139174: Prepare pathlib.Path.info for new methods (#139175)
Merge `_WindowsPathInfo` and `_PosixPathInfo` classes into a new
`_StatResultInfo` class. On Windows, this means relying on `os.stat()`
rather than `os.path.isfile()` and friends, which is a little slower. But
there's value in making the code easier to maintain, and we're going to
need the stat result for implementing `size()`, `mode()` etc.

Also move the classes from `pathlib._os` to `pathlib` proper.
2025-09-24 01:52:24 +00:00
Serhiy Storchaka
1a2e00c97a
gh-67795: Accept any real numbers as timestamp and timeout (GH-139224)
Functions that take timestamp or timeout arguments now accept any
real numbers (such as Decimal and Fraction), not only integers or floats,
although this does not improve precision.
2025-09-23 21:31:42 +03:00
Dave Peck
6ec058a1f7
gh-138558: Improve handling of Template annotations in annotationlib (#139072) 2025-09-23 11:25:51 -07:00
Victor Stinner
e8382e55c5
gh-74857, PEP 538: Coerce POSIX locale to UTF-8 based locale (#139238) 2025-09-23 19:20:59 +02:00
Russell Keith-Magee
a79ce35c70
gh-136744: Remove a redundant test skip (#139267)
Remove a redundant test skip.
2025-09-23 16:56:14 +00:00
Victor Stinner
dd45179fa0
gh-129813, PEP 782: Remove the private _PyBytesWriter API (#139264)
It is now replaced with the new public PyBytesWriter API (PEP 782).
2025-09-23 15:29:55 +00:00
Serhiy Storchaka
5854cf38a2
gh-130567: Fix possible crash in locale.strxfrm() (GH-138940)
On some macOS versions there was an off-by-one error in wcsxfrm() which
caused writing past the end of the array if its size was not calculated
by running wcsxfrm() first.

Co-authored-by: Ronald Oussoren <ronaldoussoren@mac.com>
2025-09-23 15:11:50 +00:00
Peter Bierma
6b4e3fe9d4
gh-126016: Fix flaky test by allowing the SIGINT return code (GH-139219) 2025-09-23 16:09:19 +02:00
Victor Stinner
dd683f8f34
gh-139208: Fix regrtest --fast-ci --verbose (#139240)
Don't ignore the --verbose option anymore.
2025-09-23 16:09:01 +02:00
Mark Shannon
16eae6d90d
GH-137573: Add test to check that the margin used for overflow protection is larger than the stack space used by the interpreter (GH-137724) 2025-09-23 15:47:27 +02:00
Victor Stinner
8cfd7b4ecf
gh-129813, PEP 782: Use PyBytesWriter in utf8_encoder() (#138874)
Replace the private _PyBytesWriter API with the new public
PyBytesWriter API in utf8_encoder() and unicode_encode_ucs1().
2025-09-23 11:47:09 +02:00
Victor Stinner
49e83e31bd
gh-139156: Use PyBytesWriter in PyUnicode_AsRawUnicodeEscapeString() (#139250)
Replace PyBytes_FromStringAndSize() and _PyBytes_Resize() with the
PyBytesWriter API.
2025-09-22 23:46:19 +02:00
Victor Stinner
c497694f77
gh-139156: Use PyBytesWriter in UTF-16 encoder (#139233)
Replace PyBytes_FromStringAndSize() and _PyBytes_Resize() with the
PyBytesWriter API.
2025-09-22 23:36:05 +02:00
Victor Stinner
e578a9e6a5
gh-139156: Use PyBytesWriter in PyUnicode_AsUnicodeEscapeString() (#139249)
Replace PyBytes_FromStringAndSize() and _PyBytes_Resize() with the
PyBytesWriter API.
2025-09-22 23:22:27 +02:00
Victor Stinner
c863349f98
gh-139156: Use PyBytesWriter in the UTF-7 encoder (#139248)
Replace PyBytes_FromStringAndSize() and _PyBytes_Resize() with the
PyBytesWriter API.
2025-09-22 22:49:25 +02:00
Victor Stinner
92ba2c92c4
gh-139156: Use PyBytesWriter in UTF-32 encoder (#139157)
Replace PyBytes_FromStringAndSize() and _PyBytes_Resize() with the
PyBytesWriter API.
2025-09-22 20:05:35 +00:00
Savannah Bailey
f0d8583303
GH-139040: Add Dev Container instructions in JIT README (#139041) 2025-09-22 09:34:02 -07:00
Russell Keith-Magee
04c4628345
gh-136744: Remove unnecessary chmod from pydoc.apropos() test. (GH-136746)
Remove unnecessary chmod from pydoc.apropos() test.
2025-09-22 16:26:13 +02:00
Katie Gardner
e642a24b50
gh-95953: Add a css class to changed lines of difflib.HtmlDiff make_table (#139226) 2025-09-22 13:19:37 +00:00
Savannah Bailey
72d5ee0511
GH-137218: Fix Makefile to handle FreeBSD (fix for JIT stencil changes) (GH-139170) 2025-09-22 14:21:57 +02:00
Stan Ulbrych
4fb338d844
Doc/library/zoneinfo.rst: Fix typo (#139190)
Removes duplicated wording.
2025-09-22 07:25:39 -04:00
Petr Viktorin
61e54e52ea
gh-136003: Close file descriptors in test (GH-139225)
This fixes file descriptor leaks introduced in GH-136004
2025-09-22 13:22:27 +02:00
Jason R. Coombs
a756a4b953
gh-138313: Suppress ResourceWarnings and restore skipped test (#138597) 2025-09-21 20:53:57 -04:00
Stan Ulbrych
9c3d09b984
Doc/library/os.rst: Remove spurious parenthesis (GH-139205) 2025-09-21 14:57:13 -04:00
Pablo Galindo Salgado
cb6fed0d7e
gh-138709: Supress stdout/stderr during test_sampling_profiler tests (#139212) 2025-09-21 18:39:07 +00:00
Pablo Galindo Salgado
9df477c0ce
gh-138709: Fix race condition in test_external_inspection (#139209)
Fix race condition in test_external_inspection thread status tests

The tests test_thread_status_detection and test_thread_status_gil_detection
had a race condition where the test could sample thread status between when
the sleeper thread sends its "ready" message and when it actually calls
time.sleep(). This caused intermittent test failures where the sleeper
thread would show as running (status=0) instead of idle (status=1 or 2).

The fix moves the thread status collection inside the retry loop and
specifically waits for the expected thread states before proceeding with
assertions. The retry loop now continues until:
- The sleeper thread shows as idle (status=1 for CPU mode, status=2 for GIL mode)
- The busy thread shows as running (status=0)
- Both thread IDs are found in the status collection

This ensures the test waits for threads to settle into their expected states
before making assertions, eliminating the race condition.
2025-09-21 18:32:03 +01:00
sobolevn
080faf2d47
Docs: add missing tools to Tools/README (#139150)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-09-21 14:44:17 +03:00
AN Long
e101f907dc
gh-138092: Correct the documented signature of `mmap.flush` (#138671) 2025-09-21 11:54:30 +01:00
sobolevn
848d926786
Make sure the `:keyword: role works for case` (#138878) 2025-09-21 11:49:49 +01:00
Stan Ulbrych
b90e4ace9d
Link to Discourse in `.github/CONTRIBUTING.rst` (#138996)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-09-21 10:49:46 +00:00
Serhiy Storchaka
20d5494c88
Revert "gh-66234: Add flag to disable the use of mmap in dbm.gnu (GH-135005)" (GH-136989)
This reverts commit 0cec424af5.
2025-09-20 11:01:44 +03:00
Cody Maloney
69c6b438e8
gh-138013: Split SignalsTest from test_io.test_general (#139079)
Increase parallelism by splitting out `SignalsTest` from test_general.
`SignalsTest` takes 24.2 seconds on my dev machine when fully enabled
making it the largest part of `test_io`. Code move done via copy/paste
then tweak imports.

After splitting `test_io.test_general` is down to 10.1 seconds on my dev
box with all parts enabled.
2025-09-19 18:21:50 +00:00
Pablo Galindo Salgado
67636f72d2
gh-138709: Implement CPU time profiling in profiling.sample (#138710) 2025-09-19 19:17:28 +01:00
Peter Bierma
d06113c7a7
gh-112729: Correctly fail when the process is out of memory during interpreter creation (GH-139164) 2025-09-19 10:41:09 -04:00
Lisa Roach
2fd43a1ffe
gh-138310: Adds sys.audit event for import_module (#138311)
* Updates sys.audit calls for imports to include import_module
* Adds unit tests for existing and new functionality
2025-09-19 06:21:42 -07:00
Serhiy Storchaka
7257b24140
gh-139076: Fix regression in pydoc not showing extension functions (GH-139077)
Fix a bug in the pydoc module that was hiding functions in a Python
module if they were implemented in an extension module and the module did
not have __all__.
2025-09-19 15:54:06 +03:00
Karolina Surma
b36dee855d
Fix the reference to unicode specification (#139138) 2025-09-19 14:28:55 +02:00
Russell Keith-Magee
35c7e52b3e
gh-138171: Migrate iOS testbed location and add Apple build script (#138176)
Adds tooling to generate and test an iOS XCframework, in a way that will also facilitate
adding other XCframework targets for other Apple platforms (tvOS, watchOS, visionOS and 
even macOS, potentially).

---------
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-09-19 13:23:38 +01:00
Peter Bierma
9243a4b933
gh-126016: Remove bad assertion in PyThreadState_Clear (GH-139158)
In the _interpreters module, we use PyEval_EvalCode() to run Python code in another interpreter. However, when the process receives a KeyboardInterrupt, PyEval_EvalCode() will jump straight to finalization rather than returning. This prevents us from cleaning up and marking the thread as "not running main", which triggers an assertion in PyThreadState_Clear() on debug builds. Since everything else works as intended, remove that assertion.
2025-09-19 12:17:05 +00:00
Gordon P. Hemsley
e3d9bd6be3
gh-81148: Eliminate unnecessary check in _strptime when determining AM/PM (#13428)
* bpo-36967: Eliminate unnecessary check in _strptime when determining AM/PM

* Pauls suggestion to refactor test

* Fix test

---------

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Paul Ganssle <1377457+pganssle@users.noreply.github.com>
2025-09-19 10:23:12 +00:00
Savannah Bailey
85c1ef6477
GH-137218: Update make for JIT stencils (#137265) 2025-09-19 10:36:42 +01:00
Victor Stinner
47485c0384
gh-129813, PEP 782: Fix refleak in sock_recvfrom() (GH-139151) 2025-09-19 09:30:11 +00:00
Semyon Moroz
495f589363
gh-121237: Add %:z directive to datetime.strptime (#136961) 2025-09-19 10:25:31 +01:00
da-woods
ac5c5d42a2
gh-119494: Fix error messages for deleting/setting type attributes (#119495) 2025-09-18 22:08:49 +01:00
Peter Bierma
3eec897752
gh-136003: Skip non-daemon threads when exceptions occur during finalization (GH-139129)
During finalization, we need to mark all non-daemon threads as daemon to quickly shut down threads when sending CTRL^C to the process. This was a minor regression from GH-136004.
2025-09-18 16:04:01 -04:00
Alex Waygood
293b05c09b
gh-118803: Make ByteString deprecations louder; remove ByteString from typing.__all__ and collections.abc.__all__ (#139127) 2025-09-18 18:58:16 +00:00
Alex Waygood
4305cc3ef3
gh-118803: Improve documentation around ByteString deprecation (#139115) 2025-09-18 17:29:59 +00:00
Nicholas Tindle
0f27e10204
gh-137976: Explicitly exclude localtime from available_timezones (#138012)
* fix: available_timezones is reporting an invalid IANA zone name

* 📜🤖 Added by blurb_it.

* correct rst format for backticks

---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Paul Ganssle <1377457+pganssle@users.noreply.github.com>
2025-09-18 17:32:14 +01:00
Victor Stinner
d641c41c88
gh-129813, PEP 782: Use PyBytesWriter in socket recvmsg() (#139131)
Replace PyBytes_FromStringAndSize(NULL, size) and _PyBytes_Resize()
with the new public PyBytesWriter API.
2025-09-18 17:57:04 +02:00
Benjamin Peterson
e163fbdeda
fixes gh-139090: add os.RWF_DONTCACHE (#139091) 2025-09-18 08:13:23 -07:00
Victor Stinner
9b35f7cdfe
gh-129813, PEP 782: Use PyBytesWriter in bufferedio.c (#139121)
Replace PyBytes_FromStringAndSize(NULL, size) and _PyBytes_Resize()
with the new public PyBytesWriter API.
2025-09-18 17:00:10 +02:00
Victor Stinner
446587c58e
gh-129813, PEP 782: Use PyBytesWriter in _ssl (#138929)
Replace PyBytes_FromStringAndSize(NULL, size) and _PyBytes_Resize()
with the new public PyBytesWriter API.
2025-09-18 16:54:18 +02:00
Sergey B Kirpichev
b0a8073f1b
gh-73487: Convert _decimal to use Argument Clinic (part 7) (#138221)
Use "defining class" converter, where possible.
2025-09-18 16:08:27 +02:00
Adam Turner
1ebd726c9b
gh-64490: Argument Clinic: Add support for `**kwds` (#138344)
This adds a scaffold of support, initially only working with
strictly positional-only arguments. The FASTCALL calling
convention is not yet supported.
2025-09-18 13:31:42 +00:00
Malcolm Smith
594bdde9df
gh-137242: Mention Android binary releases in documentation (#138305)
Adds a mention of binary releases to the Android documentation.

---------
Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-09-18 13:25:30 +00:00
Ken Jin
a269e691de
gh-139109: Dynamic opcode targets (GH-139111)
Make opcode targets table dynamic
2025-09-18 14:12:07 +01:00
Victor Stinner
243d599a05
gh-129813, PEP 782: Use PyBytesWriter in _sqlite (#138956)
Replace PyBytes_FromStringAndSize(NULL, size) with the new public
PyBytesWriter API.
2025-09-18 14:58:35 +02:00
Victor Stinner
6504f20cce
gh-135755: Make Py_TAIL_CALL_INTERP macro private (#138981)
Rename Py_TAIL_CALL_INTERP to _Py_TAIL_CALL_INTERP.
2025-09-18 14:33:07 +02:00
Peter Bierma
2191497933
gh-136003: Execute pre-finalization callbacks in a loop (GH-136004) 2025-09-18 08:29:12 -04:00
Victor Stinner
d6a6fe2a5b
gh-129813, PEP 782: Use PyBytesWriter in ssl.MemoryBIO (#139113)
Replace PyBytes_FromStringAndSize(NULL, size) and _PyBytes_Resize()
with the new public PyBytesWriter API.
2025-09-18 14:25:31 +02:00
Peter Bierma
89ff88be89
Document Py_AddPendingCall() change with subinterpreters in 3.12 (GH-139117)
Prior to 3.9, Py_AddPendingCall() would always run pending calls in the main interpreter, but then each interpreter got their own ceval state, and they were scheduled for any interpreter. In GH-104813, this was undone, so Py_AddPendingCall() would always schedule for the main interpreter.
2025-09-18 12:10:41 +00:00
Peter Bierma
571210b8f3
gh-135729: Store reference to globals in Interpreter._decref (GH-139104) 2025-09-18 11:17:51 +00:00
Petr Viktorin
36ec60fb43
gh-138970: Adjust tests for pegen rule flags (#139107) 2025-09-18 12:08:44 +01:00
Peter Bierma
49f1c302df
gh-139098: Use multiphase initialization in _testcapi (GH-139102)
Use multiphase initialization in the _testcapi module to allow loading in subinterpreters. The isolation here isn't perfect as there's still some use of globals, but _testcapi should generally work in other interpreters.
2025-09-18 11:00:50 +00:00
Stan Ulbrych
70ad1b30df
gh-138998: expat/refresh.sh: Fail if Step 3 is not completed (GH-139049) 2025-09-18 12:47:42 +02:00
Donghee Na
8247e1b3e7
gh-137838: Add CI for no-opt JIT (#139081)
* gh-137838: Add CI for no-opt JIT

* nit
2025-09-18 11:46:03 +01:00
Malcolm Smith
0ac377ff23
Make Android streams respect the unbuffered (-u) option (#138806)
Android pipes stdout/stderr to the log, which means every write to the log
becomes a separate log line. As a result, most practical uses of stdout/stderr
should be buffered; but it doesn't hurt to preserve unbuffered handling in case
it's useful.
2025-09-18 11:41:21 +01:00
Cody Maloney
db68bfc771
gh-138720: Make Buffered closed check match flush (GH-138724)
In `_io__Buffered_flush_impl` the macro `CHECK_CLOSED` is used to check
the `buffered*` is in a good state to be flushed. That differs slightly
from `buffered_closed`.

In some cases, that difference would result in `close()` thinking the
file needed to be flushed and closed while `flush()` thought the file
was already closed.

This could happen during GC and would result in an unraisable exception.
2025-09-18 12:02:29 +02:00
Victor Stinner
9f7bbafffe
gh-129813, PEP 782: Optimize byteswriter_resize() (#139101)
There is no need to copy the small_buffer in PyBytesWriter_Create().
2025-09-18 09:52:16 +00:00
Erlend E. Aasland
d1904b91cb
gh-116943: Ensure makesetup does not choke on missing EOL in Setup.* files (#139100) 2025-09-18 09:25:01 +00:00
Victor Stinner
4263bc3b3b
gh-129813, PEP 782: Use PyBytesWriter in _socket (#139097)
Replace PyBytes_FromStringAndSize(NULL, size) and _PyBytes_Resize()
with the new public PyBytesWriter API.
2025-09-18 11:20:56 +02:00
Mark Shannon
3b83257366
GH-138378: Move globals-to-consts pass into main optimizer pass (GH-138379) 2025-09-18 10:09:59 +01:00
Rafael Fontenelle
d22b25081b
Remove unmatched closing parenthesis (GH-139082) 2025-09-18 10:01:09 +01:00
Raymond Hettinger
c25400a4b6
Revert gh-139075. The sumprod fix needs more work. (gh-139092) 2025-09-18 02:05:27 -05:00
Oleksandr Kravets
444ebaf16e
Remove unnecessary slice in heapq.py (gh-139087) 2025-09-18 00:52:46 -05:00
Pablo Galindo Salgado
0ce9fb7e3b
gh-138970: Add general metadata system to the peg generator (#138971) 2025-09-18 02:17:04 +01:00
Raymond Hettinger
b485e50fde
gh-139074: Fix missing high precision case in sumprod() (gh-139075) 2025-09-17 16:50:15 -05:00
Denis Sergeev
5a15e73789
gh-138813: Fix mutable default kwargs={} in multiprocessing BaseProcess and DummyProcess to use None (GH-138814)
* gh-138813: Default `BaseProcess` `kwargs` to `None` (#138814)

Set `BaseProcess.__init__(..., kwargs=None)` and initialize `kwargs` with
`dict(kwargs) if kwargs else {}`. This avoids a shared mutable default and
matches threading.Thread behavior.

Co-authored-by: Dmitrii Chuprov <cheese@altlinux.org>

* DummyProcess kwargs=None (which threading.Thread accepts properly)

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2025-09-17 14:45:52 -07:00
Sergey Miryanov
b42af37ced
GH-138355: Remove trash_delete_later from _gc_runtime_state (#138767)
Remove trash_delete_later and trash_delete_nesting from _gc_runtime_state.
2025-09-17 21:25:24 +01:00
Donghee Na
d873fb42f3
gh-137838: Move _PyUOpInstruction buffer to PyInterpreterState (gh-138918) 2025-09-17 18:50:16 +01:00
Stefan Tatschner
a9b6b09141
gh-86819: Add ISO-TP CAN socket constants (#23794)
Co-authored-by: Stefan Tatschner <stefan@rumpelsepp.org>
Co-authored-by: Patrick Menschel <menschel.p@posteo.de>
2025-09-17 17:18:04 +00:00
Dino Viehland
e92599e677
gh-138714: Don't assume next block has instructions when propagating line numbers (#138770)
Co-authored-by: Irit Katriel <iritkatriel@yahoo.com>
2025-09-17 09:52:56 -07:00
Adam Turner
4b78fe9665
GH-137630: Convert `_interpqueues` to use Argument Clinic (#137685) 2025-09-17 17:35:00 +01:00
Moshe Kaplan
101fd33065
GH-139067: Add example for argparse's append action (#131389) 2025-09-17 17:24:20 +01:00
Victor Stinner
c72ffe71f1
gh-129813, PEP 782: Set invalid bytes in PyBytesWriter (#139054)
Initialize the buffer with 0xFF byte pattern when creating a writer
object, but also when resizing/growing the writer.
2025-09-17 17:58:32 +02:00
Victor Stinner
82e1920a01
gh-129813, PEP 782: Use PyBytesWriter in _testclinic (#139048)
Replace PyBytes_FromStringAndSize(NULL, size) with the new public
PyBytesWriter API.
2025-09-17 17:55:30 +02:00
chiri
8eb106240f
gh-138736: Fix sqlite3.Connection.blobopen 'row' parameter type and naming (#138738)
The 'row' parameter represents a ROWID. Clarify this in docs and docstrings.
2025-09-17 15:51:14 +00:00
Victor Stinner
77a22ef76a
gh-129813, PEP 782: Use PyBytesWriter in _multiprocessing (#139047)
Replace PyBytes_FromStringAndSize(NULL, size) and _PyBytes_Resize()
with the new public PyBytesWriter API.

Change also 'read' variable type from int to Py_ssize_t.
2025-09-17 17:44:13 +02:00
Victor Stinner
263242613f
gh-129813, PEP 782: Use PyBytesWriter in _Py_bytes_maketrans() (#139044)
Replace PyBytes_FromStringAndSize(NULL, size) with the new public
PyBytesWriter API.
2025-09-17 17:43:30 +02:00
Hans Then
dd0840bf67
gh-132558: Improve argparse docs on combining type and choices (#133827)
Co-authored-by: Savannah Bailey <savannahostrowski@gmail.com>
2025-09-17 15:25:17 +00:00
Adam Turner
2212ae5557
GH-92266: Remove embedded tabs from `c-analyzer/cpython/_parser.py` (#137622) 2025-09-17 15:25:04 +00:00
Paul Ganssle
5560ab674b
Add pganssle to CODEOWNERS for `zoneinfo` (#139032)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-09-17 16:17:27 +01:00
PrinceNaroliya
37425fe9fb
gh-137988: Fix const description in argparse.add_argument() docs (#138315)
Co-authored-by: Savannah Bailey <savannahostrowski@gmail.com>
2025-09-17 15:15:57 +00:00
Peter Bierma
a64881363b
gh-128639: Don't assume one thread in subinterpreter finalization with fixed daemon thread support (GH-134606)
This reapplies GH-128640.
2025-09-17 11:14:19 -04:00
Dino Viehland
299de38e61
gh-131776: Expose functions called from the interpreter loop via PyAPI_FUNC (#134242) 2025-09-17 08:04:02 -07:00
Aniket
dd15a2e11e
gh-138952: Document platform.machine() output casing inconsistency across platforms (#138962)
Co-authored-by: AN Long <aisk@users.noreply.github.com>
2025-09-17 15:56:21 +01:00
Rajhans Jadhao
e1eca8b308
gh-129368: In PyRun C API docs, clarify what a "start token" is (#129935) 2025-09-17 14:51:20 +00:00
Hood Chatham
2629ee4eb0
gh-128627: Use __builtin_wasm_test_function_pointer_signature for Emscripten trampoline (#137470)
With https://github.com/llvm/llvm-project/pull/150201 being merged, there is 
now a better way to generate the Emscripten trampoline, instead of including 
hand-generated binary WASM content. Requires Emscripten 4.0.12.
2025-09-17 15:33:55 +01:00
PrinceNaroliya
81c975bcfc
gh-139006: Doc: Clarify html.escape function description (#139016)
Doc: Clarify html.escape function description (GH-139006)
2025-09-17 21:45:34 +08:00
Petr Viktorin
5df6a568e1
gh-107862: Add property-based round-trip tests for base64 (#119406)
* Add property-based tests to test_base64

* Allow multiple positional arguments in @hypothesis.example stub

* Simplify the altchars strategy
2025-09-17 13:40:35 +00:00
adang1345
76b22978bc
gh-138896: Fix error installing C runtime on non-updated Windows machines (GH-138932) 2025-09-17 14:32:52 +01:00
Bénédikt Tran
3a04be986a
gh-76760: test that uuid.uuid1() sets the version field (#139033) 2025-09-17 13:31:51 +00:00
Łukasz Langa
2fc7004d54
gh-134466: Don't run when termios is inaccessible (GH-138911)
Without the ability to set required capabilities, the REPL cannot
function properly (syntax highlighting and multiline editing can't
work).

We refuse to work in this degraded state.
2025-09-17 12:59:49 +02:00
Stan Ulbrych
64c876dd68
gh-138998: Upgrade vendored expat to 2.7.2 (#138999) 2025-09-17 13:46:35 +03:00
Gyeongjae Choi
218b8dbc78
gh-99948: Support ctypes.util.find_library in emscripten environment (#138519)
Adds support for ctypes loading .so files directly.

---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
2025-09-17 10:17:56 +00:00
Adam Turner
69a5ea5340
GH-123299: Copyedit 3.14 What's New: C API (#138987) 2025-09-17 11:14:57 +01:00
Donghoon Nam
c025576a8f
gh-138966: Add description for gi_suspended attribute (GH-139008) 2025-09-17 04:21:52 -04:00
Serhiy Storchaka
a1cf6e92b6
gh-71679: Share the repr implementation between bytes and bytearray (GH-138181)
This allows to use the smart quotes algorithm in the bytearray's repr.
2025-09-17 11:10:29 +03:00
Serhiy Storchaka
cf9ef73121
gh-134716: Support regular expressions in -W and PYTHONWARNINGS (GH-138149) 2025-09-16 17:06:44 +00:00
Alex Waygood
530ddd3e06
Revert "gh-118803: Remove ByteString from typing and collections.abc (#118804)" (#138990) 2025-09-16 16:48:19 +01:00
Jelle Zijlstra
6d6aba2523
gh-137226: Fix get_type_hints() on generic TypedDict with stringified annotations (#138953)
This issue appears specifically for TypedDicts because the TypedDict constructor
code converts string annotations to ForwardRef objects, and those are not evaluated
properly by the get_type_hints() stack because of other shenanigans with type
parameters.

This issue does not affect normal generic classes because their annotations are not
pre-converted to ForwardRefs.

The fix attempts to restore the pre- #137227 behavior in the narrow scenario where
the issue manifests. It mostly makes changes only in the paths accessible from get_type_hints(),
ensuring that newer APIs (such as evaluate_forward_ref() and annotationlib) are not affected
by get_type_hints()'s past odd choices. This PR does not fix issue #138949, an older issue I
discovered while playing around with this one; we'll need a separate and perhaps more
invasive fix for that, but it should wait until after 3.14.0.
2025-09-16 07:28:39 -07:00
Benjamin Johnson
ab6893ab5c
gh-138514: getpass: restrict echo_char to a single ASCII character (#138591)
This amends commit bf8bbe9a81 by
restricting `echo_char` in `getpass.getpass` to single printable
ASCII characters as it would be uncommon to use long strings or
multi-byte characters for keyboard feedback.

---------

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Brian Schubert <brianm.schubert@gmail.com>
2025-09-16 16:21:55 +02:00
Victor Stinner
9a8bc6d4a4
gh-129813, PEP 782: Add doc reference link (#138986) 2025-09-16 15:51:45 +02:00
Steve Dower
6920fa4bcd
Adds support for building with VisualStudioVersion = 18.0 (GH-138980) 2025-09-16 13:41:36 +00:00
AN Long
6393068bde
fix some typos (#138977) 2025-09-16 18:33:39 +05:30
Irit Katriel
a651ec9524
gh-135629: rewrite language reference section on except* to improve clarity (#136150) 2025-09-16 13:56:51 +01:00
ivan
01cc53295c
Synced docs and docstring for sysconfig.get_platform (#135530)
Co-authored-by: Mikhail Efimov <efimov.mikhail@gmail.com>
Co-authored-by: Ned Deily <nad@python.org>
2025-09-16 12:16:48 +01:00
yihong
b9dbf6acb3
gh-135329: prevent infinite traceback loop on Ctrl-C for strace (GH-138133)
Signed-off-by: yihong0618 <zouzou0208@gmail.com>
Co-authored-by: dura0ok <slpmcf@gmail.com>
Co-authored-by: graymon <greyschwinger@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2025-09-16 12:39:03 +02:00
Brandt Bucher
55e29a6100
GH-129805: Clean up some changes from GH-129806 (GH-133540) 2025-09-16 11:29:09 +01:00
Stan Ulbrych
fc3e22a06c
gh-88473: Implement fast path in date.today() for date types (#130980)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-09-16 10:28:54 +01:00
Victor Stinner
d61dda52ba
gh-129813, PEP 782: Soft deprecate _PyBytes_Resize() (#138964)
Soft deprecate _PyBytes_Resize() and
PyBytes_FromStringAndSize(NULL, size).
2025-09-16 10:38:43 +02:00
Cody Maloney
ed75160b73
gh-138013: Remove load_tests in test_io.test_general (#138771)
Rely on default test discovery.

Validation:
```bash
 # Run before commit
./python -m test test_io -uall,walltime,largefile,cpu,extralargefile -M25G -o --fail-env-changed -j0 --list-cases | sort > old_cases.txt
 # Run after commit
./python -m test test_io -uall,walltime,largefile,cpu,extralargefile -M25G -o --fail-env-changed -j0 --list-cases | sort > new_cases.txt

diff new_cases.txt old_cases.
 # <outputs no changes in case list>
```
2025-09-16 10:37:28 +02:00
Sam Gross
90fe3250f8
gh-137433: Fix deadlock with stop-the-world and daemon threads (gh-137735)
There was a deadlock originally seen by Memray when a daemon thread
enabled or disabled profiling while the interpreter was shutting down.
I think this could also happen with garbage collection, but I haven't
seen that in practice.

The daemon thread could be hung while trying acquire the global rwmutex
that prevents overlapping global and per-interpreter stop-the-world events.
Since it already held the main interpreter's stop-the-world lock, it
also deadlocked the main thread, which is trying to perform interpreter
finalization.

Swap the order of lock acquisition to prevent this deadlock.
Additionally, refactor `_PyParkingLot_Park` so that the global buckets
hashtable is left in a clean state if the thread is hung in
`PyEval_AcquireThread`.
2025-09-16 09:21:58 +01:00
yihong
4c0d7bc52a
gh-138958: remove unused variable in Lib/asyncio/streams.py (#138959) 2025-09-16 08:48:41 +05:30
Emma Smith
445b424b74
Re-order Modules/makesetup in CODEOWNERS and update owners (#138628)
* Re-order Modules/makesetup in CODEOWNERS and add Adam Turner
* Add Erlend to Modules/makesetup in CODEOWNERS
2025-09-15 19:52:59 -07:00
Victor Stinner
4e00e2504f
gh-129813, PEP 782: Add PyBytesWriter.overallocate (#138941)
Disable overallocation in _PyBytes_FormatEx() at the last write.
2025-09-16 00:15:32 +02:00
Victor Stinner
4554486f15
gh-129813, PEP 782: Use PyBytesWriter in bufferedio.c (#138954)
Replace PyBytes_FromStringAndSize(NULL, size) and _PyBytes_Resize()
with the new public PyBytesWriter API.
2025-09-15 21:50:09 +00:00
Victor Stinner
e814e6b38b
gh-129813, PEP 782: Use PyBytesWriter in FileIO.read() (#138955)
Replace PyBytes_FromStringAndSize(NULL, size) and _PyBytes_Resize()
with the new public PyBytesWriter API.
2025-09-15 23:49:28 +02:00
Victor Stinner
f62b495f79
gh-129813, PEP 782: Use PyBytesWriter in _sha3 (#138923)
Replace PyBytes_FromStringAndSize(NULL, size) with the new public
PyBytesWriter API.
2025-09-15 22:53:03 +02:00
Cody Maloney
71defb6943
gh-129813, PEP 782: Use PyBytesWriter in _io.FileIO.readall (#138901)
Performance about the same, using the benchmark from gh-120754:

```
pyperf compare_to main.json pep782.json
read_file_small: Mean +- std dev: [main] 5.71 us +- 0.05 us -> [pep782] 5.68 us +- 0.05 us: 1.01x faster
read_file_large: Mean +- std dev: [main] 89.7 us +- 0.9 us -> [pep782] 86.9 us +- 0.8 us: 1.03x faster
read_all_rst_bytes: Mean +- std dev: [main] 926 us +- 8 us -> [pep782] 920 us +- 12 us: 1.01x faster
read_all_rst_text: Mean +- std dev: [main] 2.24 ms +- 0.02 ms -> [pep782] 2.17 ms +- 0.04 ms: 1.03x faster

Benchmark hidden because not significant (1): read_all_py_bytes

Geometric mean: 1.01x faster
```
2025-09-15 22:38:01 +02:00
Victor Stinner
c5fb72ea6c
gh-129813, PEP 782: Use PyBytesWriter in _winapi.PeekNamedPipe() (#138930)
Replace PyBytes_FromStringAndSize(NULL, size) and _PyBytes_Resize()
with the new public PyBytesWriter API.
2025-09-15 21:25:47 +01:00
Mehdi Hassan
dfd52e7a8b
gh-97517: Add documentation links to datetime strftime/strptime docstrings (#138559)
* Add documentation links to datetime strftime/strptime docstrings

- Add links to format codes documentation for all strftime methods
- Add links to format codes documentation for all strptime methods
- Addresses issue #97517

* Update C extension docstrings with format codes documentation

* Regenerate clinic code for updated docstrings

* Add clinic-generated header file for updated docstrings

* Fix docstring spacing consistency in both Python and C files

* Update Lib/_pydatetime.py

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>

---------

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2025-09-15 19:50:46 +01:00
Loïc Simon
537133d2b6
gh-69605: Hardcode some stdlib submodules in PyREPL module completion (os.path, collections.abc...) (GH-138268)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2025-09-15 18:51:34 +02:00
Victor Stinner
a68efdf09c
gh-129813, PEP 782: Use PyBytesWriter in _hashopenssl (#138922)
Replace PyBytes_FromStringAndSize(NULL, size) with the new public
PyBytesWriter API.
2025-09-15 18:41:43 +02:00
Serhiy Storchaka
29d026f93e
gh-37817: Allow assignment to __bases__ of direct subclasses of builtin classes (GH-137585) 2025-09-15 16:40:28 +00:00
Łukasz Langa
811acc85d5
gh-134953: Make the True/False/None check more efficient (GH-138931) 2025-09-15 18:27:37 +02:00
yihong
8ef7735c53
gh-128636: Fix crash in PyREPL when os.environ is overwritten with an invalid value for macOS (GH-138089)
Signed-off-by: yihong0618 <zouzou0208@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-09-15 18:26:23 +02:00
Ken Jin
46f823bb81
gh-132732: Clear errors in JIT optimizer on error (GH-136048) 2025-09-15 17:24:37 +01:00
00ll00
26cfb17942
gh-138239: Fix incorrect highlighting of "type" in type statements in the REPL (GH-138241)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-09-15 18:21:41 +02:00
Serhiy Storchaka
07d0b95b05
gh-137490: Fix signal.sigwaitinfo() on NetBSD (GH-137523)
Handle ECANCELED in the same way as EINTR to work around the Posix
violation in the NetBSD's implementation.
2025-09-15 19:20:31 +03:00
Savannah Bailey
fa12c6bae4
GH-132732: Remove textwrap import (#138933) 2025-09-15 16:09:51 +00:00
Savannah Bailey
9c9a0f7da7
GH-132732: Use pure op machinery to optimize various instructions with _POP_TOP and _POP_TWO (#137577) 2025-09-15 16:29:45 +01:00
Kumar Aditya
5c4bb9b7f6
gh-137992: fix PyRefTracer_SetTracer to start world before returning (#138925)
fix deadlock in PyRefTracer_SetTracer
2025-09-15 15:39:15 +01:00
Serhiy Storchaka
a003112821
gh-138712: Add os.NODEV (GH-138728) 2025-09-15 14:36:32 +00:00
Stan Ulbrych
a5b9d0b8b2
gh-134953: Expand theming for True/False/None (#135000)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2025-09-15 16:36:17 +02:00
Victor Stinner
67cc1cf68a
gh-129813, PEP 782: Use PyBytesWriter in _codecs.escape_decode() (#138919)
Replace PyBytes_FromStringAndSize(NULL, size) and _PyBytes_Resize()
with the new public PyBytesWriter API.
2025-09-15 16:32:43 +02:00
Victor Stinner
21c80cadc8
gh-129813, PEP 782: Use PyBytesWriter in _curses (#138920)
Replace PyBytes_FromStringAndSize(NULL, size) and _PyBytes_Resize()
with the new public PyBytesWriter API.
2025-09-15 16:24:34 +02:00
Victor Stinner
7c6efc3a4f
gh-129813, PEP 782: Init small_buffer in PyBytesWriter_Create() (#138924)
Fill small_buffer with 0xFF byte pattern to detect the usage of
uninitialized bytes in debug build.
2025-09-15 16:23:11 +02:00
Victor Stinner
f07ae274b8
gh-129813, PEP 782: Use PyBytesWriter in fcntl (#138921)
Replace PyBytes_FromStringAndSize(NULL, size) with the new public
PyBytesWriter API.

Don't build the fcntl with the limited C API anymore, since
the PyBytesWriter API is not part of the limited C API.
2025-09-15 16:21:43 +02:00
Serhiy Storchaka
43013f72f0
gh-138779: Use the dev_t converter for st_rdev (GH-138780)
This allows to support device numbers larger than 2**63-1.
2025-09-15 17:07:34 +03:00
Petr Viktorin
32b2c5de16
gh-137956: Guard against non-free-threaded extensions in free-threaded builds (GH-137957) 2025-09-15 11:24:16 +00:00
Abdul
aa9ceb1721
gh-137017: Ensure Thread.is_alive() only returns False after the underlying OS thread exits (gh-137315) 2025-09-15 11:13:37 +00:00
Marat Khagazheev
cb07bd24ee
gh-138902: Fix generator send arg name (#138905)
Co-authored-by: marat <khagazheev@artlebedev.ru>
2025-09-15 14:05:36 +03:00
Pablo Galindo Salgado
c5180d74e1
gh-137992: Stop the world when calling PyRefTracer_SetTracer (#137994) 2025-09-15 10:39:41 +00:00
Victor Stinner
2d724939d7
gh-129813, PEP 782: Use PyBytesWriter in _PyBytes_FormatEx() (#138839)
Replace the private _PyBytesWriter API with the new public
PyBytesWriter API.
2025-09-15 12:23:36 +02:00
Pablo Galindo Salgado
f01181b595
gh-138794: Communicate to PyRefTracer when they are being replaced (#138797) 2025-09-15 11:12:09 +01:00
sobolevn
baf7470515
gh-138886: Remove deprecated PySys_ResetWarnOptions C-API function (#138887) 2025-09-15 12:01:33 +03:00
Bartosz Sławecki
097fc12149
Fix typo in stack_protection.md (GH-138876) 2025-09-15 04:53:13 -04:00
Kian Eliasi
481588ad4c
gh-138871: Clarify NameError exception in 'del' (#138881) 2025-09-15 02:11:01 -04:00
László Kiss Kollár
3e06cfcaee
gh-135953: Reduce memory usage of stack collectors (#138875)
The stack collector base class keeps all frames until export() is
called, which causes significant unnecessary memory usage. Instead, we
can process the frames on the fly in the collect call by dispatching the
aggregation logic to the subclass through the process_frames method.

Co-authored-by: Pablo Galindo Salgado <pablogsal@gmail.com>
2025-09-14 23:47:14 +01:00
Pablo Galindo Salgado
efc08c5fbf
gh-135953: Prevent overflow in the profiler flamegraph hover boxes (#138880) 2025-09-14 21:50:18 +01:00
sobolevn
1c984ba953
gh-136355: Deprecate -b and -bb CLI flags in 3.15 (#136363)
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2025-09-14 20:00:03 +03:00
Victor Stinner
8b5ce31c2b
gh-71810: Fix _PyLong_AsByteArray() undefined behavior (#138873)
Don't read p[-1] when p is an empty string: when n==0.
2025-09-14 11:25:53 +02:00
Victor Stinner
7168e98c80
gh-129813, PEP 782: Use PyBytesWriter in lzma and zlib (#138832)
Replace PyBytes_FromStringAndSize(NULL, size) with the new public
PyBytesWriter API.
2025-09-13 19:27:04 +02:00
Victor Stinner
430900d15b
gh-129813, PEP 782: Use PyBytesWriter in _PyBytes_FromList() (#138837)
Use the new public PyBytesWriter API in:

* _PyBytes_FromHex()
* _PyBytes_FromBuffer()
* _PyBytes_FromList()
* _PyBytes_FromTuple()
* _PyBytes_FromIterator()

Add _PyBytesWriter_ResizeAndUpdatePointer() and
_PyBytesWriter_GetAllocated() helper functions.
2025-09-13 19:23:57 +02:00
Victor Stinner
af386fd361
gh-129813, PEP 782: Use PyBytesWriter in posix extension (#138829)
Replace PyBytes_FromStringAndSize(NULL, size) and _PyBytes_Resize()
with the new public PyBytesWriter API.
2025-09-13 18:57:46 +02:00
Victor Stinner
703da5e81d
gh-129813, PEP 782: Use PyBytesWriter in memoryview (#138836)
Replace PyBytes_FromStringAndSize(NULL, size) with the new public
PyBytesWriter API.
2025-09-13 18:36:05 +02:00
Victor Stinner
bb743b684b
gh-129813, PEP 782: Use PyBytesWriter in socket and mmap (#138831)
Replace PyBytes_FromStringAndSize(NULL, size) and _PyBytes_Resize()
with the new public PyBytesWriter API.
2025-09-13 18:31:26 +02:00
Victor Stinner
06b7891f12
gh-129813, PEP 782: Use Py_GetConstant(Py_CONSTANT_EMPTY_BYTES) (#138830)
Replace PyBytes_FromStringAndSize(NULL, 0) with
Py_GetConstant(Py_CONSTANT_EMPTY_BYTES). Py_GetConstant() cannot
fail.
2025-09-13 18:30:25 +02:00
Victor Stinner
8fc6ae68b0
gh-129813, PEP 782: Use PyBytesWriter in _PyBytes_DecodeEscape2() (#138838)
Replace the private _PyBytesWriter API with the new public
PyBytesWriter API.
2025-09-13 18:28:08 +02:00
Victor Stinner
a65236bb39
gh-129813, PEP 782: Use PyBytesWriter in pickle and struct (#138833)
Replace the private _PyBytesWriter API with the new public
PyBytesWriter API.
2025-09-13 18:26:49 +02:00
Victor Stinner
ca99af3c5e
gh-129813, PEP 782: Use PyBytesWriter in binascii (#138825)
Replace the private _PyBytesWriter API with the new public
PyBytesWriter API.
2025-09-13 18:25:16 +02:00
Barney Gale
805e3368d6
GH-128520: pathlib ABCs: improve protocol for 'openable' objects (#134101)
Rename `pathlib._os.magic_open()` to `vfsopen()`. The new name is a bit
less abstract, and it aligns with the `vfspath()` method added in 5dbd27d.

Per discussion on discourse[^1], adjust `vfsopen()` so that the following
methods may be called:

- `__open_reader__()`
- `__open_writer__(mode)`
- `__open_updater__(mode)`

These three methods return readable, writable, and full duplex file objects
respectively. In the 'writer' method, *mode* is either 'a', 'w' or 'x'. In
the 'updater' method, *mode* is either 'r' or 'w'.

In the pathlib ABCs, replace `ReadablePath.__open_rb__()` with
`__open_reader__()`, and replace `WritablePath.__open_wb__()` with
`__open_writer__()`.

[^1]: https://discuss.python.org/t/open-able-objects/90238

Co-authored-by: Petr Viktorin <encukou@gmail.com>
2025-09-12 22:25:18 +01:00
Stan Ulbrych
2e8f64c931
gh-71648: Optimize PNG files (GH-138842)
* Only keep > 1 kb savings
2025-09-12 20:13:05 +00:00
Christoph Walcher
220c0a8156
gh-138804: Check type in shlex.quote (GH-138809) 2025-09-12 14:26:21 -04:00
Stan Ulbrych
35e6138d1f
gh-71648: Remove unused image Doc/faq/python-video-icon.png (GH-138841) 2025-09-12 11:16:51 -05:00
Victor Stinner
eec8c98d06
gh-129813, PEP 782: Use PyBytesWriter in _hashopenssl (#138835)
Replace PyBytes_FromStringAndSize(NULL, size) with the new public
PyBytesWriter API.
2025-09-12 15:39:16 +02:00
Kumar Aditya
ea26f6da39
gh-138661: fix data race in PyCode_Addr2Line (#138664) 2025-09-12 18:04:55 +05:30
Victor Stinner
c3fca5d478
gh-129813, PEP 782: Add PyBytesWriter_Format() (#138824)
Modify PyBytes_FromFormatV() to use the public PyBytesWriter API
rather than the _PyBytesWriter private API.
2025-09-12 14:21:57 +02:00
ivonastojanovic
419441a6e1
Improve permission error messages in pdb and asyncio.tools (#134290) 2025-09-12 12:54:04 +01:00
Victor Stinner
adb414044f
gh-129813, PEP 782: Add PyBytesWriter C API (#138822) 2025-09-12 13:41:59 +02:00
Victor Stinner
3d521a62e7
gh-138756: Fix leak of inittab memory in PyInitConfig_Free() (GH-138792) 2025-09-12 11:46:02 +02:00
jxes993409
492941459a
gh-138163: skip failures if tests are run with SCHED_BATCH on glibc (GH-138576) 2025-09-12 11:37:53 +02:00
Jan-Eric Nitschke
44991619ba
gh-138669: Increase test coverage for difflib (GH-138670) 2025-09-12 11:33:38 +02:00
Chris Eibl
4f3cab96c1
gh-138801: re-enable pyrepl tests on Windows (#138802) 2025-09-12 10:47:43 +03:00
Christoph Walcher
4afa98596e
Remove unused prototype _PyPegen_set_source_in_metadata (#138810)
Remove unused prototype
2025-09-12 00:40:49 +00:00
Peter Bierma
f96f7c9f5b
Revert "gh-116946: fully implement GC protocol for _tkinter.Tk{app,tt}Object (#138331)" (#138807)
This reverts commit 283380a941.
2025-09-11 17:05:37 -04:00
Benjamin Peterson
5bd4bf04c4
closes gh-138706: update Unicode to 17.0.0 (#138719) 2025-09-11 09:58:39 -07:00
Maurycy Pawłowski-Wieroński
e0f54a608e
gh-138005: Document that CSV skipinitialspace=True and delimiter=' ' require quotation for empty fields (#138006) 2025-09-11 18:11:33 +03:00
Alper
32e1e0699f
gh-116738: add multi-threaded tests for resource module on free-threading builds (#138504) 2025-09-11 19:08:08 +05:30
Pablo Galindo Salgado
d325cddc6b
gh-138704: Add PermissionError messages to profiling.sampling (#138705) 2025-09-11 14:32:08 +01:00
Bénédikt Tran
283380a941
gh-116946: fully implement GC protocol for _tkinter.Tk{app,tt}Object (#138331) 2025-09-11 12:59:30 +02:00
Victor Stinner
96dee64c73
gh-138756: Fix memory leak in PyInitConfig_Free() (#138759)
Clear also memory of PyConfig members.
2025-09-11 10:46:19 +00:00
Cody Maloney
101172486f
gh-138013: Move I/O test infrastructre to test_io.utils (#138475)
This moves test support code to `test_io.utils` via copy/paste
code movement then adjusts imports as needed
(remove unneded + add all required).
2025-09-11 12:45:30 +02:00
Peter Bierma
1da989be74
gh-138479: Ensure that __typing_subst__ returns a tuple (GH-138482)
Raise an exception if __typing_subst__ returns a non-tuple object.

---------

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-09-11 06:39:09 -04:00
Sergey B Kirpichev
011179a79a
gh-71810: Fix corner case (length==0) for int.to_bytes() (#138739)
```pycon
>>> (0).to_bytes(0, 'big', signed=True)
b''
>>> (-1).to_bytes(0, 'big', signed=True)  # was b''
Traceback (most recent call last):
  File "<python-input-0>", line 1, in <module>
    (-1).to_bytes(0, 'big', signed=True)
    ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
OverflowError: int too big to convert
```

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-09-11 12:30:53 +02:00
yihong
a1707e4516
gh-138081: fix some dead links in InternalDocs (#138082) 2025-09-11 10:54:16 +02:00
Bénédikt Tran
4978bfca10
gh-116946: add Py_TPFLAGS_IMMUTABLETYPE to several internal types (#138582)
The following types are now immutable:

* `_curses_panel.panel`,
* `[posix,nt].ScandirIterator`, `[posix,nt].DirEntry` (exposed in `os.py`),
* `_remote_debugging.RemoteUnwinder`,
* `_tkinter.Tcl_Obj`, `_tkinter.tkapp`, `_tkinter.tktimertoken`,
* `zlib.Compress`, and `zlib.Decompress`.
2025-09-11 09:56:20 +02:00
Stephen Morton
859aecc33b
gh-138432: Improved invalid path checking in zoneinfo.reset_tzpath() (GH-138433)
* Improve error messages for path-like relative paths and path-like bytes paths.
* TZPATH is now always a tuple of strings.
2025-09-11 10:08:53 +03:00
Adam Turner
d0c9943869
GH-138562: Remove `sort()` from the common sequence methods in the data model (#138563) 2025-09-10 15:52:57 +00:00
Hugo van Kemenade
6e78a539bf
gh-138744: GitHub Actions: pin to windows-2022 (#138743) 2025-09-10 17:28:27 +03:00
Jelle Zijlstra
7a6fd4a45d
gh-138349: Fix crash when combining module-level annotation and listcomp (#138363) 2025-09-10 15:18:39 +02:00
sobolevn
f5fa336579
gh-138729: Cover inspect.formatannotationrelativeto with tests (#138730) 2025-09-10 16:06:16 +03:00
sobolevn
cf8f36fe0a
gh-138716: Fix assert a := b syntax error message (#138718) 2025-09-10 16:05:16 +03:00
Dung Nguyen
1ce05537a3
gh-138008: Fix segfaults in _ctypes due to invalid argtypes (GH-138285)
Signed-off-by: Nguyen Viet Dung <29406816+magnified103@users.noreply.github.com>
Signed-off-by: Nguyen Viet Dung <dung@ekluster.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Yongzi Li <204532581+Yzi-Li@users.noreply.github.com>
2025-09-10 14:01:19 +02:00
Bénédikt Tran
d54b1091d4
gh-136006: fix Py_NAN expansion on Solaris systems (#136575)
On Solaris, `Py_NAN` may expand as a function address instead of a floating-point number.
This amends commit 7a3b03509e.
2025-09-10 11:11:04 +02:00
Bénédikt Tran
b9c50b4988
gh-134531: use EVP_MAC API for _hashlib.HMAC when possible (#135235)
Use `EVP_MAC` API for HMAC on builds with OpenSSL 3.0 or later.
2025-09-10 10:35:01 +02:00
Bénédikt Tran
d6d054853d
gh-137371: refactor and fortify test.support.hashlib_helper (#137375) 2025-09-10 09:14:38 +02:00
Dino Viehland
04c7f36205
gh-138230: Remove dead code in code gen - codegen_check_annotation is only calle… (#138228)
Remove dead code in code gen - codegen_check_annotation is only called if future annotations are enabled, and if future annotations are enabled it does nothing.
2025-09-09 18:17:00 -07:00
Pablo Galindo Salgado
766e7f150a
gh-135953: Fix refleak in cache method (#138721) 2025-09-10 00:08:09 +00:00
László Kiss Kollár
137519a38c
gh-135953: Add flamegraph reporter to sampling profiler (#138715) 2025-09-09 23:06:45 +01:00
sobolevn
6bc65c30ff
gh-136616: Improve assert syntax error messages (#136653) 2025-09-09 23:26:22 +03:00
Samuel Sloniker
66ef16105a
gh-85076: Document exceptions that can be raised by importlib.import_module (GH-94662) 2025-09-09 12:52:00 -07:00
Serhiy Storchaka
af58a6f883
gh-88886: Remove excessive encoding name normalization (GH-137167)
The codecs lookup function now performs only minimal normalization of
the encoding name before passing it to the search functions:
all ASCII letters are converted to lower case, spaces are replaced
with hyphens.

Excessive normalization broke third-party codecs providers, like
python-iconv.

Revert "bpo-37751: Fix codecs.lookup() normalization (GH-15092)"

This reverts commit 20f59fe1f7.
2025-09-09 21:07:21 +03:00
Victor Stinner
6b7b9d00a9
gh-138535: Pass directly state to posix fill_time() (#138693)
Pass directly the module state instead of passing the module to avoid
a call to get_posix_state().
2025-09-09 16:31:13 +02:00
Petr Viktorin
a92aec101e
gh-133143: Use _Py_ID for the other literals in sys (GH-138698)
Follow-up refactoring after GH-133143, where we use `_Py_ID` for "big" and "little"
in `abi_info.byteorder`.
This uses `_Py_ID` for `sys.byteorder`, but also `float_repr_style` and a module name.
2025-09-09 14:57:07 +02:00
yagggi
074f3b20b3
gh-138577: Mention Unix-specific limitations of getpass.getpass(echo_char=...) (#138677)
In bf8bbe9a81, `getpass.getpass` gained
the ability to provide keyboard feedback through `echo_char`.

On Unix, line editing shortcuts such as Ctrl+U were previously handled
as the terminal operates in canonical mode (see termios(3)). However,
since keyboard feedback requires to switch to noncanonical mode, this
now results in an inconsistency when `getpass.getpass` uses `echo_char`
as those shortcuts are no more supported. This limitation is specific
to Unix and does not affect Windows users where line editing shortcuts
were never supported.
2025-09-09 11:41:13 +02:00
Sergey B Kirpichev
fd2e3d1633
Add impl-detail block for PyLong_FromLong docs (#126422)
Co-authored-by: Brian Schubert <brianm.schubert@gmail.com>
2025-09-09 11:22:40 +02:00
Jeffrey Bosboom
d4825ac27c
gh-138535: Optimize fill_time for typical timestamps (#138537)
While file timestamps can be anything the file system can store, most
lie between the recent past and the near future.  Optimize fill_time()
for typical timestamps in three ways:

- When possible, convert to nanoseconds with C arithmetic.
- When using C arithmetic and the seconds member is not required (for
  st_birthtime), avoid creating a long object.
- When using C arithmetic, reorder the code to avoid the null checks
  implied in Py_XDECREF().

Co-authored-by: Victor Stinner <vstinner@python.org>
2025-09-09 11:05:54 +02:00
Donghee Na
5edfe55acf
gh-137838: Fix JIT trace buffer overrun by increasing possible exit stubs (gh-138177) 2025-09-09 09:51:08 +09:00
Pablo Galindo Salgado
03ee060ec8
gh-138385: Sample all interpreters in the tachyon profiler (#138398) 2025-09-09 00:41:08 +01:00
Victor Stinner
01895d233b
gh-137242: Add a --no-randomize option, and use it in Android CI (#138649)
Adds a --no-randomize option to the CI runner, so that randomisation can be easily
disabled for --fast-ci and --slow-ci configurations on single-threaded testing platforms
like Android, iOS, and Emscripten.

---------

Co-authored-by: Malcolm Smith <smith@chaquo.com>
2025-09-09 06:45:42 +08:00
Adam Turner
22cb9ba8f9
GH-101100: Remove some entries from `nitpick_ignore` (#138464) 2025-09-08 22:10:26 +00:00
Dino Viehland
1561385863
gh-138679: Opcodes which consume no inputs should indicate they produced the val… (#138678)
Opcodes which consume no inputs should indicate they produced the value, not an arbitrary local
2025-09-08 13:53:12 -07:00
Adam Turner
6831634eb7
gh-101100: Resolve reference warnings in reference/ (#138418) 2025-09-08 19:31:24 +00:00
Adam Turner
5443b9e52f
gh-133143: Condense the implementation for `sys.abi_info` (#138672) 2025-09-08 19:21:28 +00:00
Bénédikt Tran
49b351e832
gh-133879: Improve consistency of full stops and whitespace in What's New (#138635) 2025-09-08 20:12:03 +01:00
Bruce Merry
7d435cfde6
gh-136234: Fix SelectorSocketTransport.writelines to be robust to connection loss (#136743) 2025-09-08 21:39:52 +05:30
Shamil
c6f8b2fdb1
gh-138665: Move platform.invalidate_caches docs (#138667) 2025-09-08 17:20:46 +02:00
Klaus Zimmermann
1acb718ea2
gh-133143: Add sys.abi_info (GH-137476)
This makes information about the interpreter ABI more accessible.

Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-09-08 14:35:44 +00:00
Aalaap Dey
c006a623e7
gh-138659: Typo in the gc module docstring (#138660)
docs(gc): fix typo in get_threshold() docstring

Removes a duplicate "the" from the docstring for the `gc.get_threshold()` function.
2025-09-08 14:16:33 +00:00
sobolevn
4f0c267b40
gh-138644: Update c-api docs of PyInterpreterState about PEP-684 (#138651)
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-09-08 16:44:44 +03:00
Christoph Walcher
59edf12705
gh-57911: Fix failing symlink test in tarfile (GH-138626) 2025-09-08 15:42:54 +02:00
yihong
7a3bca50e0
gh-138318, PyREPL: builtins should not be highlighted when used as attribute names (#138319) 2025-09-08 14:04:22 +01:00
Adorilson Bezerra
921f61bd82
Doc: Apply keyword role around finally (in sys module doc) (GH-138544) 2025-09-08 14:02:36 +02:00
Bénédikt Tran
4ef51fa75c
gh-138633: fix Sphinx references in ssl documentation (#138648) 2025-09-08 11:31:40 +00:00
Petr Viktorin
097c563e7b
gh-137210: Move PYTHON_API_VERSION & PYTHON_ABI_VERSION to patchlevel.h (GH-138545)
Move PYTHON_API_VERSION & PYTHON_ABI_VERSION to patchlevel.h

This allows removing #include "modsupport.h" from python_ver_rc.h,
which allows modsupport.h to use common helpers from Python.h --
specifically, `_Py_PACK_VERSION` for defining limited API.
2025-09-08 12:02:13 +02:00
Bénédikt Tran
3255c0c870
gh-138633: synchronize documented signatures of SSL objects with runtime ones (#138639) 2025-09-08 09:28:10 +00:00
Adam Turner
057ee17410
gh-136264: Fix `--relative-paths` for PEP 739's build-details.json (#138510)
* KeyError is not raised for defaultdict
* Fix relative paths on different drives on Windows
* Add a round-trip test

Co-authored-by: Itamar Oren <itamarost@gmail.com>
2025-09-08 10:14:05 +01:00
Ron Frederick
6401823db3
gh-138252: Add support in SSL module for getting and setting TLS signature algorithms (#138269)
The signature algorithms allowed for certificate-based client authentication or
for the server to complete the TLS handshake can be defined on a SSL context via
`ctx.set_client_sigalgs()` and `ctx.set_server_sigalgs()`.

With OpenSSL 3.4 or later, the list of available TLS algorithms can be retrieved
by `ssl.get_sigalgs()`.

With OpenSSL 3.5 or later, the selected signature algorithms can be retrieved from
SSL sockets via `socket.client_sigalg()` and `socket.server_sigalg()`.

This commit also partially amends 377b787618
by using `PyUnicode_DecodeFSDefault` instead of `PyUnicode_DecodeASCII` in
`_ssl._SSLContext.get_groups`, so that functions consistently decode strings
obtained from OpenSSL.

---------

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-09-08 08:36:12 +00:00
Adam Turner
919c7e806e
GH-123299: Copyedit 3.14 What's New: Build Changes (#138488) 2025-09-08 10:09:45 +03:00
sobolevn
b0420b505e
gh-105487: Fix __dir__ entries of GenericAlias (#138578)
Co-authored-by: Emma Smith <emma@emmatyping.dev>
2025-09-08 00:33:24 +03:00
dbXD320
d7b9ea5cab
gh-138584: Increase test coverage for collections.UserList (#138590)
Some common tests in `test.list_tests.CommonTest` explicitly tested `list`
instead of testing the underlying list-like type defined in `type2test`.

---------

Co-authored-by: Devansh Baghla <devanshbaghla34@gmail.com>
2025-09-07 10:53:22 +02:00
Emma Smith
4ed046c481
Add Emma Smith to CODEOWNERS (#138588)
Added myself as a code owner for build system files, WASM platform files, and compression.zstd files.
2025-09-07 01:11:19 -07:00
Duane Griffin
0912b3a6db
gh-126631: gh-137996: fix pre-loading of __main__ (GH-135295)
gh-126631: gh-137996: fix pre-loading of `__main__`

The `main_path` parameter was renamed `init_main_from_name`, update the
forkserver code accordingly.  This was leading to slower startup times when people
were trying to preload the main module.

---------

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2025-09-07 07:49:54 +00:00
Albert Zeyer
8ed5a2b56c
gh-118981: multiprocessing.popen_spawn_posix, fix potential hang (gh-118982)
fix potential hang.

It can happen that the child crashes right in the beginning for whatever reason. In this case, the parent will hang when writing into the pipe, because the child fd is not closed yet.

The normal pattern is to close the child fds right after the child proc is forked/executed/spawned, so when the child dies, then also the pipes will be closed, and there will be no hang (the parent gets SIGPIPE instead).
2025-09-07 07:18:28 +00:00
Gilles Peiffer
c117b03385
Docs: Fix typo in random_derangement recipe (GH-138599) 2025-09-06 16:53:49 -04:00
Zachary Ware
bbe00d53e9
gh-90548: Skip NODEV portion of test_makedev when linked to musl (GH-138593) 2025-09-06 14:01:26 -05:00
Zachary Ware
7d58461fdb
gh-90548: Skip ctypes test_null_dlsym when linked to musl (GH-138592)
The test relies on glibc-specific behavior.
2025-09-06 14:01:18 -05:00
R. David Murray
bcdac03670
gh-90548: Allow Alpine/MUSL to pass test_c_locale_coercion. (GH-134454)
Like cygwin, MUSL defaults to utf-8 if no variables are set.  I have no
idea if the existing tests pass on cygwin, but I made the modifications
such that I shouldn't break it if is.  The additional checks needed for
MUSL are guarded by DEFAULT_LOCALE_IS_C being False.  Based on this
flag, we expect utf-8 for the encodings and no coercion message, as
long as LC_ALL is not set to C.  (That looks like a bit of an issue with
the test structure, but I'm not going to attempt to "fix" that.)
DEFAULT_ENCODING is intentionally not given a default since it is only
used when DEFAULT_LOCALE_IS_C is False, and if you use the flag you'll
need to set it.

After reading through issue 30672, looking at the source, and running a
test on Android, I *think* the current situation is that coercion will
be done if the local is set to POSIX regardless of platform.  However,
if the platform doesn't make POSIX equivalent to C, the encodings when
coercion is disabled will not be the same as for C (it is utf-8 on
android, for example).  This means the tests would fail if POSIX were
added unconditionally to the EXPECTED_C_LOCALE_EQUIVALENTS as envisioned
in the issue.  This *could* be fixed with another flag, but I'm not sure
it is worth the effort.  I'm not even sure Python is behaving optimally
in this case (assuming my analysis is correct).  So I just altered the
comment and add POSIX if and only if the platform is linux.
2025-09-06 14:01:11 -05:00
mqudah
2f5ace780b
fix comment reference from man 7 signal to man 7 signal-safety (#138554)
docs: fix comment reference from man 7 signal to man 7 signal-safety
2025-09-06 18:40:15 +00:00
AN Long
c919d02ede
gh-138205: Remove the resize method on mmap object on platforms don't support it (#138276)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-09-06 14:10:04 +05:30
Alper
8554c0917e
gh-116738: make cProfile module thread-safe (#138229)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-09-06 13:19:14 +05:30
David Ellis
7e652f402f
gh-137706: make typing._is_unpacked_typevartuple check for True instead of truthy (#137712) 2025-09-06 07:39:49 +00:00
Brett Cannon
bde1291952
GH-95952: Require setting HOSTRUNNER when cross compiling for WASI (#138203)
macOS by default doesn't have the requisite CLI tools to make a default value easy. Plus Tools/wasm/wasi takes care of setting HOSTRUNNER.
2025-09-05 15:48:16 -07:00
Jacob Walls
92b2a8a04d
gh-93334: Fix homonym edge case in PathFinder.find_spec() (GH-98100) 2025-09-05 15:41:01 -07:00
W. H. Wang
8368895049
gh-137985: Correct description of Formatter's datefmt param in logging documentation (GH-138530) 2025-09-05 22:07:04 +01:00
Brian Schubert
e2c038f5be
gh-138010: Fix __init_subclass__ forwarding by warnings.deprecated (#138210) 2025-09-05 20:44:50 +00:00
Adam Turner
8ed1d53e62
GH-138465: Improve documentation for common sequence methods (#138474)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-09-05 20:55:02 +01:00
dbXD320
e5c5830079
gh-138191: Document `frame.f_generator` in the data model (#138540)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-09-05 17:07:29 +00:00
Serhiy Storchaka
cb7ef18d70
gh-88375, gh-111788: Fix parsing errors and normalization in robotparser (GH-138502)
* Don't fail trying to parse weird patterns.
* Don't fail trying to decode non-UTF-8 "robots.txt" files.
* No longer ignore trailing "?" in patterns and URLs.
* Distinguish raw special characters "?", "=" and "&" from the
  percent-encoded ones.
* Remove tests that do nothing.
2025-09-05 18:58:42 +03:00
AN Long
ed522ed211
gh-83424: Allow empty name if handle is non-null when create ctypes.CDLL on Windows (GH-136878) 2025-09-05 18:51:35 +03:00
Jelle Zijlstra
9158bcf86b
annotationlib: add note on security to docs (#138508) 2025-09-05 08:26:58 -07:00
Petr Viktorin
0c74fc8af0
gh-137210: Add a struct, slot & function for checking an extension's ABI (GH-137212)
Co-authored-by: Steve Dower <steve.dower@microsoft.com>
2025-09-05 16:23:18 +02:00
Christoph Walcher
c1a9c23195
gh-57911: Sanitize symlink targets in tarfile on win32 (GH-138309) 2025-09-05 16:19:47 +02:00
Semyon Moroz
e76464d161
gh-131178: Fix test_unknown_flag for platform CLI (#137816) 2025-09-05 16:59:46 +05:30
Christoph Walcher
ed53c63769
gh-138401: Check arg count>=0 in os.sendfile() (#138403)
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-09-05 09:16:55 +00:00
Gyeongjae Choi
d1d84098f6
gh-138515: Include email module in Emscripten build (gh-138520) 2025-09-05 16:34:18 +08:00
Ric
f19f1d8563
gh-107194: Improved language of list.index in tutorial (gh-138518) 2025-09-05 15:16:04 +08:00
asas1asas200
e9c2a357fb
gh-138516: fix typo in OrderedDict exception msg (#138517) 2025-09-05 12:18:05 +05:30
Brian Schubert
fc0305a2d8
docs: add module-level versionadded for annotationlib (#138511) 2025-09-04 13:45:21 -07:00
Donghee Na
f070f54c5f
gh-138192: Fix Context initialization so that all subinterpreters are assigned the MISSING value. (gh-138503)
---------

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-09-04 17:19:30 +00:00
Zackery Spytz
9d6b94afe7
gh-87595: Fix the docs for mmap.size() (#138494)
Correct some parts of the docs added in 32032ee376 that weren't
written by me.
2025-09-04 17:52:24 +02:00
Raymond Hettinger
f9a40c386d
Add random_derangement recipe gh-138377 2025-09-04 10:50:29 -05:00
William Andrea
849a80ec41
Docs: Fix typo in os.fwalk() example (GH-138486) 2025-09-04 08:33:51 -04:00
Pieter Eendebak
c9cf019cf5
gh-136599: Improve long_hash() (#136600)
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-09-04 12:27:26 +00:00
Pieter Eendebak
e46d403d59
gh-132657: improve deepcopy and copy scaling on free-threading (#138429) 2025-09-04 13:20:23 +05:30
sobolevn
06f8d7aa9f
gh-138281: Remove unused topsort and bump minimal version in peg_generator (#138487) 2025-09-04 00:27:14 +01:00
Stan Ulbrych
3b4cd88563
gh-95844: Move help_url code to a help module function (#129971)
---------

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2025-09-03 21:27:12 +00:00
Adam Turner
b94ee048f3
GH-101100: Resolve reference warnings in whatsnew/3.10.rst (#138408) 2025-09-03 21:48:39 +01:00
Zachary Ware
f8d9cb1407
Fix Windows path in venv docs (GH-138476) 2025-09-03 20:15:47 +00:00
Zachary Ware
007bc5fc62
gh-72249: Correct wording of GH-101910 blurb (GH-138468)
This incidentally corrects a reST issue reported by Daniel Nylander from the Swedish translation.
2025-09-03 13:19:54 -05:00
Ken Jin
2402f84665
gh-138431: JIT Optimizer --- Fix round-tripping references for str and tuple (GH-138458)
Co-authored-by: Mark Shannon <9448417+markshannon@users.noreply.github.com>
2025-09-04 02:05:06 +08:00
sobolevn
0d1f4e1639
gh-138281: Run ruff on Tools/peg_generator (#138282)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-09-03 17:45:29 +00:00
Adam Turner
424e2ab95a
GH-101100: Resolve reference warnings in using/windows.rst (#138416) 2025-09-03 17:18:21 +01:00
Adam Turner
8bbbac8a0d
GH-101100: Resolve reference warnings in whatsnew/3.5.rst (#138412)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-09-03 15:38:05 +00:00
Petr Viktorin
cfcfbdd923
gh-135676: Reword the Operators & Delimiters section(s) (GH-137713)
Co-authored-by: Blaise Pabon <blaise@gmail.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-09-03 15:29:15 +00:00
Adam Turner
6d730b1183
GH-101100: Resolve reference warnings in whatsnew/3.6.rst (#138411)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-09-03 16:22:17 +01:00
AN Long
1ff2cbbac8
gh-137136: Suppress build warnings when build on Windows with --experimental-jit-interpreter (GH-137137) 2025-09-03 15:42:26 +01:00
Jakub Kulík
34ed03875a
gh-91214: Skip tests failing on Solaris (GH-31978) 2025-09-03 17:00:53 +03:00
Adam Turner
8cf547f4cd
GH-101100: Resolve reference warnings in extending/extending.rst (#138417) 2025-09-03 16:00:50 +03:00
Marc Mueller
8ce4f28363
Docs: Fix typo in test.support.linked_to_musl function name (#138406) 2025-09-03 14:52:13 +02:00
Serhiy Storchaka
482fd0c811
gh-60462: Fix locale.strxfrm() on Solaris (GH-138242)
It should interpret the result of wcsxfrm() as a sequence of abstract
integers, not a sequence of Unicode code points or using other encoding
scheme that does not preserve ordering.
2025-09-03 15:49:28 +03:00
Adam Turner
2985c6345f
GH-101100: Resolve reference warnings in whatsnew/3.4.rst (#138413)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-09-03 12:01:16 +00:00
Barney Gale
b19ad11027
GH-119169: Slightly speed up os.walk(topdown=True) (GH-121431)
GH-119186: Slightly speed up `os.walk(topdown=True)`

When `os.walk()` traverses into subdirectories in top-down mode, call
`os.path.join()` once to add a trailing slash, and use string concatenation
thereafter to generate child paths.
2025-09-03 13:57:01 +02:00
Adam Turner
984d928a22
GH-101100: Resolve reference warnings in whatsnew/2.7.rst (#138415)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-09-03 11:33:13 +00:00
Adorilson Bezerra
88665de120
gh-138307: Update the Ellipsis documentation (#138306)
* Doc: Change Ellipsis doc at library/constants

* Doc: Change Ellipsis doc at library/stdtypes

* Doc: Add NumPy reference into Ellipsis doc at library/stdtypes

* Doc: Add Ellipsis reference into the pass statement section at tutorial

* Doc: Update Ellipsis doc concerns assignments at library/constants

* Update Doc/library/stdtypes.rst

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>

* Doc: Fix grammar on Ellipsis docs (library/constants.rst)

Co-authored-by: Éric <merwok@netwok.org>

* Doc: Fix grammar on Ellipsis docs (library/stdtypes.rst)

Co-authored-by: Éric <merwok@netwok.org>

* Doc: Fix grammar on Ellipsis docs (library/stdtypes.rst)

Co-authored-by: Éric <merwok@netwok.org>

* Doc: Remove pretty printers reference from Ellipsis doc at library/stdtypes

* Doc: Update index concerns Ellipsis object and pass statement

* Doc: Improve Ellipsis doc at library/constants

* Doc: Improve Ellipsis doc at library/stdtypes

* Doc: Change the "..." glossary entry to mention the Ellipsis object

* Doc: Some improvements concern ellipsis into typing doc

* Minor update Doc/tutorial/controlflow.rst

Co-authored-by: Ned Batchelder <ned@nedbatchelder.com>

* Update Doc/library/constants.rst

Co-authored-by: Ned Batchelder <ned@nedbatchelder.com>

* Update Doc/library/stdtypes.rst

Co-authored-by: Ned Batchelder <ned@nedbatchelder.com>

---------

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Éric <merwok@netwok.org>
Co-authored-by: Ned Batchelder <ned@nedbatchelder.com>
2025-09-03 07:27:22 -04:00
Adam Turner
8c1ae6de11
GH-101100: Resolve reference warnings in whatsnew/3.8.rst (#138409)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-09-03 11:24:42 +00:00
Adam Turner
14e25177c6
GH-101100: Resolve reference warnings in whatsnew/3.3.rst (#138414) 2025-09-03 11:20:43 +00:00
Adam Turner
04c236bf7a
GH-123299: Copyedit 3.14 What's New: Move and consolidate Porting (#138400) 2025-09-03 14:10:12 +03:00
Cody Maloney
6dd21e9f56
gh-138013: Remove test_io load_tests namespace manipulation (#138366)
Reduce what happens in `load_tests` so that the next change,
moving the `Buffered*` tests to `test_bufferdio` is purely mechanical
movement and updating imports.

This adds two classes, one per I/O implementation, to act as dispatch to
the implementation-specific mocks as well as module members. Previously
the mappings CTestCase and PyTestCase provide were injected directly
during `load_tests`.

CTestCase and PyTestCase inherit from `unittest.TestCase` so when the
split happens default test discovery will work for the classes in
`test_bufferedio`. `test_general` keeps a manual test list for this
refactoring; some of the tests (ex. `ProtocolsTest`) aren't currently
run and fixing that + helpers to not be picked up is out of my current
scope.

CTestCase and PyTestCase have an `io` class member which points to the
implementation meaning that can be removed from individual test cases
which now inherit from them.

This code is picking up `MockRawIO` which is defined globally in the
module but these should use the mock specific to the I/O implementation
being tested.

Co-authored-by: Victor Stinner <vstinner@python.org>
2025-09-03 11:49:59 +02:00
Cody Maloney
974532e758
gh-138013: Move I/O tests to test_io (#138365)
Centralize `io` tests into the `test_io` module so they are easier to
find and work on. This will make it easier to split `test_general` which
takes 30+ seconds in a debug build on my machine.

This renames `test_bufio` to be `test_bufferedio` so that it matches
the implementation file name (`bufferedio.c`).

Validation performed:
Tests are run in parallel after change:

```bash
./python.exe -m test test_io  -uall,largefile,extralargefile -M12G -j8
```

Docstring reformat in `test_io/__init__.py` looks reasonable:

```python
>>> import test.test_io
>>> help(test.test_io)
```

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-09-03 11:37:06 +02:00
Serhiy Storchaka
7274d07607
gh-78502: Add a trackfd parameter to mmap.mmap() on Windows (GH-138238)
If trackfd is False, the file handle corresponding to fileno
will not be duplicated.
2025-09-03 11:31:34 +03:00
Serhiy Storchaka
4a33077fdb
gh-138264: Fix gcc 14 compiler warnings (GH-138265) 2025-09-03 11:26:56 +03:00
Bénédikt Tran
572df47840
gh-116946: fully implement GC protocol for _curses_panel.panel (#138333)
This commit fixes possible reference loops via `panel.set_userptr`
by implementing `tp_clear` and `tp_traverse` for panel objects.
2025-09-03 10:17:17 +02:00
Bénédikt Tran
51244ba16a
gh-116946: add Py_TPFLAGS_IMMUTABLETYPE to _random.Random (#138341) 2025-09-03 09:55:53 +02:00
Adam Turner
dd86fb4ba5
GH-101100: Resolve reference warnings in whatsnew/3.7.rst (#138410)
Resolve reference warnings in whatsnew/3.7.rst
2025-09-03 09:20:16 +03:00
Weilin Du
c22cc8fccd
gh-101100: Resolve reference warnings in library/xml.sax.handler.rst (#136612) 2025-09-03 01:35:21 +01:00
Adam Turner
98b4cd6fe9
GH-135763: AC: Use `Py_ssize_t(allow_negative=False)` (#138394) 2025-09-02 21:29:05 +01:00
Zackery Spytz
32032ee376
gh-87595: Support mmap.size() for anonymous mapping on Unix (GH-24781)
Previously, the size would be returned on Windows and an OSError would
be raised on Unix.

Also, raise ValueError instead of OSError for trackfd=False.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-09-02 23:24:06 +03:00
Jacob Coffee
e4e2390a64
Doc: Track file downloads via plausible (#138393)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-09-02 22:02:00 +03:00
Bénédikt Tran
3ff00c76c9
gh-116946: add Py_TPFLAGS_IMMUTABLETYPE to select.poll and select.epoll (#138340) 2025-09-02 17:53:44 +00:00
Brian Schubert
5493b46462
gh-138372: Fix SyntaxWarning for erroneous t-string subscription (#138375) 2025-09-02 18:13:12 +01:00
AN Long
b3e785c76c
gh-138314: Add winreg.DeleteTree (GH-138388) 2025-09-02 17:04:57 +00:00
Adam Turner
cc7ef69c86
gh-138122: Use `profiling.sampling` in the documentation (PEP 799) (#138389) 2025-09-02 17:45:00 +01:00
Pieter Eendebak
2d3711dc06
gh-136599: Add tests for long_hash (#138335)
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
2025-09-02 18:42:12 +02:00
Serhiy Storchaka
33fcb0c4a0
gh-138204: Forbid expansion of a shared anonymous mmap on Linux (GH-138220)
This is a Linux kernel bug which caused a bus error.
https://bugzilla.kernel.org/show_bug.cgi?id=8691
2025-09-02 19:00:39 +03:00
jadonduff
c19db1d2b8
gh-138004: Fix setting a thread name on OpenIndiana (GH-138017)
Encode Solaris/Illumos thread names to ASCII, since
OpenIndiana does not support non-ASCII names.

Add tests for setting non-ASCII name for the main thread.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-09-02 15:26:25 +00:00
James Parrott
8d5c3341c5
gh-138297 Point link in docs for finally to try/else, instead of if/else (#138298)
Co-authored-by: Brian Schubert <brianm.schubert@gmail.com>
Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
2025-09-02 14:56:23 +00:00
Sebastian Rittau
3f23888fd7
gh-127647: Fix and enable I/O protocol tests (#138369) 2025-09-02 06:45:29 -07:00
Sergey Miryanov
33f89106d7
gh-133158: Adjust c-analyzer max_sizes for typeobject.c (GH-133159)
This also improves the error message for when a file is too large.
2025-09-02 13:34:22 +00:00
Stan Ulbrych
0a0cbd43a7
gh-110936: Reorder string literal definition in Lexical Analysis (GH-138063) 2025-09-02 13:48:26 +02:00
Serhiy Storchaka
cb18269e1b
gh-138253: Fix compatibility of sub-interpreters queues with queue.Queue (GH-138256)
Add the block parameter in the put() and get() methods of
the concurrent.interpreters queues for compatibility with the
queue.Queue interface.
2025-09-02 08:59:20 +03:00
Gregory P. Smith
a2ba0a7552
gh-61206: Support zstandard compression in the zipimport module (GH-138254)
* gh-61206: support zstd in zipimport

* NEWS entry

* versionchanged doc
2025-09-01 17:14:23 -07:00
Christoph Walcher
47bc10e6b3
gh-135763: AC: Implement `allow_negative for Py_ssize_t` (#138150)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-09-01 22:55:22 +01:00
Andrey
7c92497e5c
gh-138360: Fix test_free_threading for IO objects (#138359)
Fix typo in test_io.py
2025-09-01 19:53:13 +00:00
Victor Stinner
aec006be97
gh-135755: Make Py_MAX_SCRIPT_PATH_SIZE private (#138350) 2025-09-01 20:01:01 +01:00
Stan Ulbrych
b3ff3165d2
gh-89905: Correct -R option doc (#137608) 2025-09-01 19:58:25 +02:00
Tapeline
ea77feecbb
gh-138302: Specialize int ops only if ints are compact (GH-138347) 2025-09-02 01:33:15 +08:00
Marc Mueller
6528cf47a0
gh-90548: Fix musl version detection with --strip-all (#137864)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-09-01 18:58:45 +02:00
Peter Bierma
4f6ecd10c2
gh-138342: Use a common utility for visiting an object's type (GH-138343)
Add `_PyObject_VisitType` in place of `tp_traverse` functions that only visit the object's type.
2025-09-01 16:20:33 +00:00
Pieter Eendebak
0d02e4d7d3
gh-116738: Fix test_json_mutating_exact_dict (#138339)
Fix test_json_mutating_exact_dic
2025-09-01 21:44:19 +05:30
Stan Ulbrych
0d383f86ee
gh-54874: Expand unicodedata module documentation (#138301)
Closes #54874

Co-authored-by: Alexander Belopolsky <abalkin@users.noreply.github.com>
2025-09-01 17:50:31 +02:00
Bénédikt Tran
c9b252c2c0
gh-116946: Revert GC protocol for immutable empty heap types (GH-138266, GH-138288, GH-138289) (#138338)
* Revert "gh-116946: fully implement GC protocol for `bz2` objects (#138266)"

This reverts commit 9be91f6a20.

* Revert "gh-116946: fully implement GC protocol for `lzma` objects (#138288)"

This reverts commit 3ea16f990f.

* Revert "gh-116946: fully implement GC protocol for `_hashlib` objects (#138289)"

This reverts commit 6f1dd9551a.
2025-09-01 21:15:11 +05:30
Jason R. Coombs
9b38c6698a
Reapply "gh-132947: Apply changes from importlib_metadata 8.7 (#137885)" (#137924) (#137930)
* Reapply "gh-132947: Apply changes from importlib_metadata 8.7 (#137885)" (#137924)

This reverts commit 3706ef66ef.

* Skip the triggering test on buildbots only.
2025-09-01 11:27:01 -04:00
Bénédikt Tran
2a54acf3c3
gh-116946: fully implement GC protocol for zlib objects (#138290) 2025-09-01 10:24:23 +02:00
Bénédikt Tran
6f1dd9551a
gh-116946: fully implement GC protocol for _hashlib objects (#138289) 2025-09-01 10:23:01 +02:00
Bénédikt Tran
3ea16f990f
gh-116946: fully implement GC protocol for lzma objects (#138288) 2025-09-01 10:22:43 +02:00
Bénédikt Tran
9be91f6a20
gh-116946: fully implement GC protocol for bz2 objects (#138266) 2025-09-01 10:21:39 +02:00
Hood Chatham
11a5fc8238
gh-138130: Fix return value of libc_ver() on Emscripten (#138132)
Emscripten's libc is a hybrid of musl and llvm libc; but it reports that it is
"glibc". This modifies the return value of `platform.libc_ver()` to return
something that is Emscripten-specific.
2025-09-01 06:50:29 +08:00
Stan Ulbrych
78acd8e95e
gh-138286: Run `ruff on Tools/i18n` (#138287)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
2025-08-31 20:29:02 +00:00
Cody Maloney
15e37ea6b7
gh-138013: Make `test.test_io` into a package (#138153) 2025-08-31 20:14:19 +01:00
Fangyi Zhou
552cf86b83
gh-138295: Fix a grammar issue in the descriptor HOWTO (GH-138296)
"an str" -> "a str"
2025-08-31 11:50:23 -04:00
chemelnucfin
7bca924fdb
gh-138279: Remove unused attr in RuleCollectorVisitor in parser_generator.py (#138280) 2025-08-31 14:23:40 +00:00
Pieter Eendebak
43573028c6
gh-116738: Make _json module thread-safe in the free-threading (#119438)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-08-31 09:42:45 +05:30
R Chintan Meher
c7a097c02e
gh-133829: Remove some specifics from the `zipimport` example (#133835)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: sobolevn <mail@sobolevn.me>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2025-08-31 01:50:56 +01:00
alm
d3d94e0ed7
gh-138061: Exclude __pycache__ directory from the computed digest in the JIT stencils (#138131)
Exclude the __pycache__ directory when generating the digest in the JIT stencils
2025-08-30 22:21:25 +01:00
Pieter Eendebak
f58a7c7175
gh-132657: avoid locks and refcounting in frozenset lookups (#136107) 2025-08-31 00:55:36 +05:30
Tommaso Bona
31d3836f26
gh-138158: Use the "data" tarfile extraction filter in Tools/ssl/multissltests.py (#138147)
The `Tools/ssl/multissltests.py` script may extract a possibly untrusted tarball.
Since the script does not necessarily use Python 3.14 or later (where the `"data"`
filter became the default `tarfile` extraction filter), the user may theoretically
suffer from a path traversal attack.

Although the script should not be used in production and usually relies on downloading
trusted sources, the `"data"` extraction filter is now explicitly used wherever relevant.
2025-08-30 12:27:32 +02:00
Ron Frederick
bacb7771fb
gh-137197: Add SSLContext.set_ciphersuites to set TLSv1.3 ciphers (#137198)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-08-30 09:32:11 +00:00
chemelnucfin
11217a883d
gh-138257: Fix internal RuleCollectorVisitor attribute name (#138208)
The internal `RuleCollectorVisitor` class had an attribute named "rulses"
instead of "rules" that other `GrammarVisitor` subclasses define.
2025-08-30 11:28:44 +02:00
Wulian233
5c6937ad20
gh-133656: Remove deprecated zipimport.zipimporter.load_module (GH-133662)
Remove deprecated `zipimport.zipimporter.load_module`.
2025-08-30 01:28:18 +00:00
Dino Viehland
e05182f98e
gh-138250: load fast optimization should fall through to empty blocks (#138249)
load fast optimization should fall through to empty blocks
2025-08-29 11:49:35 -07:00
Hang
5f7906715a
gh-123858: Improve Doc: SyntaxWarning is emitted during bytecode generation (gh-122844)
---------

Co-authored-by: Alyssa Coghlan <ncoghlan@gmail.com>
2025-08-29 23:29:59 +10:00
Stan Ulbrych
88bfe4c47b
gh-137153: Add latin_N aliases to encodings.aliases (#136701)
Closes #137153
2025-08-29 14:28:04 +02:00
Kumar Aditya
c779f2324d
gh-134861: revert "Add CSV and BSV output formats to asyncio ps" (#138187)
This reverts commit ee72c95aa9 and 470cbe97a5
2025-08-28 21:19:15 +05:30
Ju4tCode
025a2135ef
gh-137317: Fix inspect.signature() for class with wrapped __init__ or __new__ (GH-137862)
Fixed several cases where __init__, __new__ or metaclass` __call__ is a descriptor
that returns a wrapped function.
2025-08-28 17:57:53 +03:00
Sergey B Kirpichev
ef4dd1d655
gh-73487: Convert _decimal to use Argument Clinic (part 6) (GH-138015) 2025-08-28 12:36:00 +02:00
Semyon Moroz
f914e0ab09
gh-136438: Make sure test_compile pass with all optimization levels (GH-136478) 2025-08-28 11:30:15 +02:00
sobolevn
03f8d3b0db
gh-126524: Revert "gh-126524: Run regen-unicodedata as a part of our CI #126682" (#138197) 2025-08-28 10:31:44 +03:00
Brett Cannon
d910b93f78
Drop explicit tool installation in the dev container (GH-138211)
This is now handled upstream in the dev container image itself.
2025-08-27 23:41:31 +00:00
Jakub Kulík
bbcb75c986
bpo-41839: Fix error checking in sched_get_priority_ functions (GH-22374) 2025-08-27 20:41:14 +03:00
Pablo Galindo Salgado
56eb6b64a0
gh-138122: Implement PEP 799 (#138142) 2025-08-27 17:52:50 +01:00
Andreas Pelme
f733e428f8
Docs: Fix typo in shutil.make_archive example (GH-138188) 2025-08-27 11:57:37 -04:00
Serhiy Storchaka
0dbbf61cc2
gh-71679: Improve tests for repr() of bytes and bytearray (GH-138180)
* Merge existing tests test_repr_str and test_to_str.
* Add more tests for non-printable and non-ASCII bytes.
* Add tests for special escape sequences ('\t\n\r').
* Add tests for slashes.
* Add more tests for quotes.
* Add tests for subclasses.
* Add test for non-ASCII class name.
* Only apply @check_bytes_warnings for str() tests.
2025-08-27 13:24:28 +03:00
Blaise Pabon
14a5ad1db1
gh-106318: Add example for str.find() (#134529)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-08-27 09:42:00 +03:00
Taegyun Kim
ffaec6e2a1
gh-128042: Emit a `configure warning when -O0 and --enable-optimizations` are combined (#137975)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-08-27 01:00:43 +02:00
Kumar Aditya
5ae8b97f6b
enhance docs for critical sections (#137334) 2025-08-26 22:43:02 +05:30
Rani Pinchuk
fd8f42d3d1
gh-135427: Fix DeprecationWarning for os.fork when run in threads with -Werror (GH-136796)
Don't ignore errors raised by `PyErr_WarnFormat` in `warn_about_fork_with_threads`
Instead, ignore the warnings in all test code that forks. (That's a lot of functions.)

In `test_support`, make `ignore_warnings` a context manager (as well as decorator),
and add a `message` argument to it.
Also add a `ignore_fork_in_thread_deprecation_warnings` helper for the deadlock-in-fork
warning.
2025-08-26 15:33:21 +02:00
Jakub Kulík
f60f8225ed
gh-137481: Fix test_calendar on Solaris and OpenIndiana (GH-138156)
In some locales (e.g. pt_PT.UTF-8), the abbreviated weekday names
are longer than three character.
2025-08-26 14:21:09 +03:00
Krishna Chaitanya
43b113d23d
gh-138148: Fix grammatical error in the asynchronous generator iterator term (GH-138155) 2025-08-26 07:13:33 -04:00
Bénédikt Tran
1700cc4d76
gh-136565: use SHA-256 for hashlib.__doc__ example instead of MD5 (#138157) 2025-08-26 10:38:53 +00:00
Petr Viktorin
ce1a877a38
gh-138143: Allow anonymous unions in public headers, using _Py_ANONYMOUS (GH-137283)
We already use an anonymous union for PyObject. This makes the workarounds available in all public headers:

- MSVC: `__pragma(warning(disable: 4201))` (with push/pop). Warning 4201 is specifically for anonymous unions, so let's disable for all of `<Python.h>`
- GCC/clang, pedantic old C standards: define `_Py_ANONYMOUS` as `__extension__`
- otherwise, define `_Py_ANONYMOUS` as nothing 

(Note that this is only for public headers -- CPython internals use C11, which has anonymous structs/unions.)

C API WG vote: https://github.com/capi-workgroup/decisions/issues/74
2025-08-26 11:14:35 +02:00
Adam Turner
73fb155ba7
Introduce a structure for `.github/CODEOWNERS` (#137498)
Co-authored-by: Ezio Melotti <ezio.melotti@gmail.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-08-26 03:34:07 +02:00
Chris Eibl
95d6e0b283
GH-131033: Enable the optimizing macros UNLIKELY and LIKELY for Clang (GH-131019)
This includes clang-cl on Windows, which does not define the GCC version that was previously being checked.
2025-08-25 21:59:52 +01:00
PrinceNaroliya
9ee0214b5d
gh-138098: Clarify strong references in PyDict_Next docs on the free-threaded build (GH-138106) 2025-08-25 10:53:26 -04:00
Wulian233
81268a3e2a
gh-136507: Fix mimetypes CLI to handle multiple file parameters (GH-136508)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-08-25 16:38:43 +02:00
maurycy
edf6e6819b
Remove some dead code from gzip and tarfile (#138123)
The original_n variable and the writebuf and bufsize attributes were never used.
2025-08-25 16:23:47 +03:00
Stan Ulbrych
a5530656c1
gh-133390: Extend completion for .commands in sqlite3 (GH-135432) 2025-08-25 14:58:00 +02:00
Serhiy Storchaka
b8c90e72b3
gh-137609: Change names of some positional-only parameters in builtins (GH-137611)
This is for a pair with GH-137610.
2025-08-25 15:36:06 +03:00
Serhiy Storchaka
65fb4d11a0
gh-137609: Update signatures of builtins in the documentation (GH-137610)
Show signatures that match the actual signatures or future multisignatures
for all functions, classes and methods in the "builtins" module.
2025-08-25 15:28:27 +03:00
Sergey Miryanov
5baa7a0de0
gh-95245: Document Py_TPFLAGS_PREHEADER (GH-135861)
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-08-25 12:15:51 +02:00
Yongzi Li
be24ff0b57
gh-138081: Fix/remove incorrect links in idlelib/HISTORY.txt (#138091) 2025-08-24 21:48:29 -04:00
Brian Schubert
f57be7b2b3
gh-136021: Remove dead code for internal sentinel in typing (#138120)
Remove dead code for internal sentinel
2025-08-24 20:36:35 +00:00
Bénédikt Tran
96b7a2eba4
gh-135261: bring back CI job for testing OpenSSL 1.1.1w (#135262)
This partially reverts commit d83e30cadd
by bringing back the CI job for testing OpenSSL 1.1.1w. Despite this
version being upstream EOL, the rationale for keeping it as follows:

- It most resembles other 1.1.1-work-a-like ssl APIs supported by important vendors.
- Python officially requires OpenSSL 1.1.1 or later, although OpenSSL 3.0 or later
  is recommended for cryptographic modules. Since changing the build requirements
  requires a transition period, we need to keep testing the allowed versions.
- The code base still contains calls to OpenSSL functions that are deprecated since
  OpenSSL 3.0 as well as `ifdef` blocks constrained to OpenSSL 1.1.1.
2025-08-24 09:01:37 +00:00
Serhiy Storchaka
aa1dbd4dde
gh-137986: Fix and improve the csv functions docstrings (GH-137987)
The csv.register_dialect() docstring no longer imply that it returns a
dialect.
All functions have now signatures.

Co-authored-by: maurycy <5383+maurycy@users.noreply.github.com>
2025-08-24 11:13:31 +03:00
Raymond Hettinger
6fcac09401
Improve readability by adding whitespace between code paragraphs (gh-138090)
Improve readability by adding whitespace between code paragraphs.
2025-08-23 15:18:46 +00:00
Bénédikt Tran
ab1bef8ad2
gh-136134: restore truncated comment post GH-136623 (#138088)
This amends 766614f88a
where a comment has been incorrectly truncated.
2025-08-23 10:17:14 +00:00
Serhiy Storchaka
6620ef0ff6
gh-137754: Fix import of zoneinfo if _datetime is not available (GH-137845)
Both modules should use the Python implementation in that case.
2025-08-23 12:12:13 +03:00
Kentaro Jay Takahashi
282e88506b
gh-133125: Clarify ZipInfo.date_time attribute documentation (#136082)
Specifically, clarify that ZipInfo.date_time pulls the datetime information from the central directory, and that times are interpreted as local time.

Co-authored-by: Emma Smith <emma@emmatyping.dev>
2025-08-22 16:52:30 -07:00
Robin Narsingh Ranabhat
90b932e650
gh-137740: Clarify __del__ invocation mechanism in reference counting (#137741)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-08-23 00:49:55 +05:30
Krishna Chaitanya
f278afcabf
gh-91116: Add hyperlink from sys.settrace to frame objects (GH-138062) 2025-08-22 12:28:33 -04:00
Kumar Aditya
b9bcd02e9f
gh-137384: fix crash when accessing warnings state late in runtime shutdown (#138027) 2025-08-22 19:10:43 +05:30
Serhiy Storchaka
5b0f00e616
gh-135386: Skip readonly tests for the root user (GH-138058) 2025-08-22 16:22:14 +03:00
Ken Jin
8952b826a7
gh-138042: Fix homebrew for tail-calling macOS CI (GH-138043)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-08-22 20:15:40 +08:00
Bénédikt Tran
766614f88a
gh-136134: smtplib: fix CRAM-MD5 on FIPS-only environments (#136623) 2025-08-22 11:45:01 +00:00
General_K1ng
c0ae92b7c0
gh-135386: Fix "unable to open database file" errors on readonly DB (GH-135566)
Add immutable=1 flag for read-only SQLite access to avoid WAL/SHM errors on readonly DB.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-08-22 14:11:59 +03:00
Pranjal Prajapati
f27af8ba8e
gh-130425: Add "Did you mean [...]" suggestions for del obj.attr (GH-136588)
Co-authored-by: sobolevn <mail@sobolevn.me>
Co-authored-by: Ned Batchelder <ned@nedbatchelder.com>
Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2025-08-22 12:21:16 +02:00
Bénédikt Tran
4519b8acb5
gh-136134: imaplib: fix CRAM-MD5 on FIPS-only environments (#136615) 2025-08-22 12:08:55 +02:00
Bénédikt Tran
e545bae55a
gh-134531: simplify code for computing HMAC digests (#138046) 2025-08-22 09:19:04 +00:00
yihong
531fc3a7a3
gh-138019: improve help message for json.tool (#138037) 2025-08-22 08:44:25 +00:00
vict-Yang
ce70a57bc0
gh-137920: Fix semantically relevant typo in curses.window.attron (#137940) 2025-08-22 10:27:02 +02:00
Hugo van Kemenade
5a7f5ea631
gh-123299: Fix typos & grammar and copyedit What's New in 3.14 (#138040) 2025-08-22 08:33:29 +01:00
Russell Keith-Magee
2ba2287b85
gh-137973: Add a non-parallel test plan to the iOS testbed project (#138018)
Modifies the iOS testbed project to add a test plan. This simplifies the iOS
test runner, as we can now use the built-in log streaming to see test results.
It also allows for some other affordances, like providing a default LLDB config,
and using a standardized mechanism for specifying test arguments.
2025-08-22 13:11:50 +08:00
Sergey B Kirpichev
bb8791c0b7
gh-73487: Convert `_decimal` to use Argument Clinic (part 5) (#137948)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-08-21 23:12:17 +01:00
Adam Turner
79aeeb880e
GH-132775: Fix argument parsing for `_interpqueues.put()` (#137686) 2025-08-22 00:00:58 +02:00
sobolevn
ba8e20b5f2
gh-137967: Fix "Whats New" doc example (#138028) 2025-08-21 17:48:40 +00:00
Pablo Galindo Salgado
539a4ca1b9
gh-137967: Restore suggestions on nested attribute access (#137968) 2025-08-21 16:56:57 +01:00
Terry Jan Reedy
339f5da639
gh-138011: Clarify tutorial method object example code (#138014)
x must be a MyClass instance for examples to work.

---------
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2025-08-21 11:02:29 -04:00
Petr Viktorin
9f05f98730
gh-137376: Add note on top-level global declarations (GH-137707)
Co-authored-by: Brian Schubert <brianm.schubert@gmail.com>
2025-08-21 14:58:38 +02:00
Mark Shannon
a8d9d94784
GH-137959: Replace shim code in jitted code with a single trampoline function. (GH-137961) 2025-08-21 10:40:53 +01:00
Sergey B Kirpichev
c056a089d8
gh-73487: Convert `_decimal` to use Argument Clinic (part 4) (#137931)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-08-20 22:59:40 +01:00
Yüce Tekol
7dc42b67a7
gh-137884: Added threading.get_native_id() on Illumos/Solaris (GH-137927) 2025-08-20 17:10:44 +00:00
Scott Noyes
3143ceeb1d
gh-137481: Fix abbreviation of day names in TextCalendar (GH-137482)
Use the length of the longest day name in the current locale, rather
than a constant 9, to decide if the names should be abbreviated.
2025-08-20 19:55:50 +03:00
Ken Jin
7fda8b66de
gh-137728 gh-137762: Fix bugs in the JIT with many local variables (GH-137764) 2025-08-20 22:53:54 +08:00
Serhiy Storchaka
eae9d7de1c
gh-137477: Fix inspect.getblock() for generator expressions (GH-137488)
This fixes also inspect.getsourcelines() and inspect.getsource().
2025-08-20 16:18:08 +03:00
Tangyuan
7685b8ada8
gh-137900: Improve dataclasses frozen parameter documentation (#137937) 2025-08-20 09:08:45 -04:00
Serhiy Storchaka
23adbf53c5
gh-137044: To weaken the statement regarding the RLIM_INFINITY value (GH-137954) 2025-08-20 15:05:38 +03:00
Maximilian Linhoff
9b5235b62e
Fix typo in logging docs (GH-137981) 2025-08-20 07:07:32 -04:00
Itamar Oren
d22a745644
gh-137964: Remove the "experimental" designation from the Windows installer (GH-137965) 2025-08-19 22:30:59 +01:00
Steve Dower
7d06a0af17
gh-120037: Disable user site packages when a ._pth file is used (GH-137428) 2025-08-19 21:28:28 +01:00
Serhiy Storchaka
e39255e76d
Update the availability info in the resource docs (GH-137922) 2025-08-19 18:11:03 +03:00
Serhiy Storchaka
8700404f86
Update the dbm documentation (GH-137919)
Unify documentation for all backends, enumerate all not implemented mapping
methods, document particularities of implemented mapping methods.
2025-08-19 18:05:24 +03:00
Serhiy Storchaka
ac37b77441
gh-137044: Fix test_resource on 32-bit Linux (GH-137941) 2025-08-19 15:22:30 +03:00
PrinceNaroliya
379161dd51
[docs] minor, fix grammar in ssl.SSLContect.sslsocket_class docstring (GH-137935)
Fix grammar in ssl.SSLContect.sslsocket_class docstring

---------

Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
2025-08-19 12:00:39 +00:00
Petr Viktorin
719e5c3f71
gh-123681: Check NORMALIZE_CENTURY behavior at runtime; require C99 (GH-136022)
A runtime check is needed to support cross-compiling.

Remove the _Py_NORMALIZE_CENTURY macro.
Remove _pydatetime.py's _can_support_c99.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-08-19 12:59:03 +02:00
Peter Bierma
b07a267953
gh-137883: Check the recursion limit for specialized keyword argument calls (GH-137887) 2025-08-19 09:53:38 +01:00
Adam Turner
bb75dec87f
gh-95534: Convert `ZlibDecompressor.__new__` to AC (#137923) 2025-08-19 09:52:13 +01:00
Mikhail Efimov
06dd63501a
gh-136438: Make sure test_dis pass with all optimization levels (GH-136593)
Now tests pass with all combinations of -OO and --without-doc-strings.
2025-08-19 10:48:35 +02:00
Sergey B Kirpichev
9cb91305ab
gh-73487: Convert `_decimal` to use Argument Clinic (part 3) (#137844)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-08-19 09:20:06 +01:00
Serhiy Storchaka
6e2b9a2130
gh-137512: Add new constants in the resource module (GH-137513)
* RLIMIT_NTHR
* RLIMIT_THREADS
* RLIMIT_UMTXP
* RLIM_SAVED_CUR
* RLIM_SAVED_MAX

* Document RLIMIT_PIPEBUF. Other doc fixes.
2025-08-19 08:52:45 +02:00
Jason R. Coombs
3706ef66ef
Revert "gh-132947: Apply changes from importlib_metadata 8.7 (#137885)" (#137924)
This reverts commit 5292fc00f2.
2025-08-18 20:57:36 +00:00
ggqlq
8750e5ecfc
gh-134869: Fix Ctrl+C corrupts REPL autocomplete (#134929) 2025-08-18 21:54:39 +01:00
Jason R. Coombs
5292fc00f2
gh-132947: Apply changes from importlib_metadata 8.7 (#137885)
* Copied files from python/importlib_metadata@b67ac80c49.
2025-08-18 10:54:10 -07:00
Adam Turner
918e3ba6c0
GH-137623: Use an AC decorator for docstring line length enforcement (#137690) 2025-08-18 18:29:00 +01:00
Serhiy Storchaka
0324c726de
gh-137044: Make resource.RLIM_INFINITY always positive (GH-137511)
It is now a positive integer larger larger than any limited resource value.
This simplifies comparison of the resource values.
Previously, it could be negative, such as -1 or -3, depending on platform.

Deprecation warning is emitted if the old negative value is passed.
2025-08-18 19:28:56 +03:00
Bartosz Sławecki
138ed6db9f
gh-44538: Mention nested classes/functions in doctest docs (GH-137870) 2025-08-18 10:58:23 -04:00
Sergey B Kirpichev
83387e033d
gh-73487: Convert `_decimal` to use Argument Clinic (part 2) (#137637)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-08-18 14:21:00 +01:00
Kumar Aditya
1c3950abc1
gh-135862: add C contiguous one-dimensional buffer requirement to asyncio.StreamWriter docs (#137910) 2025-08-18 18:36:43 +05:30
Petr Viktorin
7dfa048bbb
gh-135228: Create __dict__ and __weakref__ descriptors for object (GH-136966)
This partially reverts #137047, keeping the tests for GC collectability of the
original class that dataclass adds `__slots__` to.
The reference leaks solved there are instead solved by having the `__dict__` &
`__weakref__` descriptors not tied to (and referencing) their class.

Instead, they're shared between all classes that need them (within
an interpreter).
The `__objclass__` ol the descriptors is set to `object`, since these
descriptors work with *any* object. (The appropriate checks were already
made in the get/set code, so the `__objclass__` check was redundant.)

The repr of these descriptors (and any others whose `__objclass__` is `object`)
now doesn't mention the objclass.

This change required adjustment of introspection code that checks
`__objclass__` to determine an object's “own” (i.e. not inherited) `__dict__`.
Third-party code that does similar introspection of the internals will also
need adjusting.


Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2025-08-18 14:25:51 +02:00
Bar Harel
92be979f64
gh-127859: Fixed documentation for call_later and call_at for early wakeup in asyncio (#137859) 2025-08-18 17:48:54 +05:30
Petr Viktorin
d8a9466e29
bpo-38735: Don't fail when importing from / with sys.pycache_prefix set (GH-30456)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-08-18 13:53:01 +02:00
Semyon Moroz
043f251154
gh-131885: Use positional-only markers for the `decimal` module (#131990) 2025-08-18 12:49:21 +01:00
Weilin Du
63fffb15f5
gh-137847: Add examples for UUIDv6-8 (#137848)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-08-18 11:24:19 +00:00
Serhiy Storchaka
0c8fecc4cf
gh-137729: Fix support for locales with @-modifiers (GH-137253) 2025-08-18 10:11:15 +03:00
Hood Chatham
bc2872445b
gh-127146: Emscripten: Add test_sample_profiler skips where needed (#137815)
Emscripten doesn't have the `socket.SO_REUSEADDR` constant; skip tests that
require that symbol to exist.
2025-08-18 07:57:15 +08:00
Christoph Walcher
8e3244d39b
Emend an error in `string.templatelib` example output (#137890) 2025-08-17 23:12:32 +01:00
Adam Turner
25b97289e4
GH-137841: Open tzdata/zones file with UTF-8 encoding (#137872) 2025-08-17 17:13:57 +01:00
Serhiy Storchaka
7636a66635
gh-135661: Fix parsing unterminated bogus comments in HTMLParser (GH-137873)
Bogus comments that start with "<![CDATA[" should not include the starting "!"
in its value.
2025-08-17 13:37:50 +03:00
Rafael Fontenelle
eac37b46d9
gh-131591: fix formatting of remote debugger docs (#137225) 2025-08-17 11:11:31 +05:30
Terry Jan Reedy
3663b2ad54
gh-137846: Add missing 'be' to profile doc. (#137856)
Insert 'be' into 'will interpreted'.
2025-08-16 10:29:47 -04:00
Victor Stinner
5c0231c27a
gh-137725: Convert faulthandler to Argument Clinic (#137726)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-08-16 15:16:04 +02:00
Kumar Aditya
038a6e3b95
gh-90483: fix docs of SubprocessTransport.get_pipe_transport (#137852) 2025-08-16 11:11:45 +00:00
Kumar Aditya
4b2dbe8e0a
gh-101359: clarify docs for asyncio.Event.clear (#137849) 2025-08-16 10:50:54 +00:00
Jason R. Coombs
ec4021c6d7
gh-120492: Sync importlib_metadata 8.2.0 (#124033)
* Sync with importlib_metadata 8.2.0

Removes deprecated behaviors, including support for `PackageMetadata.__getitem__` returning None for missing keys and Distribution subclasses not implementing abstract methods.
Prioritizes valid dists to invalid dists when retrieving by name (python/cpython/#120492). Adds SimplePath to `importlib.metadata.__all__`.

* Add blurb
2025-08-15 14:19:23 -07:00
Nick Burns
d86c2257a6
gh-92936: update http.cookies docs post GH-113663 (#137566)
* add versionchanged and example with quotes in cookie value

* update whatsnew with http.cookies change

* Update Doc/library/http.cookies.rst

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>

* Update Doc/whatsnew/3.15.rst

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>

* spelling, quote

* demonstrate json

* Update Doc/library/http.cookies.rst

Co-authored-by: Senthil Kumaran <senthil@python.org>

* Apply suggestions from code review

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>

* shorter description

---------

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Senthil Kumaran <senthil@python.org>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-08-15 13:47:46 -07:00
ggqlq
03f5519d77
gh-131178: Add tests for site command-line interface (GH-133582) 2025-08-15 14:00:43 -04:00
rimchoi
eee6589c17
gh-137777: Disband the 'Program Frameworks' chapter (#137796) 2025-08-15 18:41:09 +01:00
Pablo Galindo Salgado
4e08a9f97a
gh-137078: Fix keyword typo recognition when executed over files (#137079) 2025-08-15 15:14:13 +00:00
Adam Turner
dc53a3e52a
GH-123299: Copyedit 3.14 What's New: Removed (#137794)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-08-15 14:56:13 +00:00
Kumar Aditya
31bbea1477
gh-137808: use argument clinic for _thread.lock and _thread.RLock (#137809) 2025-08-15 13:58:10 +00:00
Chaemin-Lim
d6719c6be6
gh-137760: Update REPL constants documentation (gh-137798) 2025-08-15 22:53:15 +09:00
Adam Turner
75d20b2c67
GH-123299: Copyedit 3.14 What's New: Optimizations (#137789) 2025-08-15 11:14:45 +00:00
Jakub Stasiak
095bc775ec
Mention the "context manager" keyword in concurrent.futures documentation (#130976) 2025-08-15 15:30:22 +05:30
ROHAN WINSOR
8665769614
gh-137716: Fix double period in AttributeError message for invalid mock assertions (#137717) 2025-08-14 21:26:02 +00:00
Justin Applegate
781294019d
gh-135241: Make unpickling of booleans in protocol 0 more strict (GH-135242)
The Python pickle module looks for "00" and "01" but _pickle only looked
for 2 characters that parsed to 0 or 1, meaning some payloads like "+0" or
" 0" would lead to different results in different implementations.
2025-08-14 22:22:37 +03:00
Serhiy Storchaka
0cbbfc4621
gh-135661: Fix CDATA section parsing in HTMLParser (GH-135665)
"] ]>" and "]] >" no longer end the CDATA section.

Make CDATA section parsing  context depending.
Add private method HTMLParser._set_support_cdata() to change the context.
If called with True, "<[CDATA[" starts a CDATA section which ends with "]]>".
If called with False, "<[CDATA[" starts a bogus comments which ends with ">".
2025-08-14 18:13:22 +00:00
adam j hartz
04f8ef663b
gh-137576: Fix for Basic REPL showing incorrect code in tracebacks with PYTHONSTARTUP (#137625)
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
2025-08-14 20:58:11 +03:00
Stan Ulbrych
8b8bd3d4ad
Update link to translating in the devguide in bugs.rst (#137736) 2025-08-14 09:14:50 -07:00
Hunter Hogan
1665abadaf
gh-123299: Update What's new in Python 3.14: typos and misplaced item. (#136665)
Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
2025-08-14 16:14:33 +00:00
Konstantin Morenko
c58020ed32
gh-109975: Indicate the minimum version for PyREPL in the tutorial (#136046) 2025-08-14 16:45:12 +01:00
sobolevn
04377a1bd1
gh-133403: Run mypy on Tools/build/check_warnings.py (#137700) 2025-08-14 16:58:02 +03:00
Yoav Nir
c87b66bc7c
gh-74185: repr() of ImportError now contains attributes name and path (#136770)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
Co-authored-by: ynir3 <ynir3@bloomberg.net>
2025-08-14 15:14:00 +02:00
Serhiy Storchaka
c47ffbf1a3
gh-125854: Improve error messages for invalid category in the warnings module (GH-137750)
Include the type name if the category is a type, but not a Warning
subclass, instead of just 'type'.
2025-08-14 14:59:04 +03:00
Hugo van Kemenade
2a6888ea14
gh-137749: Python 3.14 installer is for macOS 10.15 and later (#137753) 2025-08-14 14:01:45 +03:00
Semyon Moroz
968f6e523a
gh-130821: Add type information to error messages for invalid return type (GH-130835) 2025-08-14 11:04:41 +03:00
Sachin Shah
c9d7065188
GH-137573: mark _PyOptimizer_Optimize as no inline (GH-137731)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2025-08-14 08:00:00 +00:00
Zachary Ware
7a703c8f19
gh-132339: Add support for OpenSSL 3.5 (GH-137720)
* Add OpenSSL 3.5.2 definitions to Modules/_ssl_data_35.h (moved from Modules/_ssl_data_34.h)

* Demote OpenSSL 3.1 to "old", remove it from CI

* Update all OpenSSL versions to latest patchlevel in CI config and multissltests defaults

* Add OpenSSL 3.5.2 to CI configuration and multissltests default list

* Fix a typo in the argument parser description of multissltests.py
2025-08-13 23:18:03 -05:00
Brett Cannon
14319a99e5
Use the latest dev container image perpetually (#137734)
With `Tools/wasm/wasi` now selecting the appropriate WASI SDK based on the supported version, we can now use the `latest` label of the image.
2025-08-13 14:05:08 -07:00
Thomas Grainger
f24a012350
gh-131788: make resource_tracker re-entrant safe (GH-131787)
* make resource_tracker re-entrant safe
* Update Lib/multiprocessing/resource_tracker.py
* trim trailing whitespace
* use f-string and args = [x, *y, z]
* raise self._reentrant_call_error

---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2025-08-13 20:00:23 +00:00
Sam Gross
a10152f8fd
gh-137400: Fix thread-safety issues when profiling all threads (gh-137518)
There were a few thread-safety issues when profiling or tracing all
threads via PyEval_SetProfileAllThreads or PyEval_SetTraceAllThreads:

* The loop over thread states could crash if a thread exits concurrently
  (in both the free threading and default build)
* The modification of `c_profilefunc` and `c_tracefunc` wasn't
  thread-safe on the free threading build.
2025-08-13 14:15:12 -04:00
Mark Shannon
923d68655b
Add internal doc describing the stack protection mechanism (GH137663) 2025-08-13 19:04:25 +01:00
Serhiy Storchaka
15ab45775c
gh-87281: Improve documentation for locale.setlocale() and locale.getlocale() (GH-137313)
Add a section explaining the locale name formats.
2025-08-13 20:49:33 +03:00
Dino Viehland
b78e9c05b6
gh-137681: Always initialize exception handler for new instruction (#137655)
Always initialize exception handler for new instruction
2025-08-13 08:58:26 -07:00
Jelle Zijlstra
089a324a42
gh-137226: Fix behavior of ForwardRef.evaluate with type_params (#137227)
The previous behavior was copied from earlier typing code. It works around the way
typing.get_type_hints passes its namespaces, but I don't think the behavior is logical
or correct.
2025-08-13 06:47:47 -07:00
Sergey B Kirpichev
70730ad041
gh-73487: Convert _decimal to use Argument Clinic (part 1) (#137606)
Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
2025-08-13 14:41:57 +02:00
Stan Ulbrych
9e512ae010
gh-64612: Remove error handlers list under open() (GH-137304)
This was duplicated and out-of date.
2025-08-13 12:38:30 +02:00
Serhiy Storchaka
35759fe2fa
gh-137668: Document that ord() supports also bytes and bytearray (GH-137669) 2025-08-13 12:12:16 +03:00
Petr Viktorin
639df39bf0
gh-131146: Fall back to month_name if standalone_month_names aren't distinct (GH-137674)
Some systems reportedly don't expand '%OB' and '%Ob'.
In this case (and similar theoretically possible ones, like expanding to empty
string or 'OB'), fall back to the month_name & month_abbr.
2025-08-13 07:03:05 +00:00
Adam Turner
797c2c33e1
GH-137630: Argument Clinic: Reduce use of 'as' for renaming in `_interpretersmodule.c` (#137680) 2025-08-12 23:28:38 +01:00
sobolevn
e93dca7223
gh-133403: Run mypy on Tools/build/mypy.ini changes (#137692) 2025-08-12 22:01:50 +00:00
Adam Turner
6baf552484
GH-137623: Begin enforcing docstring length in Argument Clinic (#137624) 2025-08-12 20:17:35 +00:00
RafaelWO
003bd8cc63
gh-136672: Docs: Move Enum functions and add examples (GH-136791)
* Docs: Move Enum functions and add examples

When the `Enum` functions `_add_alias_` and `_add_value_alias_` were added in de6bca9564, the documentation for them was done under `EnumType` instead of `Enum`.

This change moves them to the docs of the `Enum` class and adds an example for each function.

---------

Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
2025-08-12 12:28:27 -07:00
Sergey Miryanov
654b8d9364
GH-137562: Fix github-issue number for deallocated objects in cache bug (GH-137614) 2025-08-12 10:32:53 -07:00
Malcolm Smith
f660ec3753
gh-137242: Add Android CI job (#137186)
Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) <wk.cvs.github@sydorenko.org.ua>
2025-08-12 20:16:04 +03:00
Adam Turner
be56464c4b
GH-137630: Convert `_interpreters` to use Argument Clinic (#137631) 2025-08-12 16:23:13 +01:00
sobolevn
68a61b0f1d
gh-133403: Check generate_stdlib_module_names and check_extension_modules with mypy (#137546) 2025-08-12 18:11:18 +03:00
Hugo van Kemenade
715647a99a
gh-137288: Update 3.14 magic numbers (GH-137665) 2025-08-12 13:52:09 +02:00
Jelle Zijlstra
6859b95cff
gh-135228: When @dataclass(slots=True) replaces a dataclass, make the original class collectible (take 2) (GH-137047)
Remove the `__dict__` and `__weakref__` descriptors from the original class when creating a dataclass from it.

An interesting hack, but more localized in scope than gh-135230.

This may be a breaking change if people intentionally keep the original class around
when using `@dataclass(slots=True)`, and then use `__dict__` or `__weakref__` on the
original class.


Co-authored-by: Alyssa Coghlan <ncoghlan@gmail.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-08-12 13:16:54 +02:00
Serhiy Storchaka
027cacb67c
gh-126008: Improve docstrings for Tkinter cget and configure methods (GH-133303)
* Explain the behavior of Widget.configure() depending on arguments.
* Unify descriptions.
* Replace "resource" with "option".
2025-08-12 07:55:01 +03:00
Evan Kohilas
dd079db4b9
gh-131885: Use positional-only markers for `max() and min()` (#131868) 2025-08-12 00:29:17 +01:00
Brett Cannon
7140b99b0d
GH-137426: Remove code deprecation of importlib.abc.ResourceLoader (GH-137567)
Enough other classes in `importlib.abc` inherit from the class and the deprecation was to redirect people to `TraversableResources`. The documentation now makes it clear the class only exists for backwards compatibility.

---------

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-08-11 16:18:54 -07:00
Konstantin Baikov
0c83daaf45
gh-125897: Mark range function parameters as positional only (#125945) 2025-08-11 19:12:55 -04:00
Sam Gross
362692852f
gh-137400: Fix a crash when disabling profiling across all threads (gh-137471)
The `PyEval_SetProfileAllThreads` function and other related functions
had a race condition on `tstate->c_profilefunc` that could lead to a
crash when disable profiling or tracing on all threads while another
thread is starting to profile or trace a a call.

There are still potential crashes when threads exit concurrently with
profiling or tracing be enabled/disabled across all threads.
2025-08-11 11:41:44 -04:00
AN Long
deb0020e3d
gh-115766: Fix IPv4Interface.is_unspecified (GH-137326) 2025-08-11 15:04:47 +02:00
Sergey B Kirpichev
bc4996c125
gh-128813: cleanup C-API docs for PyComplexObject (GH-137579)
* move non-deprecated API up
* make a dedicated section for deprecated low-leved API
2025-08-11 13:51:39 +02:00
László Kiss Kollár
4497ad409e
gh-135953: Profile a module or script with sampling profiler (#136777) 2025-08-11 12:36:43 +01:00
da-woods
70218b4008
Fix documentation of hash in PyHash_FuncDef (#137595)
Because of a small typo, it wasn't showing up in the generated docs.
2025-08-11 13:18:37 +02:00
Serhiy Storchaka
1bde13b0e9
Add test for opening an SQLite with bytes path (GH-136331) 2025-08-11 09:16:54 +03:00
Malcolm Smith
b36d23f58e
Update pre-commit hooks (#137591)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-08-10 22:32:50 +00:00
Peter Bierma
55788a9096
gh-137583: Only lock the SSL context, not the SSL socket (GH-137588)
Fixes a deadlock in 3.13.6.
2025-08-10 14:47:11 +00:00
Serhiy Storchaka
046a4e39b3
gh-136571: Convert more code in datetime to Argument Clinic (GH-136573)
This adds signatures for some classes and methods.

date.fromisocalendar() can now raise OverflowError for arguments that
don't fit in the C int.
2025-08-09 18:25:49 +00:00
Mark Shannon
af15e1d13e
GH-132532: Add new DSL macros to better declare semantics of exits at ends of instructions/uops. (GH-137098) 2025-08-09 15:41:28 +01:00
Sergey Miryanov
c744b57fd6
gh-137562: Remove reference for GC_REACHABLE in comment (GH-137563)
GC_REACHABLE is obsolete
2025-08-09 21:32:45 +09:00
Alexander Nordin
3964f97489
gh-137026: Add an explainer guide for asyncio (GH-137215)
* - Add an explainer guide (aka HOWTO, not how-to) for asyncio.

* Fix linter errors.

* - Enforce max line length of roughly 79 chars.
- Start sentences on new lines to minimize disruption of diffs.

* Add reference to subinterpreters.

* - Significantly reduce article size. Remove both example sections & "Which concurrency do I want" section.

* Align section-header lengths with section names.

* - Remove reference to deleted section.

* - Fix a variety of rote style guide items like title-alignment, use of ie and $, and so forth.
- Add links to other parts of the docs for keywords and objects like await, coro, task, future, etc.

* - One last title alignment.

* - Style nit.

* - Rework a variety of I statements.

* Lint fix.

* - Firm up commentary on yield from in corotuines.

* Update language comparing await and yield from.

* - Remove await-ing Tasks and futures section

* Update Doc/howto/a-conceptual-overview-of-asyncio.rst

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>

* Update Doc/howto/a-conceptual-overview-of-asyncio.rst

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>

* - Address comments related to style & writing flow.

* per-thread event loop note.

* Add section describing coroutines roots in generators.

* Phrasing tweak.

* Use asyncio.create_task instead of asyncio.Task

* Update Doc/howto/a-conceptual-overview-of-asyncio.rst

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>

* Update Doc/howto/a-conceptual-overview-of-asyncio.rst

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>

* small phrasing.

* Update Doc/howto/a-conceptual-overview-of-asyncio.rst

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>

* phrasing nit.

* style nits

* Update Doc/howto/a-conceptual-overview-of-asyncio.rst

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>

* phrasing nit

* Fix misnaming of async generator.

* phrasing nits.

* Update Doc/howto/a-conceptual-overview-of-asyncio.rst

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>

* Update Doc/howto/a-conceptual-overview-of-asyncio.rst

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>

* consistent spacing

* Update Doc/howto/a-conceptual-overview-of-asyncio.rst

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>

* phrasing nits

* Update Doc/howto/a-conceptual-overview-of-asyncio.rst

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>

* Update Doc/howto/a-conceptual-overview-of-asyncio.rst

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>

* Update Doc/howto/a-conceptual-overview-of-asyncio.rst

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>

* Update Doc/howto/a-conceptual-overview-of-asyncio.rst

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>

* add conclusion

* nits

* - Variety of style & grammar improvements thanks to ZeroIntensity's comments.

* - Make all directives start with a 3 space indent. Then 4 thereafter.

* - Use :linenos: instead of manually writing the line numbers.

* - Fix label typo for article.

* fix label link.

* Apply suggestions from code review

Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) <wk.cvs.github@sydorenko.org.ua>
Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>

* - introduce async-sleep name

* Phrasing

* nit

* ungendered octopus

* teammates

* jobs

* rework fella to penguin

* - remove byline; add seealso

* Change ref from asyncio to use seealso block.

* Remove typehints. Fix indentation in one code example.

* Slight rephrase for clarity.

* Make references point to asyncio. Wrap some long lines.

* - Variety of style/phrasing improvements based on PR feedback.

* phrasing.

* phrasing nit.

* Apply suggestions from code review

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>

* Update Doc/howto/a-conceptual-overview-of-asyncio.rst

Co-authored-by: Carol Willing <carolcode@willingconsulting.com>

* nit

* Apply suggestions from code review

Co-authored-by: Carol Willing <carolcode@willingconsulting.com>

* fix backticks.

* nits

* nit

* add section on asyncio.run

* title change under the hood.

* modify task coro example.

* howtos article link.

* prefer await without backticks.

* phrasing tweak.

* Rework phrasing around how await tasks pauses and returns control in the await section.

* move code block to beforfe explanation in coroutine under the hood.

* phrasing.

* link to yield from.

* style nits

* nit

* - Modify language re: event-loop cycling endlessly.
- Discuss why await was designed to not yield for coros.

* - Add a note about debug=True on asyncio.run to await coro section.

* clarity nit

* - Add two other references in seealso block.

* nit

* Language simplification

* Apply suggestions from code review

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>

* nit

* grammar fix.

* fix

* worker bees

* rework event loop paragraph to significantly deemphasize queues

* remove all references to queue besides the initial analogy.

* add note about garbage collection of tasks

* add practical note re: garbage collection

* phrasing nits

* re arrange note on task gc.

* line wrap nit

* Update Doc/howto/a-conceptual-overview-of-asyncio.rst

Co-authored-by: Kumar Aditya <kumaraditya@python.org>

* link to debug mode docs.

* readd part2 prefix.

* simplify title.

* fix titles. tihnk I messed this up earlier.

* avoid idiom in title.

* fix titles once agian.

* Apply suggestions from code review

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>

* rework task gc example.

* phrasing tweak.

* tewak.

* nit

* nit

* nit

* nit

---------

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) <wk.cvs.github@sydorenko.org.ua>
Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2025-08-08 22:29:51 -07:00
Nick Burns
d7dbde8958
gh-92936: allow double quote in cookie values (#113663)
* allow double quote in cookie values
* Update Lib/test/test_http_cookies.py

Co-authored-by: Senthil Kumaran <senthil@python.org>
2025-08-08 12:07:15 -07:00
Douglas Thor
34d7351ac7
gh-133722: Add Difflib theme to _colorize and 'color' option to difflib.unified_diff (#133725) 2025-08-08 18:34:02 +03:00
Tom Forbes
64ee1babfb
Replace "ordered arguments" with "positional arguments" in unittest.mock documentation (GH-137552) 2025-08-08 14:00:18 +00:00
Sergey B Kirpichev
9743d069bd
gh-128813: deprecate cval field of the PyComplexObject struct (#137271)
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-08-08 10:36:42 +00:00
sobolevn
fb1cb00030
Bump mypy to 1.17.1 (#137542) 2025-08-08 10:14:51 +03:00
Adorilson Bezerra
f06fcb7f4b
[Doc] Remove unnecessary quotes from typing module (#137207)
* gh-106320: Remove private _PyInterpreterState functions (#106335)

Remove private _PyThreadState and _PyInterpreterState C API
functions: move them to the internal C API (pycore_pystate.h and
pycore_interp.h). Don't export most of these functions anymore, but
still export functions used by tests.

Remove _PyThreadState_Prealloc() and _PyThreadState_Init() from the C
API, but keep it in the stable API.

* Doc: minor change

* Revert "Doc: minor change"

This reverts commit ebfa0937c2.

* [Doc] Remove unnecessary quotes from typing (See Also section)

* [Doc] Remove unnecessary quotes from typing

---------

Co-authored-by: Victor Stinner <vstinner@python.org>
2025-08-07 19:04:59 -07:00
Adam Turner
b4a1974aa2
GH-136155: Fail the EPUB check on fatal errors (#137351) 2025-08-08 02:32:20 +01:00
Sergey Miryanov
25518f51dc
GH-135552: Add tests to check weakref clearing (GH-136304)
These are tests to ensure behaviour introduced by GH-136189 is working as expected.

Co-authored-by: Mikhail Borisov <43937008+fxeqxmulfx@users.noreply.github.com>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Co-authored-by: Neil Schemenauer <nas-github@arctrix.com>
2025-08-07 17:45:33 -07:00
Sergey B Kirpichev
37b5a0d671
gh-130102: drop "require numeric arguments" from pow() docs (#137456)
Co-authored-by: Senthil Kumaran <senthil@python.org>
2025-08-07 23:43:18 +00:00
Neil Schemenauer
350c58ba4e
GH-135552: Make the GC clear weakrefs later (GH-136189)
Fix a bug caused by the garbage collector clearing weakrefs too early.  The
weakrefs in the ``tp_subclasses`` dictionary are needed in order to correctly
invalidate type caches (for example, by calling ``PyType_Modified()``).
Clearing weakrefs before calling finalizers causes the caches to not be
correctly invalidated.  That can cause crashes since the caches can refer to
invalid objects.  Defer the clearing of weakrefs without callbacks until after
finalizers are executed.
2025-08-07 16:32:17 -07:00
Bénédikt Tran
deb385a143
gh-137412: fix default_builtin_hashes values in test_hashlib.py (#137413)
fix `default_builtin_hashes` in test_hashlib
2025-08-07 15:31:56 -07:00
Dino Viehland
375f484f97
gh-137291: Support perf profiler with an evaluation hook (#137292)
Support perf profiler with an evaluation hook
2025-08-07 14:54:12 -07:00
Abhinav Upadhyay
e3ad9003c5
GH-119085: Move comment in Python/gc.c to correct place.
In GH-116206, the comment about moving reachable objects to next generation
got moved from its original place to a place where there is no code below
it. Put the comment back to where the actual movement of reachable objects
happens.
2025-08-07 20:31:11 +00:00
Sebastien Williams-Wynn
244c7b8c4c
gh-137526: Fix broken link to drdobbs journal in difflib.rst (#137527) 2025-08-07 12:36:05 -07:00
Ee Durbin
d0f4e76de0
add floss.fund manifest provenance (#137529)
ref: https://fundingjson.org/#wellknown
2025-08-07 15:35:39 -04:00
maurycy
db8742e2b4
Remove redundant assignment in asyncio.streams.StreamReaderProtocol.connection_lost() (GH-137524)
The _stream_writer attribute was removed in a355f60 (gh-114914).
2025-08-07 18:38:14 +03:00
Peter Bierma
082f370cdd
gh-137514: Add a free-threading wrapper for mutexes (GH-137515)
Add `FT_MUTEX_LOCK`/`FT_MUTEX_UNLOCK`, which call `PyMutex_Lock` and `PyMutex_Unlock` on the free-threaded build, and no-op otherwise.
2025-08-07 11:24:50 -04:00
Nice Zombies
dec624e0af
gh-135336: Add fast path to json string encoding (#133239)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-08-07 15:21:56 +00:00
Bartosz Sławecki
7ab68cd506
gh-137440: Update comment in Python/hamt.c on importing for testing (GH-137441)
Switch from `_testcapi` to `_testinternalcapi`.
2025-08-07 09:50:49 -04:00
Serhiy Storchaka
baefaa6cba
gh-137044: Support large limit values in getrlimit() and setrlimit() (GH-137338)
* Return large limit values as positive integers instead of negative integers
  in resource.getrlimit().
* Accept large values and reject negative values (except RLIM_INFINITY)
  for limits in resource.setrlimit().
2025-08-07 11:06:37 +03:00
Guilherme Leobas
5be872350d
gh-137463: Update validate_abstract_methods in test_collections.py (#137464)
Update `validate_abstract_methods` in `test_collections.py`

The test for missing abstract methods in `validate_abstract_methods` incorrectly attempted to instantiate the generated class `C` with an argument (`C(name)`), which always raises a `TypeError: C() takes no arguments`. Although the test originally passes, it passes for the wrong reason.

This change makes the test correctly validate the enforcement of abstract methods in ABCs.
2025-08-07 09:10:56 +03:00
tobiasjcat
3c1471d971
gh-137499: Fixed dead link to NIST website (#137500) 2025-08-07 08:41:16 +03:00
Isuru Fernando
3000594e92
gh-84683: Check <prefix>/share/zoneinfo for zoneinfo files on Windows (GH-28495) 2025-08-06 23:05:41 +01:00
Greg Stein
c653fba016
Docs: Small clarity change for `except*` (#121073)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-08-06 21:58:24 +00:00
Mendel Feygelson
37b9a5df93
Docs: Use the correct example module in warnings.rst (#137402) 2025-08-06 22:51:59 +01:00
Daniele Parmeggiani
ee72c95aa9
gh-134861: Add 🍌SV output format to `python -m asyncio ps` (#137486)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-08-06 20:42:34 +00:00
Daniele Parmeggiani
470cbe97a5
gh-134861: Add CSV output format to `python -m asyncio ps` (#134862)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-08-06 20:10:40 +00:00
Brett Cannon
0953200b13
GH-137484: Have Tools/wasm/wasi use the build triple instead of "build" (GH-37485)
This should help prevent issuse where something like a container is used to do one build and then someone tries to build again locally.
2025-08-06 12:28:54 -07:00
Adam Turner
ffb5a5372d
Further CODEOWNERS listings for Adam Turner (#137483) 2025-08-06 19:53:08 +01:00
Barney Gale
f0a3c6ebc9
GH-137466: Remove deprecated and undocumented glob.glob0() and glob1() (#137467) 2025-08-06 17:13:58 +01:00
Alexander Urieles
481d5b5455
gh-75989: TarFile.extractall and TarFile.extract now overwrite symlinks when extracting hardlinks (GH-137316) 2025-08-06 14:59:22 +02:00
Victor Stinner
ce1b747ff6
gh-58124: Avoid CP_UTF8 in UnicodeDecodeError (#137415)
Fix name of the Python encoding in Unicode errors of the code page
codec: use "cp65000" and "cp65001" instead of "CP_UTF7" and "CP_UTF8"
which are not valid Python code names.
2025-08-06 14:35:27 +02:00
Victor Stinner
c17f378c0e
Use PyInitConfig API in _freeze_module.c (#137423) 2025-08-06 14:34:56 +02:00
Victor Stinner
3a79a12262
Use PyConfig_Get() in frozenmain.c (#137421)
Replace private _Py_GetConfig() with public PyConfig_Get().

Remove also explicit PyRuntime initialization, it's not needed.
2025-08-06 14:33:28 +02:00
Ned Deily
781eb1a688
gh-137450: macOS installer shell path management improvements (#137451)
Separate the installer `Shell profile updater` postinstall script from the `Update Shell Profile.command` to enable more robust error handling.
2025-08-06 07:21:30 -04:00
Erlend E. Aasland
247dab27fd
gh-133390: Amend gh-135659 (sqlite3 docs update) (#137447)
* gh-133390: Amend gh-135659 (sqlite3 docs update)
2025-08-06 10:47:18 +02:00
Furkan Onder
54a5fdffc8
gh-137056: Fix DTrace build support on NetBSD (GH-137057) 2025-08-06 10:19:56 +03:00
Sina Zel taat
c2428ca9ea
gh-136823: Update documentation on excluded headers in Python.h (#136824)
Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
2025-08-05 20:52:33 +00:00
Gregory P. Smith
532c37695d
gh-137134: Update SQLite to 3.50.4 for binary releases (GH-137135)
* Update SQLite to 3.50.3 for binary releases.
* macOS and Windows news entries. what about Android?
* update sbom hash
* newline fix via regen-sbom
* news wording
* Update SQLite to 3.50.4 for binary releases.
* update 3.50.4.0.tar.gz hash in sbom & regen-sbom to fix whitespace
* Postpone to a separate PR the build-installer changes to support additional hash types

Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Ned Deily <nad@python.org>
2025-08-05 13:50:51 -07:00
Ned Batchelder
44ff6b5451
Docs: add dunder and walrus to the glossary (#137430) 2025-08-05 16:30:38 -04:00
Adam Turner
39bd7c3156
GH-136155: Use `sphinxext-opengraph` v0.12.0 (#137393) 2025-08-05 21:14:31 +01:00
Zachary Ware
9745976ac6
Fix buildbot release status link in CONTRIBUTING.rst (GH-137429)
The existing link works, but includes the legacy `/all` part of the path
which causes a scary-looking banner about a misconfiguration on the
`Home` page when in reality it's the link that includes a deprecated path.
2025-08-05 19:44:27 +00:00
Irit Katriel
1f2026b8a2
gh-137288: Fix bug where boolean expressions are not associated with the correct exception handler (#137310) 2025-08-05 19:25:57 +01:00
Stan Ulbrych
525784aa65
gh-123441: Correct the supported languages of the iso-8859-4 codec (GH-137034) 2025-08-05 17:55:05 +03:00
Sam Gross
485b16b4f7
gh-137238: Fix data race in _Py_slot_tp_getattr_hook (gh-137240)
Replacing the slot isn't thread-safe if the GIL is disabled. Don't
require that the slot has been replaced when specializing.
2025-08-05 09:32:22 -04:00
naweiss
a50822ff94
gh-107545: Fix misleading setsockopt() error messages (GH-107546) 2025-08-05 10:16:14 +00:00
Furkan Onder
7f416c8674
gh-137397: Skip test_os_open on NetBSD due to indefinite hang (#137398) 2025-08-05 10:32:21 +02:00
Bénédikt Tran
0af7556b94
gh-136306: fix test_ssl.ContextTests.test_set_groups on FIPS builds (#137405)
X25519 is not a valid curve if OpenSSL is built with FIPS mode,
and ignoring unknown groups in `SSL_CTX_set1_groups_list()`
is only supported since OpenSSL 3.3, so we use two curves that
are known to be FIPS-compliant, namely P-256 and P-384.
2025-08-05 07:50:34 +00:00
markmcclain
001461a292
gh-137390: Add missing line continuation character in configure.ac (#137391) 2025-08-04 23:08:26 +01:00
Adam Turner
4dae9b1ff1
gh-132661: PEP 750 documentation: second pass (#137020) 2025-08-04 22:45:51 +01:00
alexey semenyuk
c5cebe1b5a
gh-137128: Remove outdated todo about coro_fns in asyncio (#137385) 2025-08-04 16:44:29 +00:00
Victor Stinner
08ce7c6958
gh-129033: Remove dead code in test.support.has_no_debug_ranges() (#137379) 2025-08-04 16:48:24 +02:00
Peter Bierma
e8251dc0ae
gh-134170: Add colorization to unraisable exceptions (#134183)
Default implementation of sys.unraisablehook() now uses traceback._print_exception_bltin() to print exceptions with colorized text.

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-08-04 14:35:00 +00:00
Petr Viktorin
8943bb722f
gh-136520: Clarify docs for _pack_ & _align_ (GH-137036)
Move docs to the reference section & reduce the “tutorial” part to a quick intro & link.

Clarify what values are accepted.

Add macro/attribute equivalents.

Discourage _align_ values that aren't powers of two.
2025-08-04 15:40:42 +02:00
Sergey B Kirpichev
4dd85b347f
gh-137368: document __index__() support for PyLong_AsInt32/64() (GH-137369) 2025-08-04 15:30:29 +02:00
Alex Waygood
a46ed665ff
Remove Alex Waygood as a codeowner for pre-commit config (#137372) 2025-08-04 13:29:14 +03:00
Alexander Urieles
3ec3d05345
gh-81325: Support path-like objects with streaming TarFile (#137188)
Co-authored-by: Emma Smith <emma@emmatyping.dev>
2025-08-03 19:53:01 -07:00
Sergey B Kirpichev
b266fbc9ec
gh-122450: Expand documentation for `Rational and Fraction` (#136800)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-08-04 02:15:59 +00:00
Richard Si
506542b596
gh-137257: Upgrade bundled pip to 25.2 (GH-137258) 2025-08-03 22:00:17 -04:00
Rogdham
57eab1b8f7
gh-132983: Use `Py_UNREACHABLE in _zstd_load_impl()` (#137320) 2025-08-04 02:36:12 +01:00
Kliment Lamonov
406dc714f6
gh-136567: Add information about lost prefixes to Tools/cases_generator/interpreter_definition.md (#136780) 2025-08-03 21:43:13 +03:00
Adam Turner
13e21b2fd6
GH-136155: Use `sphinxext-opengraph` v0.11.0 (#137348) 2025-08-03 19:32:46 +01:00
Serhiy Storchaka
1612dcbafe
gh-137341: Remove more word duplications (GH-137342) 2025-08-03 19:41:12 +03:00
Pablo Galindo Salgado
0153d82a5a
gh-137314: Fix incorrect treatment of format specs in raw fstrings (#137328) 2025-08-03 17:10:51 +01:00
Rogdham
676748d4da
gh-132983: Fix docstrings in `ZstdDict` (#137321)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-08-03 15:04:45 +00:00
sobolevn
158b28dd19
gh-137191: Fix how type parameters are collected from Protocol and Generic bases with parameters (#137281) 2025-08-03 10:40:55 +03:00
Mark Shannon
801cf3fcdd
GH-137276: Don't mark uop as escaping if the escaping call is on an exit branch (GH-137277) 2025-08-02 16:49:34 +01:00
Maciej Olko
7475887e1e
Remove incorrect feature coverage comment from msgfmt script's docstring (#112862)
Remove feature coverage comment from msgfmt script's docstring

msgfmt handles plural forms since cb081b83.

The comment was incorrectly applied in 637a33b -- original patch was from before the cb081b83 commit.

Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
2025-08-02 16:37:25 +02:00
Inada Naoki
f195c28030
Doc: remove unused images (#137323) 2025-08-02 15:32:18 +01:00
sobolevn
b74f3bed51
gh-137308: Replace a single docstring with pass in -OO mode (#137318)
This is required so we would never have empty node bodies.
Refs #130087
2025-08-02 11:57:01 +00:00
Bénédikt Tran
fe0e921817
gh-131876: Revert "gh-131876: extract _hashlib helpers into a separate directory (#136995) (#137307)
Revert "gh-131876: extract `_hashlib` helpers into a separate directory (#136995)"

This reverts commit 45138d3584.
2025-08-01 10:45:40 -07:00
Mark Shannon
e7b55f564d
GH-136410: Faster side exits by using a cold exit stub (GH-136411) 2025-08-01 16:26:07 +01:00
Serhiy Storchaka
718e0c89ba
gh-137273: Fix debug assertion failure in locale.setlocale() on Windows (GH-137300)
It happened when there were at least 16 characters after dot in the
locale name.
2025-08-01 17:43:53 +03:00
Kumar Aditya
e99bc7fd44
gh-133467: fix data race in type_set_name (#137302)
Fix data race in `type_set_name` by assigning name under stop the world pause making it thread safe in free-threading.
2025-08-01 13:40:40 +00:00
Sergey B Kirpichev
9ced5c4ace
gh-128813: soft-deprecate _Py_c_*() functions (GH-137261) 2025-08-01 09:40:12 +02:00
Henry Schreiner
2a87af062b
gh-137282: Fix TypeError in tab completion and dir() of concurrent.futures (GH-137214)
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
2025-07-31 16:17:27 +00:00
Xuanteng Huang
d18f73ae13
gh-137200: support frame lineno setter with BRANCH_LEFT and BRANCH_RIGHT events (GH-137229) 2025-07-31 14:22:22 +01:00
Dzmitry Plashchynski
438cbd857a
gh-131146: Fix month names in a "standalone form" in calendar module (GH-131147)
The calendar module displays month names in some locales using the genitive case.
This is grammatically incorrect, as the nominative case should be used when the month
is named by itself. To address this issue, this change introduces new lists
`standalone_month_name` and `standalone_month_abbr` that contain month names in
the nominative case -- or more generally, in the form that should be used to
name the month itself, rather than form a date.

The module now uses the `%OB` format specifier to get month names in this form
where available.
2025-07-31 14:06:33 +02:00
Jeong, YunWon
0282eef880
gh-137194: Fix requires_debug_ranges when _testcpi doesn't exist (GH-137195) 2025-07-31 14:22:11 +03:00
Krzysztof Magusiak
b723c8be07
gh-124503: Optimize ast.literal_eval() for small input (GH-137010)
The implementation does not create anymore local functions which reduces
the overhead for small inputs. Some other calls are inlined into a
single `_convert_literal` function.
We have a gain of 10-20% for small inputs and only 1-2% for bigger
inputs.
2025-07-31 12:55:00 +03:00
adam j hartz
d5191ba99b
gh-137025: Include `python.worker.mjs` in the Emscripten Web Example (#137236) 2025-07-31 09:19:52 +01:00
Victorien
5e2f0b976a
gh-119180: Refer to annotationlib.get_annotations() in typing.get_type_hints() documentation (#137247) 2025-07-30 20:21:56 -07:00
Brandt Bucher
d591b5effb
GH-134291: Support older macOS deployment targets for JIT builds (GH-137211) 2025-07-30 15:48:18 -07:00
Stan Ulbrych
5f35f9b8fa
gh-137239: Add *_max functions to heapq.__all__ (gh-137241) 2025-07-30 16:12:14 -05:00
Raymond Hettinger
dc05d475c1
Add example of min-heap and max-heap working together (gh-137251) 2025-07-30 15:53:33 -05:00
Brett Cannon
94498a53f3
GH-137248: Add a --logdir option to Tools/wasm/wasi (GH-137249) 2025-07-30 19:13:37 +00:00
Brett Cannon
2f1a9f2ed4
GH-137243: Have Tools/wasm/wasi detect WASI SDK installs in /opt when the release tarball is extracted (GH-137244) 2025-07-30 11:46:24 -07:00
Justin Bronder
e3ea861351
gh-135444: fix asyncio.DatagramTransport.sendto to account for datagram header size when data cannot be sent (#135445)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-07-30 23:41:28 +05:30
Serhiy Storchaka
9d3b53c47f
gh-71189: Support all-but-last mode in os.path.realpath() (GH-117562) 2025-07-30 10:19:19 +03:00
Neil Schemenauer
5236b0281b
GH-116738: document thread-safety of bisect (GH-136555) 2025-07-30 02:44:10 +00:00
Sam Gross
98d462cf4d
gh-137179: Fix flaky test_history_survive_crash test (gh-137180)
Kill the REPL subprocess once it prints the output from the command
immediately before the `time.sleep()`.
2025-07-29 14:25:50 -04:00
Akuli
0b4e13c265
gh-137183: Document that array.array typecode w is new in 3.13 (GH-137184) 2025-07-29 17:23:44 +02:00
Sam Gross
11a8652e25
gh-137185: Fix _Py_DumpStack() async signal safety (gh-137187)
Call backtrace() once when installing the signal handler to ensure that
libgcc is dynamically loaded outside the signal handler.

This fixes a "signal-unsafe call inside of a signal" TSan error from
test_faulthandler.test_enable_fd.
2025-07-29 14:25:32 +00:00
Hood Chatham
d7e12a362a
Add a What's New entry for Emscripten (#137035)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2025-07-29 01:42:07 +01:00
Jelle Zijlstra
11503211c6
gh-136843: Document how multiple inheritance works (#136844)
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Akuli <akuviljanen17@gmail.com>
2025-07-28 12:35:40 -07:00
AN Long
d53199101c
gh-136586: Improve winreg's module docstring (GH-136587) 2025-07-28 20:19:01 +01:00
Ron Frederick
377b787618
gh-136306: Add support for getting and setting SSL groups (#136307)
Add support for getting and setting groups used for key agreement.

* `ssl.SSLSocket.group()` returns the name of the group used
  for the key agreement of the current session establishment.
  This feature requires Python to be built with OpenSSL 3.2 or later.

* `ssl.SSLContext.get_groups()` returns the list of names of groups
  that are compatible with the TLS version of the current context.
  This feature requires Python to be built with OpenSSL 3.5 or later.

* `ssl.SSLContext.set_groups()` sets the groups allowed for key agreement
  for sockets created with this context. This feature is always supported.
2025-07-28 19:33:31 +02:00
Chris Eibl
59e2330cf3
GH-131296: Fixes clang-cl warning on Windows in socketmodule.h (GH-131832) 2025-07-28 17:52:07 +01:00
Kumar Aditya
cbe6ebe15b
gh-134043: use stackrefs for dict lookup in _PyObject_GetMethodStackRef (#136412)
Co-authored-by: Sam Gross <colesbury@gmail.com>
2025-07-28 22:04:57 +05:30
R. David Murray
1e9b8f2f85
gh-131338: Disable computed stack limit checks on non-glibc linux (#134336)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-07-28 22:02:34 +05:30
Alexander Urieles
7040aa54f1
gh-130577: tarfile now validates archives to ensure member offsets are non-negative (GH-137027)
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2025-07-28 08:37:26 -07:00
AN Long
1481384141
gh-119711: describe create_datagram_endpoint's behavior in asyncio when local_addr is None (#136913) 2025-07-28 16:25:59 +05:30
Bénédikt Tran
45138d3584
gh-131876: extract _hashlib helpers into a separate directory (#136995)
The `Modules/hashlib.h` helper file is now removed and split into multiple files:

* `Modules/_hashlib/hashlib_buffer.[ch]` -- Utilities for getting a buffer view and handling buffer inputs.
* `Modules/_hashlib/hashlib_fetch.h` -- Utilities used when fetching a message digest from a digest-like identifier.
  Currently, this file only contains common error messages as the fetching API is not yet implemented.
* `Modules/_hashlib/hashlib_mutex.h` -- Utilities for managing the lock on cryptographic hash objects.
2025-07-28 11:28:48 +02:00
Bénédikt Tran
eefd70f0ed
gh-136968: fortify macro usage in cryptographic modules (#136973)
Macros used in cryptographic extension modules are partially rewritten
to use `static inline` functions when possible to help code completion.
2025-07-28 07:36:15 +00:00
Duprat
4e40f2bea7
gh-132898: Add a note in multiprocessing.Process docs about creating a process in a REPL (GH-137118)
* Reword, expand, and clarify the limitation, highlighting the REPL case.
* Mention in the high level Process description.
* added a pointer to the GH issue from the doc note

---------

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2025-07-27 12:59:08 -07:00
Toshaksha
6784ef7da7
gh-136278: Document codecs.escape_encode() and codecs.escape_decode() (#136314)
Closes #136278
2025-07-27 16:37:52 +00:00
Barney Gale
2bd4ff0700
GH-128520: pathlib ABCs: tweak protocol for virtual path strings (#134104)
Adjust `pathlib._os.vfspath()` so that it doesn't try `os.fsdecode()`. I
don't know that supporting `os.PathLike` arguments is a good idea, so
it's best to leave it out for now.
2025-07-27 12:47:15 +01:00
Barney Gale
10a925c86d
GH-137059: url2pathname(): fix support for drive letter in netloc (#137060)
Support file URLs like `file://c:/foo` in `urllib.request.url2pathname()`
on Windows. This restores behaviour from 3.13.
2025-07-27 11:44:41 +00:00
Iqra Khan
ae8b7d7100
gh-136992: Add "None" as valid SameSite value as per RFC 6265bis (#137040)
The "SameSite" attribute defined in RFC 6265bis [1] allows the "Strict", "Lax" and "None"
enforcement modes. We already documented "Strict" and "Lax" as being valid values
but "None" was missing from the list. While the RFC has not been formally approved,
modern browsers support the "None" value [2, 3] thereby making sense to document it.

[1]: https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis
[2]: https://developers.google.com/search/blog/2020/01/get-ready-for-new-samesitenone-secure
[3]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Set-Cookie#none

---------

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-07-27 10:27:08 +02:00
Abdul
cfd6da849a
gh-137058: Update C23 standard version check in pyport.h (#137127)
Use `__STDC_VERSION__ >= 202311L` instead of `__STDC_VERSION__ > 201710L`.
2025-07-27 09:47:21 +02:00
ryan-duve
9cbf46d992
Link to plaintext for "show source" links (#137131) 2025-07-27 02:48:56 +01:00
Pablo Galindo Salgado
a852c7bdd4
gh-131038: Use text=True in subprocesses in test_perf_profiler (#137117) 2025-07-26 18:01:51 +01:00
Stephen Morton
d5fa437dfb
gh-126662: naming consistency for signal.ItimerError (#126712) 2025-07-26 22:14:12 +05:30
Bénédikt Tran
d658b9053b
gh-136912: fix handling of OverflowError in hmac.digest (#136917)
The OpenSSL and HACL* implementations of HMAC single-shot
digest computation reject keys whose length exceeds `INT_MAX`
and `UINT32_MAX` respectively. The OpenSSL implementation
also rejects messages whose length exceed `INT_MAX`.

Using such keys in `hmac.digest` previously raised an `OverflowError`
which was propagated to the caller. This commit mitigates this case by
making `hmac.digest` fall back to HMAC's pure Python implementation
which accepts arbitrary large keys or messages.

This change only affects the top-level entrypoint `hmac.digest`, leaving
`_hashopenssl.hmac_digest` and `_hmac.compute_digest` untouched.
2025-07-26 08:22:06 +00:00
Savannah Bailey
f7c380ef67
GH-132732: Use pure op machinery to optimize COMPARE_OP_INT/FLOAT/STR (#137062)
Co-authored-by: Ken Jin <kenjin4096@gmail.com>
2025-07-25 19:02:04 -07:00
soolabettu
1e69cd1634
gh-137090: Remove redundant statement in `Doc/library/concurrent.interpreters.rst` (#137091)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-07-25 16:50:53 +01:00
Peter Bierma
e047a35b23
gh-134698: Hold a lock when the thread state is detached in ssl (GH-134724)
Lock when the thread state is detached.

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2025-07-25 08:16:05 -07:00
Tyler Kennedy
cb93b6fc5e
gh-130522: Fix unraisable TypeError in threading at interpreter shutdown (#131537)
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-07-25 14:51:30 +00:00
Bénédikt Tran
7ce2f101c4
gh-136929: ensure that hashlib.<name> does not raise AttributeError (#136933)
Previously, if OpenSSL was not present and built-in cryptographic extension modules
were disabled, requesting `hashlib.<name>` raised `AttributeError` and an ERROR log
message with the exception traceback is emitted when importing `hashlib`. 

Now, the named constructor function will always be available but raises a `ValueError`
at runtime indicating that the algorithm is not supported. The log message has also
been reworded to be less verbose.
2025-07-25 14:49:09 +00:00
Raymond Hettinger
ea06ae5b5e
Fix Queue.shutdown docs for condition to unblock a join (gh-137088) 2025-07-25 07:56:28 -06:00
Sergey Miryanov
d7db0ee7ee
gh-137084: remove multiple calls to get_gc_state in gc.c (#137085) 2025-07-25 18:13:54 +05:30
Peter Bierma
9b451fb457
gh-137093: Fix race condition in test_embed.test_bpo20891 (GH-137094)
Use a `PyEvent` instead of a lock to fix a race on the free-threaded build.
2025-07-25 08:33:18 -04:00
Denis Laxalde
fece15d29f
gh-136914: Fix support of cached functions and properties in DocTest's lineno computation (GH-136930)
Previously, DocTest's lineno of functions and methods decorated with
functools.cache(), functools.lru_cache() and functools.cached_property()
was not properly returned (None was returned) because the
computation relied on inspect.isfunction() which does not consider the
decorated result as a function.

We now use the more generic inspect.isroutine(), as elsewhere
in doctest's logic.

Also, added a special case for functools.cached_property().
2025-07-25 12:46:12 +03:00
Zachary Ware
d5e75c0768
Exclude _testclinic_depr.c.h from c-analyzer (GH-137086)
_testclinic.c mocks out PY_VERSION_HEX to 3.8 before including
_testclinic_depr.c.h to avoid the errors the preprocessor would
otherwise throw due to the deprecation feature it is testing.

Also partially revert 74e2acddf6:
this restores Modules/_testclinic.c to match the same file in the 3.14
branch.
2025-07-24 15:50:01 -05:00
Kumar Aditya
9a6b60af40
gh-136870: fix data races in instrumentation of bytecode (#136994)
De-instrumenting code objects modifies the thread local bytecode for all threads as such, holding the critical section on the code object is not sufficient and leads to data races. Now, the de-instrumentation is now performed under a stop the world pause as such no thread races with executing the thread local bytecode while it is being de-instrumented.
2025-07-24 17:58:46 +00:00
Raymond Hettinger
245671555b
Fix docs for Queue.shutdown (gh-137028) 2025-07-24 11:23:03 -06:00
Kumar Aditya
d8fa40b08d
gh-132551: add missing critical sections on BytesIO methods (#137073) 2025-07-24 11:57:48 +00:00
Sergey Miryanov
e93c30d466
gh-137054: remove obsolete counting of objects in young generation under Py_STATS builds (#137055) 2025-07-24 17:00:27 +05:30
AN Long
ec02db5caa
gh-136759: rename lock.h to pylock.h (#137041)
Rename `lock.h` to `pylock.h` to avoid conflicts with headers of other projects.
2025-07-24 16:16:07 +05:30
Hood Chatham
ae4d27eba7
gh-124621: Emscripten: Add smoke test for using pyrepl in Chrome (#137004)
Adds a mechanism to test browser-based initialisation of the Python interpreter,
via a Playwright headless browser instance.
2025-07-24 14:44:02 +08:00
Hood Chatham
ecb3f23b94
gh-136976: Emscripten: Add _decimal and libmpdec (#136997)
Adds tooling to build mpdec (and thus _decimal) as part of an Emscripten build.
2025-07-24 06:31:30 +00:00
FredericDT
dc27218225
gh-136980: Remove unused C tracing code in bdb (#136981) 2025-07-24 09:58:54 +09:00
Brett Cannon
ec7fad79d2
Touch up Setup.local handling in Tools/wasm/wasi (GH-137051)
The comment in the generated file is now more self-explanatory. The checks for unexpected file contents are also strengthened.
2025-07-23 11:50:15 -07:00
Rogdham
a10235ea67
gh-132983: Add missing references to Zstandard in shutil docstrings (GH-136617)
Zstd references in shutil docstrings
2025-07-23 18:09:53 +00:00
Petr Viktorin
777159fa31
gh-135676: Lexical analysis: Reword String literals and related sections (GH-135942)
Co-authored-by: Blaise Pabon <blaise@gmail.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-07-23 15:57:54 +00:00
Jelle Zijlstra
6a285f94c6
Revert "gh-135228: When @dataclass(slots=True) replaces a dataclass, make the original class collectible (#136893)" (#137014)
This reverts commit 46cbdf967a.
2025-07-23 08:13:19 -07:00
Guido Imperiale
38b936cc99
gh-137043: mention PyList_GET_ITEM as unsafe borrowed API in free-threading docs (#137042) 2025-07-23 20:06:06 +05:30
Cornelius Roemer
80a7017d26
Fix typos in Doc/extending/extending.rst and Doc/library/shelve.rst (GH-136890) 2025-07-23 15:04:59 +03:00
Petr Viktorin
fac4964fdb
gh-136516: Mention installation artifacts as de-facto resources (GH-136419)
Files like NUL on windows are, from `importlib.resources` point of
view, an artifact caused by installing to a filesystem directory.
Mention these.
2025-07-23 14:01:38 +02:00
sobolevn
99cdf1deb6
gh-136437: Make several functions in os.path pos-only (#136949) 2025-07-23 14:56:02 +03:00
Petr Viktorin
e41c1ce585
gh-136459: Use platform-specific type in perf_jit_trampoline (GH-137031)
gh-136461 added perf support for macOS, with ifdefs around all changes
except increasing thread_id to 64 bits.
Make that change Apple-specific too.
2025-07-23 10:20:42 +02:00
Nathan Goldbaum
b13a5df52f
gh-133296: Fix versionadded for C API functions that were backported (#137024) 2025-07-22 21:27:50 +01:00
Ani
aafb1435d8
Use test.support.is_wasm32 flag for is_emscripten or is_wasi for generic checks (GH-136815)
Co-authored-by: Brett Cannon <brett@python.org>
2025-07-22 12:50:13 -07:00
Adam Turner
d6cf05b5d0
Fix tables in 'Using on Windows' for the text writer (#137012) 2025-07-22 16:15:29 +00:00
Nazım Can Altınova
a667800558
gh-136459: Add perf trampoline support for macOS (#136461) 2025-07-22 16:47:24 +01:00
Adam Turner
b6d3242244
GH-136975: Emend a spelling error (algorthm -> algorithm) (#136999) 2025-07-22 13:48:58 +00:00
Victorien
c13cc4af79
Fix code example in annotationlib documentation (#136972) 2025-07-22 13:48:02 +00:00
Serhiy Storchaka
3a89dfe32b
Revert "gh-112068: C API: Add support of nullable arguments in PyArg_Parse (GH-121303)" (#136991) 2025-07-22 16:39:50 +03:00
sobolevn
b31e5d6de1
gh-136437: Convert more `os.path` functions to positional-only in the docs (#136970) 2025-07-22 14:38:33 +01:00
Hood Chatham
12d2f373b9
gh-124621: Emscripten: Fix __syscall_ioctl patch (GH-136993)
If there is an error, we have to return `-errno` not positive errno.
Included in backport of GH-136931: #136988
2025-07-22 15:05:26 +02:00
Pablo Galindo Salgado
aafbdb5df5
gh-133742: Fix test_sysconfig and test_build_details for relocated directories (#136987) 2025-07-22 11:53:05 +00:00
Timon Viola
4d02f31cdd
gh-118350: Fix support of elements "textarea" and "title" in HTMLParser (#135310)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2025-07-22 13:27:13 +02:00
Hood Chatham
c933a6bb32
gh-124621: Emscripten: Support pyrepl in browser (GH-136931)
Basic support for pyrepl in Emscripten. Limitations:
* requires JSPI
* no signal handling implemented

As followup work, it would be nice to implement a webworker variant
for when JSPI is not available and proper signal handling.

Because it requires JSPI, it doesn't work in Safari. Firefox requires
setting an experimental flag. All the Chromiums have full support since
May. Until we make it work without JSPI, let's keep the original web_example
around.

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Éric <merwok@netwok.org>
2025-07-22 12:13:38 +02:00
Dave Peck
22c8658906
gh-132661: Document t-strings and templatelib (#135229)
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Loïc Simon <loic.pano@gmail.com>
Co-authored-by: pauleveritt <pauleveritt@me.com>
2025-07-22 12:44:13 +03:00
Cornelius Roemer
9a21df7c0a
Fix 3 typos in "Next" News items (#136892) 2025-07-22 11:22:08 +03:00
Malcolm Smith
149bddcc21
gh-131531: Android test fixes (#136845)
Modifies the test runner script to no longer export the the HOST environment
variable, and to allow for tests that produce no Python output (output from the
Android console is still expected and required). These changes stem from
knowledge gained during developing a PR for Android support in cibuildwheel.
2025-07-22 14:51:16 +08:00
Jelle Zijlstra
46cbdf967a
gh-135228: When @dataclass(slots=True) replaces a dataclass, make the original class collectible (#136893)
An interesting hack, but more localized in scope than #135230.

This may be a breaking change if people intentionally keep the original class around
when using `@dataclass(slots=True)`, and then use `__dict__` or `__weakref__` on the
original class.

Co-authored-by: Alyssa Coghlan <ncoghlan@gmail.com>
2025-07-21 21:43:34 -07:00
Hood Chatham
bbe589f93c
gh-133600: Move config.site-wasm32-emscripten into the emscripten folder (#136934)
Reorganises the large Emscripten-specific file into the Emscripten folder.
2025-07-22 07:58:31 +08:00
Emma Smith
6bf1c0ab34
gh-136170: Revert adding ZipFile.data_offset (GH-136950)
* Revert "gh-84481: Make ZipFile.data_offset more robust (#132178)"

This reverts commit 6cd1d6c6b1.

* Revert "gh-84481: Add ZipFile.data_offset attribute (#132165)"

This reverts commit 0788948dcb.

---------

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2025-07-21 23:16:30 +00:00
Nathan Goldbaum
89c220b93c
gh-133296: Publicly expose critical section API that accepts PyMutex (gh-135899)
This makes the following APIs public:

* `Py_BEGIN_CRITICAL_SECTION_MUTEX(mutex),`
* `Py_BEGIN_CRITICAL_SECTION2_MUTEX(mutex1, mutex2)`
* `void PyCriticalSection_BeginMutex(PyCriticalSection *c, PyMutex *mutex)`
* `void PyCriticalSection2_BeginMutex(PyCriticalSection2 *c, PyMutex *mutex1, PyMutex *mutex2)`

The macros are identical to the corresponding `Py_BEGIN_CRITICAL_SECTION` and
`Py_BEGIN_CRITICAL_SECTION2` macros (e.g., they include braces), but they
accept a `PyMutex` instead of an object.

The new macros are still paired with the existing END macros
(`Py_END_CRITICAL_SECTION`, `Py_END_CRITICAL_SECTION2`).
2025-07-21 17:25:43 -04:00
Kumar Aditya
f183996eb7
gh-136870: fix data race in PyThreadState_Clear on sys_tracing_threads (#136951)
In free-threading, multiple threads can be cleared concurrently as such the modifications on `sys_tracing_threads` should be done while holding the profile lock, otherwise it can race with other threads setting up profiling.
2025-07-21 20:35:25 +00:00
sobolevn
3224429450
gh-136437: Document os.path.dirname as accepting only pos-only (#136946) 2025-07-21 18:22:58 +00:00
sobolevn
b5428bb0e7
gh-136437: Document some os.path functions as requiring pos-only (#136812) 2025-07-21 21:01:43 +03:00
Peter Bierma
a10960699a
gh-136421: Load _datetime static types during interpreter initialization (GH-136583)
`_datetime` is a special module, because it's the only non-builtin C extension that contains static types. As such, it would initialize static types in the module's execution function, which can run concurrently. Since static type initialization is not thread-safe, this caused crashes. This fixes it by moving the initialization of `_datetime`'s static types to interpreter startup (where all other static types are initialized), which is already properly protected through other locks.
2025-07-21 13:47:26 -04:00
Barney Gale
80b2d60a51
GH-136874: url2pathname(): discard query and fragment components (#136875)
In `urllib.request.url2pathname()`, ignore any query or fragment components
in the given URL.
2025-07-21 17:33:20 +00:00
Josh Cannon
4b68289ca6
Pedantic rewording of why relative importing doesn't work in main modules (GH-136846)
Pedantically reword the section about relative imports and main modules.
2025-07-21 09:30:17 -07:00
Alper
65893c6f9c
gh-116738: Make syslog module thread-safe (#136760)
Make the setlogmask() function in the syslog module thread-safe. These changes are relevant for scenarios where the GIL is disabled or when using subinterpreters.
2025-07-21 09:24:42 -07:00
Nacho Caballero
5f9e38f9b9
gh-136859: Improve StrEnum docs (GH-136864)
Co-authored-by: Nacho Caballero <nacho.caballero@astrazeneca.com>
Co-authored-by: Antonio Spadaro <ilovelinux@users.noreply.github.com>
2025-07-21 08:18:40 -07:00
Mikhail Efimov
58d305cf38
gh-136438: Make sure test_generated_cases pass with all optimization levels (#136594)
Fix the `test_generated_cases` to work with `-O` or `-OO` flags.
Previously, `test_generated_cases` was catching an `AssertionError` while `Tools/cases_generator/optimizer_generator.py` used an `assert` statement.  This approach semantically incorrect, no one should trying to catch an `AssertionError`!
Now the `assert` statement has been replaced with an explicit `raise ValueError(...)` and the corresponding `self.assertRaisesRegex(AssertionError, ...)` has been updated to catch a `ValueError` instead.
2025-07-21 15:25:25 +03:00
Petr Viktorin
658599c15d
gh-121028: Soft-deprecate sys.api_version (GH-136463) 2025-07-21 14:22:48 +02:00
Petr Viktorin
28153fec58
gh-135621: Simplify TermInfo (GH-136916) 2025-07-21 13:06:42 +02:00
Serhiy Storchaka
dee6501894
gh-135661: Fix parsing attributes with whitespaces around the "=" separator in HTMLParser (GH-136908)
This fixes a regression introduced in GH-135930.
2025-07-21 12:07:15 +02:00
Łukasz Langa
09dfb50f1b
gh-135621: Remove dependency on curses from PyREPL (GH-136758) 2025-07-21 11:57:34 +02:00
adam j hartz
d1d526afe7
gh-136251: Improvements to WASM demo REPL (GH-136252)
Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
2025-07-21 11:56:45 +02:00
Hood Chatham
9c7b2af73d
gh-136852: Emscripten: Fix bug in #136853 (#136909)
We need to get rid of some whitespace to make this work.
2025-07-21 11:17:36 +02:00
Sergey Muraviov
cf19b6435d
gh-134411: assert PyLong_FromLong(x) != NULL when x is known to be small (#134415)
Since `PyLong_From Long(PY_MONITORING_DEBUGGER_ID)` falls to `small_int` case and can't return `NULL`. Added `assert`s for extra confidence.
https://github.com/python/cpython/issues/134411#issuecomment-2897653868
2025-07-21 11:59:06 +03:00
Vinay Sajip
1e672935b4
gh-136882: Update stale link in the basic logging tutorial. (#136885)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2025-07-21 10:29:12 +02:00
Bénédikt Tran
5798348a07
gh-136428: amend UUIDv8 performance improvements (#136903)
UUIDv8 has been added in Python 3.14.0a2 and its construction time
has been improved in Python 3.14.0a4, but since those changes will
not be visible when comparing the latest Python 3.13 and 3.14 together,
we do not document them on the What's New page to avoid confusion.
2025-07-21 08:23:16 +00:00
Dave Peck
c5e77af131
gh-132661: Disallow Template/str concatenation after PEP 750 spec update (#135996)
Co-authored-by: sobolevn <mail@sobolevn.me>
Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
2025-07-21 08:44:26 +02:00
AN Long
246be21de1
gh-136470: Correct InterpreterPoolExecutor's default thread name (GH-136472)
The OS thread name is now correctly prefixed with `InterpreterPoolExecutor` instead of `ThreadPoolExecutor`.
2025-07-20 23:34:32 +00:00
Hood Chatham
aec7f5f8b2
gh-136852: Emscripten: Add PYTHON_NODE_VERSION environment variable (#136853)
To choose the node version we use. Together with:
https://github.com/python/buildmaster-config/pull/614
closes #136852.
2025-07-21 00:30:35 +02:00
Pablo Galindo Salgado
acbe896cb1
GH-130645: Default to color help in argparse (#136809)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
2025-07-20 14:55:44 -07:00
🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко)
65d2c51c10
GH-111758: Merge TSan and UBSan reusable GHA workflows (#136820)
Co-authored-by: Sviatoslav Sydorenko <webknjaz@redhat.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-07-20 23:03:46 +03:00
Peter Bierma
8f59fbb082
gh-136492: Add FrameLocalsProxyType to types (GH-136546)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-07-20 20:49:00 +02:00
morotti
e24c66d55a
gh-91349: Adjust default compression level to 6 (down from 9) in gzip and tarfile (GH-131470)
gh-91349: Adjust default compression level to 6 (down from 9) in gzip and tarfile

It is the default level used by most compression tools and a
better tradeoff between speed and performance.

Co-authored-by: rmorotti <romain.morotti@man.com>
Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
2025-07-20 09:43:40 -07:00
Alexander Urieles
958657bbc3
gh-131724: Add a new max_response_headers param to HTTP/HTTPSConnection (GH-136814)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2025-07-20 13:53:54 +00:00
MonadChains
18a7f5dad8
gh-127598: Improve ModuleNotFoundError when -S is passed (GH-136821) 2025-07-20 15:33:58 +02:00
Bénédikt Tran
4a151cae33
gh-134531: prefer using _hashlib module state instead of module object (#136865)
Some internal helper functions taking the module object to retrieve its state
under some conditions now directly take the module's state instead as those
conditions hold most of the time.
2025-07-20 13:10:36 +00:00
Bénédikt Tran
c504f62fe2
gh-136547: fix hashlib_helper for blocking and requesting digests (#136762)
- Fix `hashlib_helper.block_algorithm` where the dummy functions were incorrectly defined.
- Rename `hashlib_helper.HashAPI` to `hashlib_helper.HashInfo` and add more helper methods.
- Simplify `hashlib_helper.requires_*()` functions.
- Rewrite some private helpers in `hashlib_helper`.
- Remove `find_{builtin,openssl}_hashdigest_constructor()` as they are no more needed and were
  not meant to be public in the first place.
- Fix some tests in `test_hashlib` when FIPS mode is on.
2025-07-20 14:32:35 +02:00
Dominic H.
cc81b4e501
gh-86608: Improve and restructure tarfile examples (#121771)
Add an example on how to write a tarfile to stdout; general improvements.

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-07-20 12:19:47 +00:00
Dominic H.
c6e6fe92cd
gh-130655: gettext: Add fallback testcase (#136857) 2025-07-20 14:08:13 +02:00
Nacho Caballero
9c2f91cde8
gh-136854: Exit on error in make venv (#136856)
Co-authored-by: Nacho Caballero <nacho.caballero@astrazeneca.com>
2025-07-20 12:08:00 +00:00
Hugo van Kemenade
dda9d0011f
gh-108362: Retarget incremental GC changes to 3.14 (#125453) 2025-07-20 12:56:55 +03:00
Olga Pustovalova
588d9fb84a
gh-136438: Make sure test_remote_pdb pass with all optimization levels (GH-136788) 2025-07-20 10:57:54 +02:00
Bénédikt Tran
6be49ee517
gh-136787: improve exception messages for invalid hash algorithms (#136802) 2025-07-20 08:49:34 +00:00
Hood Chatham
800d37feca
gh-124621: Emscripten: Fix regression in use-after-close error handling (#136837) 2025-07-19 21:43:50 +02:00
Disconnect3d
69ea1b3a8f
gh-136839: Refactor simple dict.update calls (#136811)
Refactor simple dict.update calls

This commit refactors simple `dict.update({key: value})` calls which can
be done via `dict[key] = value` instead.

I found those cases with the [semgrep](https://semgrep.dev/) tool:

```
$ semgrep --lang python --pattern '$DICT.update({$A: ...})'

┌─────────────────┐
│ 5 Code Findings │
└─────────────────┘

    Lib/dataclasses.py
         1268┆ slots.update({slot: doc})

    Lib/multiprocessing/resource_tracker.py
           50┆ _CLEANUP_FUNCS.update({
           51┆     'semaphore': _multiprocessing.sem_unlink,
           52┆ })
            ⋮┆----------------------------------------
           53┆ _CLEANUP_FUNCS.update({
           54┆     'shared_memory': _posixshmem.shm_unlink,
           55┆ })

    Lib/tkinter/scrolledtext.py
           26┆ kw.update({'yscrollcommand': self.vbar.set})

    Lib/xmlrpc/server.py
          242┆ self.funcs.update({'system.multicall' : self.system_multicall})
```
2025-07-19 10:12:10 -07:00
sobolevn
67036f1ee1
gh-133875: Remove deprecated pathlib.PurePath.is_reserved (#133876) 2025-07-19 17:07:46 +00:00
Hood Chatham
7ae4749d06
gh-124621: Emscripten: Add support for async input devices (GH-136822)
This is useful for implementing proper `input()`. It requires the
JavaScript engine to support the wasm JSPI spec which is now stage 4.
It is supported on Chrome since version 137 and on Firefox and node
behind a flag.

We override the `__wasi_fd_read()` syscall with our own variant that
checks for a readAsync operation. If it has it, we use our own async
variant of `fd_read()`, otherwise we use the original `fd_read()`.
We also add a variant of `FS.createDevice()` called
`FS.createAsyncInputDevice()`.

Finally, if JSPI is available, we wrap the `main()` symbol with
`WebAssembly.promising()` so that we can stack switch from `fd_read()`.
If JSPI is not available, attempting to read from an AsyncInputDevice
will raise an `OSError`.
2025-07-19 17:14:29 +02:00
Slavaqq
1ba23244f3
gh-136793: Update the sampling rate in the documentation (#136829) 2025-07-19 15:00:46 +00:00
Matthieu Lienart
6293d8a1a6
gh-136752: Clarify documentation for `IPv{N}Address.is_reserved` (#136794)
Co-authored-by: Matthieu Lienart <matthieu.lienart@axians.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-07-19 14:43:56 +00:00
Valerio Gianella
57acd65a30
gh-135468: Improve `BaseHandler.http_error_default()` parameter descriptions (#136797)
Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
2025-07-19 15:43:00 +01:00
jdunter
8ffc3ef01e
gh-54732: Make argparse error caused by empty rows in option files explicit (#136795)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-07-19 14:08:19 +00:00
Olga Matoula
3a64844533
gh-136801: Fix PyREPL syntax highlightning on match cases after multi-line case (GH-136804) 2025-07-19 15:15:49 +02:00
Saurav Singh
6a1c93af80
gh-136764: improve comment in enum.verify.__call__ (GH-136774) 2025-07-19 05:55:02 -07:00
aggshruti99
f575588ccf
gh-135730: Clarify multiprocessing.Queue close() documentation (#136803)
Add a copy of the text from SimpleQueue.close()

---------

Co-authored-by: saggarwal145 <saggarwal145@bloomberg.net>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2025-07-19 14:24:39 +02:00
Disconnect3d
d19bb44713
Doc/c-api/memory.rst: extend --without-pymalloc doc with ASan information (GH-136790)
* Doc/c-api/memory.rst: extend --without-pymalloc doc with ASan information

This commit extends the documentation for disabling pymalloc with the `--without-pymalloc` flag regarding why it is worth to use it when enabling AddressSanitizer for Python build (which is done, e.g., in CPython's CI builds).

I have tested the CPython latest main build with both ASan and pymalloc enabled and it seems to work just fine. I did run the `python -m test` suite which didn't uncover any ASan crashes (though, it detected some memory leaks, which I believe are irrelevant here).

I have discussed ASan and this flag with @encukou on the CPython Core sprint on EuroPython 2025. We initially thought that the `--without-pymalloc` flag is needed for ASan builds due to the fact pymalloc must hit the begining of page when determining if the memory to be freed comes from pymalloc or was allocated by the system malloc. In other words, we thought, that ASan would crash CPython during free of big objects (allocated by system malloc). It may be that this was the case in the past, but it is not the case anymore as the `address_in_range` function used by pymalloc is annotated to be skipped from the ASan instrumentation.

This code can be seen here:
acefb978dc/Objects/obmalloc.c (L2096-L2110)

While the annotation macro is defined here:
acefb978dc/Include/pyport.h (L582-L598)

And the corresponding attribute is documented in:
* for gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-no_005fsanitize_005faddress-function-attribute
* for clang: https://clang.llvm.org/docs/AttributeReference.html#no-sanitize-address-no-address-safety-analysis

* Update Doc/c-api/memory.rst

* Improve --with-address-sanitizer and pymalloc docs

---------

Co-authored-by: Petr Viktorin <encukou@gmail.com>
2025-07-19 13:52:54 +02:00
nacind
eb8ac4c857
gh-122450: Indicate that Fraction denominators are always positive (#136789) 2025-07-19 13:26:50 +02:00
Sina Zel taat
acefb978dc
gh-136769: Include fixed-width integers in the fundamental data types table (#136784)
Fixed-sized types, like ``c_int32``, are currently missing from the fundamental data types table
in the ``ctypes`` documentation. This commit adds them, and  notes that ``c_[u]int8`` is an alias
of ``c_[u]byte``.
2025-07-19 11:19:41 +01:00
Gergely Elias
263e451c41
gh-74598: document that fnmatch.filterfalse is affected by cache limitation (#136781) 2025-07-19 09:51:11 +00:00
RafaelWO
3eecc72ac7
Docs: Improve example for `itertools.batched()` (#136775)
The current example `batched('ABCDEFG', n=3) → ABC DEF G` can confuse readers because both, the size of the tuples and the number of tuples are 3.
By using a batch size of n=2, it is clearer that the `n` argument refers to the size of the resulting tuples.
I.e. the new example is: `batched('ABCDEFG', n=2) → AB CD EF G`
2025-07-19 10:29:44 +01:00
Hunter Hogan
60146f4f6f
Fix typo in Lib/test/test_ast/test_ast.py (#136767)
`ASTOptimiziationTests` -> `ASTOptimizationTests`
2025-07-19 12:14:49 +03:00
chemelnucfin
f520f22927
parser_generator.py typo - keywods -> keywords (#135014) 2025-07-19 11:54:20 +03:00
Roman
09ac8e042f
Fix typo: "occured" =>"occurred" (#134928)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2025-07-19 11:48:04 +03:00
Mikhail Efimov
03017a8cc2
gh-136438: Make sure test_ast pass with all optimization levels (#136596)
Explicitly pass an `optimizer` parameter to the calls of `ast.parse/compile`, because if it is not provided, the interpreter will use its internal state, which can be modified using the `-O` or `-OO` flags.

Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
2025-07-18 19:07:46 +03:00
Tian Gao
28937d3a21
gh-136697: Use the standard audit event format for sys.monitoring docs (#136747) 2025-07-17 11:10:10 -07:00
Alper
eddc8c0a1d
gh-116738: Make pwd module thread-safe (#136695)
Make the pwd module functions getpwuid(), getpwnam(), and getpwall() thread-safe. These changes apply to scenarios where the GIL is disabled or in subinterpreter use cases.
2025-07-17 09:16:01 -07:00
Hood Chatham
22af5d35a6
gh-127146: Emscripten: Set umask to zero in python.sh (#136740)
Clears the umask used during a test of pydoc.apropos when testing on
Emscripten. This is to work around a known issue in Emscripten; but it's not
clear if the chmod call that is causing the problem is actually testing
anything of significance.
2025-07-17 15:39:01 +00:00
Ole Herman Schumacher Elgesem
180b3eb697
fix traceback.FrameSummary docstring by adding end_lineno, colno, and end_colno (#136716) 2025-07-16 22:59:30 +05:30
Kumar Aditya
b7d722547b
gh-136669: build _asyncio as static module (#136670)
`_asyncio` is now built as a static module so that thread states can be accessed directly via registers and avoids the overhead of function call.
2025-07-16 22:09:08 +05:30
Bartosz Sławecki
69d8fe50dd
gh-126548: Add a thread-unsafety warning for importlib.reload() (GH-136704) 2025-07-16 12:34:14 -04:00
Hood Chatham
dcd27aace1
gh-127146: Emscripten: Don't need to avoid unpaired surrogate anymore (#136707)
This might have been fixed by gh-136624, or by some Emscripten change.
In any case, it no longer seems to be needed.
2025-07-16 17:53:47 +02:00
Harmen Stoppels
bde808ad6b
gh-136710: Fix bad indentation in os.chdir docstring (GH-136709) 2025-07-16 15:30:10 +00:00
sobolevn
2f0db9b05f
Add .gram file to the .editorconfig (#136680) 2025-07-16 17:35:15 +03:00
Hood Chatham
c730952aa6
gh-127146: Emscripten: more regular stack overflow skips (#136708)
Makes the Emscripten stack overflow skip message consistent with WASI, 
and replaces some ad-hoc skips.
2025-07-16 14:02:25 +00:00
Hood Chatham
12e52cad71
gh-127146: Emscripten: Make os.umask() actually work (#136706)
Provide a stub implementation of umask that is enough to get some tests passing.
More work is needed upstream in Emscripten to make all umask tests to pass.
2025-07-16 15:33:15 +02:00
Facundo Batista
8e2f4b4483
Improved venv docs to indicate that isolation is the default. (#136698)
* Improved venv docs to note that isolation is the default.

* Insert "that" so that a sentence reads better.

* Improved wording.

---------

Co-authored-by: Vinay Sajip <vinay_sajip@yahoo.co.uk>
2025-07-16 08:55:31 -03:00
Pablo Galindo Salgado
ef66fb597b
gh-135148: Correctly handle f/t strings with comments and debug expressions (#135198) 2025-07-16 11:47:13 +02:00
William Andrea
e89923d366
fix grammar typo in logging.rst (#136584) 2025-07-16 12:31:26 +05:30
Hood Chatham
e81c4e84b3
gh-127146: Report uid in Emscripten + node as native uid (#136509)
Corrects the handling of getuid on emscripten, which was consistently reporting as 0.
2025-07-16 06:17:16 +02:00
Serhiy Storchaka
cb59eaefed
Fix the doctest.testmod() docstring (GH-136675)
__test__ = None is not supported since Python 2.4.
2025-07-15 19:42:02 +03:00
Serhiy Storchaka
7689407fa4
Fix index entry and anchor for module.__test__ (GH-136674)
It was "doctest.module attribute". Now it is "module attribute".
2025-07-15 18:52:51 +03:00
andrewreds
2500eb96b2
gh-135909: Assert incoming refcnt != 0 for the free threaded GC (GH-136009)
This helps catch double deallocation bugs and is similar to the
assertion in the GIL-enabled build.  The call to `validate_refcounts`
is moved up to start of the GC because `queue_untracked_obj_decref()`
creates it own zero reference count garbage.
2025-07-15 11:26:16 -04:00
Richard Si
be02e68158
gh-72327: Suggest using system terminal for pip install in PyREPL (#136328)
Users new to Python packaging often try to use pip from the REPL only to
be met with a confusing SyntaxError. If this happens, guide the user to
use a system terminal instead to invoke pip.

Closes #72327

---------

Co-authored-by: Tom Viner <tom@viner.tv>
Co-authored-by: Brian Schubert <brianm.schubert@gmail.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Alyssa Coghlan <ncoghlan@gmail.com>
2025-07-15 14:25:07 +00:00
Kumar Aditya
a8f42e6e88
gh-111968: remove redundant fetching of interpreter state in dict implementation (#136673) 2025-07-15 19:15:11 +05:30
Ran Benita
7e10a103df
gh-136682: Remove incorrect statement that os.path.samestat accepts file-like objects (#136683) 2025-07-15 14:49:11 +02:00
Maciej Olko
624bf52c83
gh-136155: Docs: check for EPUB fatal errors in CI (#134074)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2025-07-15 15:26:24 +03:00
Bénédikt Tran
a02cf19dee
gh-72570: mention the incompatibility of XOFs with HMAC (#136676) 2025-07-15 14:03:21 +02:00
Adam Turner
5b969fd645
GH-132661: Add `string.templatelib.convert()` (#135217) 2025-07-15 11:56:42 +02:00
Adam Turner
c89a66feb1
GH-133711: Enable UTF-8 mode by default (PEP 686) (#133712)
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-07-15 10:45:41 +01:00
Dzmitry Plashchynski
f320c951c3
gh-131189: Fix "msvcrt" import warning on Linux when "_ctypes" is not available. (GH-131201)
Fix "msvcrt" import warning on Linux when "_ctypes" is not available.

On Linux, compiling without "libffi" causes a
"No module named 'msvcrt'" warning when launching PyREPL.
2025-07-15 09:44:31 +02:00
Sergey B Kirpichev
e4654e0b3e
gh-136663: fix signatures of PyFloat_Pack/Unpack in docs (#136664) 2025-07-15 11:00:12 +05:30
Tian Gao
db2032407a
Fix a minor indentation error (#136661) 2025-07-14 17:01:56 -07:00
Alper
9363703bd3
gh-116738: Make grp module thread-safe (#135434)
Make grp module methods getgrgid() and getgrnam() thread-safe when the GIL is disabled and getgrgid_r()/getgrnam_r() C APIs are not available.
---------

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-07-14 11:18:41 -07:00
mpage
d995922198
gh-136396: Include instrumentation when creating new copies of the bytecode (#136525)
Previously, we assumed that instrumentation would happen for all copies of
the bytecode if the instrumentation version on the code object didn't match
the per-interpreter instrumentation version. That assumption was incorrect:
instrumentation will exit early if there are no new "events," even if there
is an instrumentation version mismatch.

To fix this, include the instrumented opcodes when creating new copies of
the bytecode, rather than replacing them with their uninstrumented variants.
I don't think we have to worry about races between instrumentation and creating
new copies of the bytecode: instrumentation and new bytecode creation cannot happen
concurrently. Instrumentation requires that either the world is stopped or the
code object's per-object lock is held and new bytecode creation requires holding
the code object's per-object lock.
2025-07-14 10:48:10 -07:00
Brandt Bucher
3d8c38f6db
GH-135904: Improve the JIT's performance on macOS (GH-136528) 2025-07-14 10:14:20 -07:00
Bénédikt Tran
a68ddea3bf
gh-90733: improve hashlib.scrypt interface (#136100)
* add `scrypt` to `hashlib.__all__`
* improve `hashlib.scrypt` exception messages
2025-07-14 12:49:34 +02:00
Garry Cairns
75e2c5dd34
gh-134567: Move unittest What’s New entry (#136630) 2025-07-14 13:32:10 +03:00
Hugo van Kemenade
5bbf30e89e
Partially revert "gh-101100: Fix sphinx warnings in library/email.parser.rst (#136475)" (#136629) 2025-07-14 12:13:15 +03:00
Lee Dogeon
cd3e7ac89b
gh-67341: fix a typo in Include/fileutils.h (#136049)
`IO_REPARSE_TAG_SYMLINK` is mapped to `S_IFLNK` in `fileutils.c`, not in `posixmodule.c`
2025-07-14 08:02:05 +00:00
Serhiy Storchaka
b74fb8e220
gh-135256: Simplify parsing parameters in Argument Clinic (GH-135257) 2025-07-13 23:27:48 +03:00
Hood Chatham
283b050523
gh-127146: Emscripten: Fix test_open_undecodable_uri by setting -sTEXTDECODER=2 (#136624)
Removes the JS text decoder fallback and gets rid of the bugs due to the differences 
in behavior on invalid utf8 strings. See https://github.com/emscripten-core/emscripten/issues/24690.
2025-07-13 20:30:38 +02:00
Serhiy Storchaka
da699ed7e5
gh-121914: Change the names of the symbol tables for lambda and genexpr (GH-135288)
Change the names of the symbol tables for lambda expressions and generator
expressions to "<lambda>" and "<genexpr>" respectively to avoid conflicts
with user-defined names.
2025-07-13 21:09:42 +03:00
Duane Griffin
85ec3b3b50
gh-127971: fix off-by-one read beyond the end of a string during search (#132574) 2025-07-13 15:33:34 +02:00
Stan Ulbrych
a93d9aaf62
gh-42237: Link to complete list of codec aliases (#136625)
Closes #42237
2025-07-13 13:12:46 +00:00
Serhiy Storchaka
e18829a8ad
gh-132629: Deprecate accepting out-of-range values for unsigned integers in PyArg_Parse (GH-132630)
For unsigned integer formats in the PyArg_Parse* functions,
accepting Python integers with value that is larger than
the maximal value the corresponding C type or less than
the minimal value for the corresponding signed integer type
is now deprecated.
2025-07-13 12:44:54 +03:00
Peter Bierma
3dbe02ccd3
gh-132346: Docs: Clarify that reference counts aren't stable between versions (GH-132352) 2025-07-13 05:10:37 -04:00
Bénédikt Tran
9e5cebd56d
gh-136547: allow to temporarily disable hash algorithms in tests (#136570) 2025-07-13 10:58:15 +02:00
Peter Bierma
0d4fd10fba
Docs: Fix and improve the PyUnstable_Object_EnableDeferredRefcount documentation (GH-135323) 2025-07-13 02:46:13 -04:00
Yongzi Li
609d5adc7c
gh-134833: improve docs for del s[i:j] in Mutable Sequence Types (#134834) 2025-07-13 11:26:31 +05:30
Ajay Kamdar
46707d241a
gh-132969: update ACKS file (gh-133222) (#136144) 2025-07-13 11:19:44 +05:30
Sachin Shah
171de05b48
gh-136523: Fix wave.Wave_write emitting an unraisable when open raises (GH-136529) 2025-07-13 08:49:12 +03:00
Stan Ulbrych
42b251bceb
gh-134939: Correct concurrent.interpreters source code link (#136564) 2025-07-13 11:05:57 +05:30
Weilin Du
47b01da4cc
gh-101100: Fix sphinx warnings in Doc/library/platform.rst (GH-136562) 2025-07-12 21:15:04 +03:00
Bénédikt Tran
9be3649f5e
gh-136591: avoid using deprecated features for OpenSSL 3.0+ (#136592)
Since OpenSSL 3.0, `ERR_func_error_string()` always returns NULL and
`EVP_MD_CTX_get0_md()` should be preferred over `EVP_MD_CTX_md()`.
2025-07-12 16:33:07 +00:00
Serhiy Storchaka
be2c3d284e
gh-136549: Fix signature of threading.excepthook() (GH-136559) 2025-07-12 18:54:26 +03:00
Bast
5e1e21dee3
gh-91153: prevent a crash in bytearray.__setitem__(ind, ...) when ind.__index__ has side-effects (#132379)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-07-12 13:37:52 +00:00
Kliment Lamonov
25335d297b
gh-134759: fix UnboundLocalError in email.message.Message.get_payload (#136071)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-07-12 13:30:09 +00:00
Illia Volochii
5a20e79725
gh-99813: Start using SSL_sendfile when available (#99907)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-07-12 12:42:35 +00:00
Furkan Onder
dda70fa771
gh-99631: Add custom loads and dumps support for the shelve module (#118065)
Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-07-12 14:27:32 +02:00
Weilin Du
c564847e98
gh-89083: Add CLI tests for UUIDv{6,7,8} (#136548)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-07-12 14:06:15 +02:00
Bénédikt Tran
2301cdb559
gh-135853: add math.fmax and math.fmin (#135888) 2025-07-12 11:31:10 +00:00
Bénédikt Tran
83d04a29a6
gh-136565: Improve and amend hashlib.__doc__ (#136566) 2025-07-12 11:02:27 +00:00
Petr Viktorin
c7d24b81c3
gh-111506: Add _Py_OPAQUE_PYOBJECT to hide PyObject layout & related API (GH-136505)
Allow Py_LIMITED_API for (Py_GIL_DISABLED && _Py_OPAQUE_PYOBJECT)


API that's removed when _Py_OPAQUE_PYOBJECT is defined:

    - PyObject_HEAD
    - _PyObject_EXTRA_INIT
    - PyObject_HEAD_INIT
    - PyObject_VAR_HEAD
    - struct _object (i.e. PyObject) (opaque)
    - struct PyVarObject (opaque)
    - Py_SIZE
    - Py_SET_TYPE
    - Py_SET_SIZE
    - PyModuleDef_Base (opaque)
    - PyModuleDef_HEAD_INIT
    - PyModuleDef (opaque)
    - _Py_IsImmortal
    - _Py_IsStaticImmortal

Note that the `_Py_IsImmortal` removal (and a few other issues)
 means _Py_OPAQUE_PYOBJECT only works with limited
API 3.14+ now.


Co-authored-by: Victor Stinner <vstinner@python.org>
2025-07-12 09:55:12 +02:00
Will Childs-Klein
db47f4d844
gh-135401: Test AWS-LC as a cryptography library in CI (GH-135402)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Zachary Ware <zach@python.org>
2025-07-11 17:24:11 -05:00
Raymond Hettinger
7f1e66ae0e
Minor edit: Improve comment readability and ordering (gh-136557) 2025-07-11 12:36:17 -07:00
Weilin Du
561212a033
Doc: More duplicate word fixes (GH-136299) 2025-07-11 21:18:47 +03:00
Weilin Du
252e2f710e
gh-101100: Fix sphinx warnings in Doc/library/functools.rst (GH-136424)
Add index entries and anchors for cache_info, cache_clear and register.
2025-07-11 20:03:13 +03:00
Victor Stinner
2c9a8011c6
gh-135906: Test the internal C API in test_cext (#136247)
Remove duplicated definition: atexit_datacallbackfunc type
is already defined by Include/cpython/pylifecycle.h.
2025-07-11 16:48:43 +02:00
Victor Stinner
cbf007beeb
gh-136156: Remove tempfile test_link_tmpfile() (#136534)
It's not always possible to guarantee that the file was opened with
O_TMPFILE even if tempfile._O_TMPFILE_WORKS is true.
2025-07-11 16:45:31 +02:00
Pablo Galindo Salgado
236f733d8f
gh-136541: Fix several problems of perf trampolines in x86_64 and aarch64 (#136500)
This commit fixes the following problems:

* The x86_64 trampolines are not preserving frame pointers
* The hardcoded offsets to the code segment from the FDE only worked properly for x64_64
* The CIE data was not following conventions of aarch64
* The eh_frame for aarch64 was not fully correct
2025-07-11 14:32:35 +01:00
William S Fulton
7de8ea7be6
gh-136300: Modify C tests to conform to PEP-737 (GH-136301)
- Use %T format specifier instead of %s and Py_TYPE(x)->tp_name.
- Remove legacy %.200s format specifier for truncating type names.

Co-authored-by: Victor Stinner <vstinner@python.org>
2025-07-11 15:18:35 +02:00
sobolevn
3343fce05a
gh-136434: Fix docs generation of UnboundItem in subinterpreters (#136435) 2025-07-11 15:31:59 +03:00
Stan Ulbrych
975b57d945
gh-76637: Note that undefined Codec is for testing (#136531)
Closes #76637
2025-07-11 12:50:21 +02:00
Weilin Du
515b3d18ed
gh-101100: Fix sphinx warnings in library/email.parser.rst (#136475) 2025-07-11 12:37:01 +03:00
Ethan Furman
49365bd110
gh-107538: [Enum] fix handling of inverted/negative values (GH-132273)
* Fix flag mask inversion when unnamed flags exist.

For example:

    class Flag(enum.Flag):
        A = 0x01
        B = 0x02
        MASK = 0xff

    ~Flag.MASK is Flag(0)

* EJECT and KEEP flags (IntEnum is KEEP) use direct value.

* correct Flag inversion to only flip flag bits

IntFlag will flip all bits -- this only makes a difference in flag sets with
missing values.

* correct negative assigned values in flags

negative values are no longer used as-is, but become inverted; i.e.

    class Y(self.enum_type):
        A = auto()
        B = auto()
        C = ~A        # aka ~1 aka 0b1 110 (from enum.bin()) aka 6
        D = auto()

    assert Y.C. is Y.B|Y.D
2025-07-10 16:49:09 -07:00
Brandt Bucher
56c6f04b88
Omit Python/perf_jit_trampoline.c from the **/*jit* CODEOWNERS rule (#136519)
Omit perf_jit_trampoline from "JIT" codeowners
2025-07-10 23:08:48 +01:00
Sergey Miryanov
c560df9658
gh-136517: Print uncollectable objects if DEBUG_UNCOLLECTABLE mode was set (#136518) 2025-07-10 22:13:23 +01:00
László Kiss Kollár
59acdba820
gh-135953: Implement sampling tool under profile.sample (#135998)
Implement a statistical sampling profiler that can profile external
Python processes by PID. Uses the _remote_debugging module and converts
the results to pstats-compatible format for analysis.


Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
2025-07-10 18:44:24 +01:00
Stan Ulbrych
35e2c35970
gh-52876: Implement missing parameter in codecs.StreamReaderWriter functions (#136498)
Closes #52876
2025-07-10 17:42:14 +02:00
Stan Ulbrych
4b41b2043b
gh-82663: Clarify codecs.iterdecode/encode docs (#136497)
Closes #82663
2025-07-10 17:31:08 +02:00
Dave Peck
f1b8d01c80
gh-132661: Add default value (of "") for Interpolation.expression (#136441) 2025-07-10 16:27:41 +02:00
Rogdham
f519918ec6
gh-136394: Fix race condition in test_zstd (GH-136432) 2025-07-10 08:47:27 -04:00
Pieter Eendebak
d754f75f42
gh-82088: Improve performance of PyLong_As*() for multi-digit ints (#135585)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-07-10 13:16:01 +02:00
Petr Viktorin
85bc89f35f
gh-136209: Add .. c:var:: declarations for C exception types (GH-136210)
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-07-10 13:07:55 +02:00
sobolevn
c176543349
gh-136438: Make sure test_builtins pass with all optimization levels (#136474) 2025-07-10 11:57:29 +03:00
Petr Viktorin
b44316a097
gh-136476: Remove creation of unused list (GH-136494) 2025-07-10 08:12:23 +00:00
Emma Smith
61dd9fdad7
gh-135846: Add zstd dependency to Android build script (#136253)
Adds zstd to the Android build process.

---------

Co-authored-by: Malcolm Smith <smith@chaquo.com>
2025-07-10 07:46:33 +08:00
Pablo Galindo Salgado
ea45a2f97c
gh-136476: Show the full stack in get_async_stack_trace in _remote_debugging (#136483) 2025-07-09 23:11:17 +00:00
Victor Stinner
9c4d287775
gh-102740: Clarify time.monotonic() "system-wide" in the doc (#136431) 2025-07-10 01:06:48 +02:00
Victor Stinner
92b33c9590
gh-136156: Skip test_tempfile.test_link_tmpfile() on Android (#136430)
Adds a test skip on platforms where hard links are not available (which includes Android).
2025-07-10 06:17:21 +08:00
Zachary Ware
92f392ad9e
gh-136145: Define 'standard library' and 'stdlib' in the glossary (GH-136146)
---------

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Éric <merwok@netwok.org>
2025-07-09 21:33:45 +00:00
Diego Russo
e697f5e7c0
Add Diego Russo as code owner of the JIT (#136460) 2025-07-09 21:18:06 +01:00
Brandt Bucher
c49dc3bd0f
GH-115802: Optimize JIT stencils for size (GH-136393) 2025-07-09 12:11:28 -07:00
Raymond Hettinger
798f791daf
Minor edit: Move comments closer to the code they describe (gh-136477) 2025-07-09 10:23:46 -07:00
Oskar Roesler
591abcc01f
gh-81520: Document unexpected os.path.ismount behaviour with btrfs subvolumes (GH-136058) 2025-07-09 11:54:58 -04:00
NekrodNIK
6a6cd3c07c
gh-131825: Fix sqlite3 timezone-naive adapter recipe (GH-136270) 2025-07-09 10:06:42 -04:00
Geoffrey Thomas
3c43df4dbd
Docs: unittest.enterModuleContext is not a classmethod (#136464) 2025-07-09 14:52:39 +01:00
Justin Su
77fa7a4dcc
gh-136447: Use self.loop instead of global loop variable in asyncio REPL (#136448) 2025-07-09 14:27:20 +05:30
Jelle Zijlstra
797abd1f7f
gh-134657: Remove newly added private names from asyncio.__all__ (#134665) 2025-07-09 13:25:46 +05:30
Stan Ulbrych
f1dcf3c7bf
gh-53243: Document codecs.readbuffer_encode() (#136284)
Closes #53243
2025-07-09 09:39:55 +02:00
Vinay Sajip
301b29dd30
gh-94503: Update logging cookbook example with info on addressing log injection. (GH-136446)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2025-07-09 08:30:56 +01:00
dgpb
f9932f542e
gh-119109: improve functools.partial vectorcall with keywords (#124584)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-07-09 12:55:45 +05:30
Hood Chatham
6ea4258285
gh-136229: Remove Platform Emscripten is not supported warning (#136230)
Updates configure script to identify Emscripten as Tier 3.
2025-07-09 02:26:41 +00:00
Pablo Galindo Salgado
77d25e5b16
gh-91048: Revert the memory cache removal for remote debugging (#136440)
gh-91048: Reintroduce the memory cache for remote debugging
2025-07-09 00:31:17 +00:00
Arseniy Terekhin
a6566e49e6
gh-92536: Fix comment about number of unicode string types (#136439) 2025-07-08 23:49:55 +02:00
Stan Ulbrych
ffd7f2f231
gh-136162: Document encodings package functions (#136164)
Closes #136162.
2025-07-08 23:34:48 +02:00
Neil Schemenauer
b6b99bf7f1
GH-91636: Clear weakrefs created by finalizers. (GH-136401)
Weakrefs to unreachable garbage that are created during running of
finalizers need to be cleared.  This avoids exposing objects that
have `tp_clear` called on them to Python-level code.
2025-07-08 12:19:57 -07:00
Hugo van Kemenade
bc9bc078df
Update bytecode magic number in tests for the 3.14 release candidate (#136427) 2025-07-08 20:11:48 +03:00
Victor Stinner
6c81e8c57a
gh-136156: Allow using linkat() with TemporaryFile (#136281)
tempfile.TemporaryFile() no longer uses os.O_EXCL with os.O_TMPFILE,
so it's possible to use linkat() on the file descriptor.
2025-07-08 18:39:47 +02:00
AN Long
490eea0281
gh-136380: Fix import behavior for concurrent.futures.InterpreterPoolExecutor (#136381)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: sobolevn <mail@sobolevn.me>
2025-07-08 13:32:14 +00:00
Pablo Galindo Salgado
ba9c198630
gh-136186: Fix race condition in test_external_inspection.test_only_active_thread (#136347) 2025-07-08 13:23:31 +01:00
Yuki Kobayashi
0152df5fff
gh-101100: Fix sphinx warnings in Doc/library/exceptions.rst (#136309)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-07-08 15:05:05 +03:00
sobolevn
db699db99d
gh-136297: Fix hypothesis and subTest usage in test_zoneinfo_property.py (#136384) 2025-07-08 07:51:36 +00:00
Kumar Aditya
51934000ba
gh-117657: enable test_capi under TSAN (#136269) 2025-07-08 13:05:24 +05:30
Kumar Aditya
89f06a38c0
gh-134043: use _PyObject_GetMethodStackRef in pattern matching (#136356) 2025-07-08 13:04:50 +05:30
Weilin Du
5b78c85fb4
gh-101100: Fix sphinx warnings in whatsnew/3.11.rst (#136402) 2025-07-08 11:55:13 +05:30
Hugo van Kemenade
fbef0c1d6a
gh-102567: Add missing newline to --help-all (GH-136391) 2025-07-08 07:59:00 +02:00
Kumar Aditya
0240ef4705
gh-98388: add tests for happy eyeballs (#136368) 2025-07-07 23:30:27 +05:30
Charlie Lin
fe187fae8d
gh-135906: Use _PyObject_CAST in internal headers (GH-135892)
Fixes build errors encountered in python-greenlet/greenlet#450 when building greenlet on the free-threaded build.

---------

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-07-07 12:56:14 -04:00
Weilin Du
0b62523959
gh-101100: Fix Sphinx warnings in library/email.compat32-message.rst (#136323) 2025-07-07 19:28:44 +03:00
Petr Viktorin
fb170cf50d
gh-120713: Make _Py_NORMALIZE_CENTURY private (GH-135933) 2025-07-07 17:57:48 +02:00
Maciej Olko
c45da6ae16
gh-136155: Docs: only add custom OpenGraph protocol meta tags for HTML builds (#136187)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2025-07-07 16:29:27 +03:00
Serhiy Storchaka
b7aa2a4b4d
gh-124486: Fix test_whichdb_ndbm in test_dbm on NetBSD (GH-136335)
On NetBSD, ndbm.open() does not fail for empty file.
2025-07-07 15:14:17 +03:00
Petr Viktorin
73e1207a4e
gh-135913: Document ob_refcnt, ob_type, ob_size (GH-135914)
* gh-135913: Document ob_refcnt, ob_type, ob_size

In `typeobj.rst`, instead of `:c:member:` it would be better to
use `.. c:member::` with a `:no-index:` option, see:

See ref. https://www.sphinx-doc.org/en/master/usage/domains/index.html#basic-markup

However, `c:member` currently does not support `:no-index:`.
2025-07-07 14:05:17 +02:00
Anthony Sottile
11f074b243
gh-86682: Add versionadded for sys._getframemodulename (#136325)
add versionadded for sys._getframemodulename
2025-07-07 16:52:04 +05:30
Petr Viktorin
9aac5a3d44
gh-131591: Document Py_REMOTE_DEBUG (GH-135929) 2025-07-07 12:56:29 +02:00
sobolevn
0a33221594
gh-101100: Fix sphinx warnings in whatsnew/3.9 (#136163) 2025-07-07 13:41:11 +03:00
Petr Viktorin
2468aafe98
gh-135755: Document __future__.* and CO_* as proper Sphinx objects (GH-135980)
* Turn the __future__ table to list-table.
  This'll make it easier to add entries that need longer markup
* Semantic markup for __future__ feature descriptions.
* Document CO_* C macros.
2025-07-07 12:31:13 +02:00
Victor Stinner
cb99d99277
gh-127502: Remove XML vulnerability table (GH-135294)
* Remove the table
* Replace warnings with notes


Latest releases of Python 3.9-3.15 include expat 2.7.1 which is not vulnerable.

expat 2.6.0 was released in February 2024.
2025-07-07 11:03:07 +02:00
Vinay Sajip
d05423a90c
gh-94503: Update logging cookbook with an example of uniformly handling newlines in output. (GH-136217) 2025-07-07 10:01:03 +01:00
Sergey B Kirpichev
3e849d75f4
gh-87790: support thousands separators for formatting fractional part of Fraction (#132204) 2025-07-07 11:16:31 +03:00
Sergey B Kirpichev
90a5b4402b
gh-87790: support thousands separators for formatting fractional part of Decimal (#132202)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-07-07 11:16:27 +03:00
Kumar Aditya
0c3e3da195
gh-109700: fix interpreter finalization while handling memory error (#136342) 2025-07-07 12:45:22 +05:30
Serhiy Storchaka
85b817da94
gh-136289: Fix test_sqlite3 on platforms with strict UTF-8 filesystem (GH-136326) 2025-07-07 06:29:00 +00:00
Jelle Zijlstra
9312702d2e
gh-136316: Make typing.evaluate_forward_ref better at evaluating nested forwardrefs (#136319) 2025-07-06 16:44:20 -07:00
sobolevn
c89f76e6c4
gh-136021: Make type_params a required parameter for typing._eval_type (#136332) 2025-07-06 22:11:13 +03:00
AN Long
77a8bd29da
gh-109070: Document that get_context in multiprocessing have side effect (#136341)
Document that get_context in multiprocessing have side effect
2025-07-06 11:26:26 -07:00
Kumar Aditya
d22e073d2b
gh-109700: fix memory error handling in PyDict_SetDefault (#136338) 2025-07-06 15:18:11 +00:00
sobolevn
06e347b846
gh-136285: Improve pickle protocol testing in test_interpreters (#136286) 2025-07-06 07:35:30 +00:00
W. H. Wang
1953713d0d
gh-136032: Fix argparse.BooleanOptionalAction doc (#136133) 2025-07-05 15:54:26 -07:00
Emma Smith
5dac137b9f
gh-136315: Fix skipped multithreading test in test_zstd (#136320)
Fix skipped test in test_zstd
2025-07-05 17:32:28 +00:00
Jeong, YunWon
887e5c8646
gh-136047: Allow typing._allow_reckless_class_checks to check _py_abc (#136115) 2025-07-05 14:24:33 +00:00
Victorien
5b56daa9d7
gh-130870: Preserve GenericAlias subclasses in typing.get_type_hints() (#131583) 2025-07-05 06:55:39 -07:00
Weilin Du
f0c7344a8f
gh-101100: Fix references in http.cookiejar docs (GH-136238) 2025-07-05 09:29:02 -04:00
sobolevn
5de7e3f973
gh-136297: Test all pickle protocols in test_zoneinfo_property.py (#136298) 2025-07-05 09:14:40 +03:00
William S Fulton
d1d5dce14f
gh-136288: Fix error message in _testcapi/vectorcall.c (GH-136258)
Use the %N format specifier instead of %s and `PyType_GetName`.
2025-07-04 11:54:00 -04:00
Rafael Fontenelle
ade1988094
Docs: Move "or" outside monospace syntax in tarfile.rst (GH-136263) 2025-07-04 10:40:32 -04:00
Richard Levasseur
93263d4314
gh-135773: have pyvenv.cfg without home key anchor a venv and deduce home (#135831)
This is still formally undefined behaviour, but we may as well
keep the *same* undefined behaviour as previous versions.

PEP 796 proposes a cleaner and more consistent replacement for 3.15+
2025-07-04 23:44:37 +10:00
Serhiy Storchaka
8ac7613dc8
gh-102555: Fix comment parsing in HTMLParser according to the HTML5 standard (GH-135664)
* "--!>" now ends the comment.
* "-- >" no longer ends the comment.
* Support abnormally ended empty comments "<-->" and "<--->".

---------

Co-author: Kerim Kabirov <the.privat33r+gh@pm.me>
Co-authored-by: Ezio Melotti <ezio.melotti@gmail.com>
2025-07-04 07:00:23 +00:00
Kumar Aditya
b582d751b4
gh-129824: fix data races in subinterpreters under TSAN (#135794)
This fixes the data races in typeobject.c in subinterpreters under free-threading. The type flags and slots are only modified in the main interpreter as all static types are first initialised in main interpreter.
2025-07-04 03:48:55 +00:00
Kumar Aditya
85f092f541
gh-115999: remove redundant check in free-threading from _STORE_ATTR_WITH_HINT (#136249) 2025-07-04 09:04:47 +05:30
Cody Maloney
48cb9b6112
gh-133982: Test _pyio.BytesIO in free-threaded tests (gh-136218) 2025-07-04 11:27:21 +09:00
Brett Cannon
b4991056f4
Clarify some details regarding sys.monitoring (#133981) 2025-07-03 14:04:01 -07:00
Serhiy Storchaka
0243f97cba
gh-135661: Fix parsing start and end tags in HTMLParser according to the HTML5 standard (GH-135930)
* Whitespaces no longer accepted between `</` and the tag name.
  E.g. `</ script>` does not end the script section.

* Vertical tabulation (`\v`) and non-ASCII whitespaces no longer recognized
  as whitespaces. The only whitespaces are `\t\n\r\f `.

* Null character (U+0000) no longer ends the tag name.

* Attributes and slashes after the tag name in end tags are now ignored,
  instead of terminating after the first `>` in quoted attribute value.
  E.g. `</script/foo=">"/>`.

* Multiple slashes and whitespaces between the last attribute and closing `>`
  are now ignored in both start and end tags. E.g. `<a foo=bar/ //>`.

* Multiple `=` between attribute name and value are no longer collapsed.
  E.g. `<a foo==bar>` produces attribute "foo" with value "=bar".

* Whitespaces between the `=` separator and attribute name or value are no
  longer ignored. E.g. `<a foo =bar>` produces two attributes "foo" and
  "=bar", both with value None; `<a foo= bar>` produces two attributes:
  "foo" with value "" and "bar" with value None.

* Fix Sphinx errors.

* Apply suggestions from code review

Co-authored-by: Ezio Melotti <ezio.melotti@gmail.com>

* Address review comments.

* Move to Security.

---------

Co-authored-by: Ezio Melotti <ezio.melotti@gmail.com>
2025-07-03 23:33:02 +03:00
Emma Smith
938a5d7e62
gh-135252: Document Zstandard integration across zipfile, shutil, and tarfile (#135311)
Document Zstandard integration across zipfile, shutil, and tarfile
2025-07-03 20:28:25 +00:00
Victor Stinner
da79ac9d26
gh-135075: Make PyObject_SetAttr() fail with NULL value and exception (#136180)
Make PyObject_SetAttr() and PyObject_SetAttrString() fail if called
with NULL value and an exception set.
2025-07-03 14:51:44 +02:00
Sergey B Kirpichev
b2e498ac26
gh-115119: Recommend upstream libmpdec in build requirements (#136205)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-07-03 14:44:59 +02:00
Kirill Podoprigora
a525ba514a
Python/gc.c: Refer to InternalDocs instead of devguide. (#136243) 2025-07-03 12:14:14 +00:00
Sergey B Kirpichev
c113a8e523
gh-130664: Treat '0' fill character with align '=' as zero-padding for Fraction's (GH-131067) 2025-07-03 13:57:31 +03:00
Serhiy Storchaka
5c984ae35e
gh-133740: Fix regression in locale.nl_langinfo(ALT_DIGITS) (GH-136237)
There is no need to temporary switch locale for items ALT_DIGITS and ERA
if the nl_langinfo() result is empty (most locales).
2025-07-03 10:39:14 +00:00
Daniel Hollas
8dc3383abe
gh-135069: Fix exception message in encodings.idna module (#135071) 2025-07-03 15:23:37 +05:30
Alper
8f8bdf251a
Fix comments for heapq.siftup_max (#135359)
Co-authored-by: mpage <mpage@meta.com>
2025-07-03 15:21:41 +05:30
Kira
e0245c789f
gh-135640: Adds more type checking to ElementTree (GH-135643) 2025-07-03 10:48:47 +03:00
Serhiy Storchaka
9084b15156
gh-135836: Fix IndexError in asyncio.create_connection() (#135875) 2025-07-03 09:38:39 +05:30
Weilin Du
135ba86212
gh-136135: Doc: Fix some broken links (GH-136137) 2025-07-02 20:51:31 -04:00
sobolevn
7afe1adb00
Replace capi-sig mailing list with discuss.python.org (#136211) 2025-07-02 20:43:43 +03:00
sobolevn
41a9b46ad4
gh-136203: Improve TypeError msg when comparing two MappingProxyTypes (#136204)
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-07-02 19:05:28 +03:00
Victor Stinner
fa43a1e0f8
gh-127705: Move Py_INCREF_MORTAL() to the internal C API (GH-136178)
Rename Py_INCREF_MORTAL() to _Py_INCREF_MORTAL() and move it to
pycore_object.h internal header.
2025-07-02 15:40:41 +02:00
sobolevn
ab7196a2f5
gh-136193: Improve TypeError msg when comparing two SimpleNamespaces (#136195)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-07-02 14:32:41 +03:00
Garry Cairns
51ab66b3d5
gh-134567: Add the formatter parameter in unittest.TestCase.assertLogs (GH-134570) 2025-07-02 09:51:19 +00:00
Sergey B Kirpichev
b19c9da401
gh-115119: Defer removal of bundled libmpdec to 3.16 (#133997)
Rename libmpdecimal -> libmpdec

see https://www.bytereef.org/mpdecimal/doc/libmpdec/index.html
2025-07-02 11:20:00 +02:00
Ken Jin
b3308973e3
gh-136183: Deal with escapes in JIT optimizer's constant evaluator (GH-136184) 2025-07-02 14:08:25 +08:00
Sam Gross
f41e9c750e
gh-134009: Expose PyMutex_IsLocked in the public C API (gh-134365)
The `PyMutex_IsLocked()` function is useful in assertions for verifying
that code maintains certain locking invariants.
2025-07-01 13:26:13 -04:00
Serhiy Storchaka
86c3316183
gh-134280: Disable constant folding for ~ with a boolean argument (GH-134982)
This moves the deprecation warning from compile time to run time.
2025-07-01 20:24:04 +03:00
Ken Jin
e0d6500b2d
gh-136125: Use _PyObject_GetMethodStackRef for LOAD_ATTR (GH-136127) 2025-07-02 01:20:46 +08:00
Sergey B Kirpichev
17cf0a343b
gh-115119: Remove implicit fallback to the bundled libmpdec (#134078)
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-07-01 17:50:51 +02:00
Stan Ulbrych
93809a918f
gh-105456: Remove 3 deprecated sre_* modules (#135994) 2025-07-01 17:31:07 +02:00
Zackery Spytz
12ce16bc13
gh-87298: Add tests for find_in_strong_cache() bug in _zoneinfo (GH-24829)
Co-authored-by: Paul Ganssle <p.ganssle@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-07-01 14:55:24 +00:00
Vladyslav Lazoryk
9c0cb5beb8
gh-136169: Update parameter name in fractions.from_float method (#136172)
Update parameter name in fractions.from_float method
2025-07-01 16:23:48 +03:00
Victor Stinner
28940e8e48
gh-130396: Move PYOS_LOG2_STACK_MARGIN to internal headers (#135928)
Move PYOS_LOG2_STACK_MARGIN, PYOS_STACK_MARGIN,
PYOS_STACK_MARGIN_BYTES and PYOS_STACK_MARGIN_SHIFT macros to
pycore_pythonrun.h internal header. Add underscore (_) prefix to the
names to make them private. Rename _PYOS to _PyOS.
2025-07-01 15:18:17 +02:00
heliang666s
0e19db653d
gh-135836: Fix IndexError in asyncio.create_connection with empty exceptions list (#135845)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-07-01 11:50:11 +00:00
Stan Ulbrych
31b56df3bb
gh-133447: Update sqlite3 What's New 3.15 entry (GH-136079) 2025-07-01 12:30:51 +02:00
Petr Viktorin
fe119a0817
gh-87135: threading.Lock: Raise rather than hang on Python finalization (GH-135991)
After Python finalization gets to the point where no other thread
can attach thread state, attempting to acquire a Python lock must hang.
Raise PythonFinalizationError instead of hanging.
2025-07-01 10:57:42 +02:00
Petr Viktorin
845263adc6
gh-133157: remove usage of _Py_NO_SANITIZE_UNDEFINED in pyexpat (#135346)
This was the last usage, so the macro is removed as well.

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-07-01 10:54:08 +02:00
Cody Maloney
23caccf74c
gh-133982: Use implementation-specific open in test_fileio.OtherFileTests (GH-135364) 2025-06-30 17:56:11 -04:00
sobolevn
7e33558455
gh-135422: Fix regression in SyntaxError messages after #134036 (#135423) 2025-06-30 21:52:26 +03:00
Eric Snow
fc82cb91ba
gh-134939: Fill Out the concurrent.interpreters Docs (gh-135902) 2025-06-30 10:54:53 -06:00
Stan Ulbrych
486587da42
gh-63207: Update time.time documentation after #116822 (#136068) 2025-06-30 18:10:24 +02:00
sedram
a87f3e0282
gh-136122: Fix video link for math.tau documentation (#136129) 2025-06-30 17:43:39 +03:00
Victor Stinner
ee47670e8b
gh-85702: Catch PermissionError in zoneinfo.load_tzdata() (#136117)
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-06-30 16:33:01 +02:00
Stan Ulbrych
2bdd50309f
gh-48181: Document codecs.charmap_build (#135997) 2025-06-30 15:42:08 +02:00
Adam Dangoor
75f40595e5
gh-131885: Update documented signatures for csv.{writer,reader} (GH-136085) 2025-06-30 09:32:51 -04:00
Pieter Eendebak
847d1c2cb4
gh-123471: Make itertools.product and itertools.combinations thread-safe (#132814)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-06-30 11:31:59 +00:00
Xuanteng Huang
b1056c2a44
gh-135607: remove null checking of weakref list in dealloc of extension modules and objects (#135614)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-06-30 11:14:31 +00:00
Pieter Eendebak
0533c1faf2
gh-123471: Make itertools.chain thread-safe (#135689) 2025-06-30 16:36:58 +05:30
Serhiy Storchaka
536a5ff153
gh-132813: Fix the csv documentation for quoting and escaping (#133209) 2025-06-30 10:42:00 +03:00
sobolevn
980a56843b
gh-136087: Remove \r from documented os.linesep values (#136088) 2025-06-30 10:12:05 +03:00
Kanishk Pachauri
fb9f933b8e
gh-130160: use .. program:: directive for documenting venv CLI (GH-130699)
Co-authored-by: Semyon Moroz <donbarbos@proton.me>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-06-30 06:41:57 +01:00
Weilin Du
698bab5a40
Doc: fix duplicated words (#136086)
---------

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2025-06-29 18:04:02 -04:00
fry69
7a403a8050
gh-123299: Provide replacement for removed sqlite3 attributes in What's New 3.14 (#125566)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-06-29 15:34:45 +00:00
Peter Bierma
3947847914
gh-127604: Docs: Include a C stack in the faulthandler example (GH-136081) 2025-06-29 10:58:26 -04:00
Bénédikt Tran
bd928a3035
gh-136066: simplify platform._platform() (#136069) 2025-06-29 09:56:52 +02:00
Akshat Gupta
30ba03ea8e
gh-136053: Check error for TYPE_SLICE in marshal.c (GH-136054)
Fix a possible crash when deserializing a large marshal data
(at least several GiBs) containing a slice.
2025-06-29 10:07:24 +03:00
Weilin Du
f04d2b8819
Doc: Fix duplicate words in idlelib (#136089) 2025-06-29 02:47:38 -04:00
Pablo Galindo Salgado
5334732f9c
gh-91048: Fix external inspection multi-threaded performance (#136005) 2025-06-28 14:11:31 +01:00
Nicolas Trangez
579acf4562
gh-76595: Add note on PyCapsule_Import behavior (GH-134022) 2025-06-28 09:01:41 -04:00
Bénédikt Tran
42ccac2d7f
gh-135853: add math.signbit (#135877) 2025-06-28 14:46:07 +02:00
Ken Jin
ff7b5d44a0
gh-132732: Fix up pure types in JIT (GH-136050)
Fix up pure types in JIT
2025-06-28 18:30:30 +08:00
Weilin Du
35ecaf90b2
Fix a typo in Lib/unittest/mock.py (#136067) 2025-06-28 10:25:07 +01:00
Ken Jin
c419af9e27
gh-132732: JIT: Only allow compact ints in pure evaluation (GH-136040) 2025-06-28 00:18:44 +08:00
Brandt Bucher
0e5d096130
GH-135904: Optimize the JIT's assembly control flow (GH-135905) 2025-06-27 08:20:51 -07:00
Lee Dogeon
0141e7f9e6
gh-108765: fix comment about macro definitions in _stat.c post GH-108854 (#136027) 2025-06-27 15:15:11 +00:00
Bénédikt Tran
1e975aee28
gh-135755: rename undocumented HACL_CAN_COMPILE_SIMD{128,256} macros (#135847)
Rename undocumented `HACL_CAN_COMPILE_SIMD{128,256}` macros
to `_Py_HACL_CAN_COMPILE_VEC{128,256}`. These macros are private.
2025-06-27 17:12:21 +02:00
Will Childs-Klein
065194c1a9
gh-135571: Guard _hashlib usage in test_hashlib.py (#135572) 2025-06-27 17:01:16 +02:00
Serhiy Storchaka
731f5b8ab3
gh-136028: Fix parsing month names containing "İ" (U+0130) in strptime() (GH-136029)
This affects locales az_AZ, ber_DZ, ber_MA and crh_UA.
2025-06-27 16:47:03 +03:00
Hugo van Kemenade
de0d014815
gh-92266: Replace tabs with four spaces in Python files (#135983) 2025-06-27 16:23:33 +03:00
Ken Jin
695ab61351
gh-132732: Automatically constant evaluate pure operations (GH-132733)
This adds a "macro" to the optimizer DSL called "REPLACE_OPCODE_IF_EVALUATES_PURE", which allows automatically constant evaluating a bytecode body if certain inputs have no side effects upon evaluations (such as ints, strings, and floats).


Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
2025-06-27 19:37:44 +08:00
Serhiy Storchaka
c45f4f3ebe
gh-78465: Fix error message for cls.__new__(cls, ...) where cls is not instantiable (GH-135981)
Previous error message suggested to use cls.__new__(), which
obviously does not work. Now the error message is the same as for
cls(...).
2025-06-27 14:35:55 +03:00
Sergey B Kirpichev
f3aec60d7a
gh-128051: Fix tests if sys.float_repr_style is 'legacy' (#135908)
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-06-27 12:00:25 +02:00
Pieter Eendebak
e23518fa96
gh-136017: avoid decref in rich compare for bool objects (#136018) 2025-06-27 14:31:51 +05:30
Serhiy Storchaka
07183ebce3
gh-53203: Fix strptime() for %c, %x and %X formats on some locales (#135971)
* Add detection of decimal non-ASCII alt digits.
* Add support of non-decimal alt digits on locale lzh_TW.
* Accept only numbers in correct range if alt digits are known.
* Fix bug in detecting the position of the week day name on locales byn_ER and wal_ET.
* Fix support of single-digit hour on locales ar_SA and bg_BG.
* Add support for %T, %R, %r, %C, %OC.
* Prepare code to use nl_langinfo().
2025-06-27 10:50:59 +03:00
Russell Keith-Magee
0c6c09b737
gh-135968: Add iOS binary stubs for strip (#135970)
Adds iOS binary stubs for invoking `strip`
2025-06-27 12:58:20 +08:00
Tim Peters
2fc68e180f
gh-135551: Change how sorting picks minimum run length (#135553)
New scheme from Stefan Pochmann for picking minimum run lengths.

By allowing them to change a little from one run to the next, it's possible to
arrange for that all merges, at all levels, strongly tend to be as evenly balanced
as possible, for randomly ordered data. Meaning the number of initial runs is a
power of 2, and all merges involve runs whose lengths differ by no more than 1.
2025-06-26 23:48:05 -05:00
Russell Keith-Magee
b38810bab7
gh-135966: Modify iOS testbed to make app_packages a site directory (#135967)
The iOS testbed now treats the app_packages folder as a site folder. This ensures it is
on the path, but also ensures any .pth files are processed on app startup.
2025-06-27 12:46:49 +08:00
Brian Schubert
34ce1920ca
Docs: Fix duplicate word typos (GH-135958) 2025-06-26 20:00:19 -04:00
Nathan Korth
58a42dea97
gh-135995: Fix missing char in palmos encoding (#135990)
0x8b correctly encodes to ‹, but 0x9b was mistakenly marked as a control character instead of ›.
---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Brian Schubert <brianm.schubert@gmail.com>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2025-06-26 18:35:45 -04:00
Stan Ulbrych
642e5dfc74
IDLE: Update NEWS2x.txt with 2.7.0 release date (#129908) 2025-06-26 16:20:07 -04:00
Victor Stinner
8594d2c03d
gh-135927: Check _MSC_VER to define _Py_NULL macro (#135987) 2025-06-26 18:11:49 +02:00
Duane Griffin
a4625d597f
gh-91555: add warning to docs about possibility of deadlock/infinite recursion (GH-135954)
* gh-91555: add warning to docs about possibility of deadlock/infinite recursion

Attempt to clarify in the documentation that care must be taken when using
multiprocessing classes to implement logging since they have builtin internal
logging, and hence may cause deadlock/infinite recursion.

* Update Doc/library/logging.handlers.rst

Co-authored-by: Vinay Sajip <vinay_sajip@yahoo.co.uk>

* Change whitespace.

---------

Co-authored-by: Vinay Sajip <vinay_sajip@yahoo.co.uk>
2025-06-26 15:18:32 +01:00
Connor Denihan
0d76dccc3b
gh-135110: Fix misleading generator.close() documentation (GH-135152)
The documentation incorrectly stated that generator.close() 'raises' a
GeneratorExit exception. This was misleading because the method doesn't
raise the exception to the caller - it sends the exception internally
to the generator and returns None.
2025-06-26 09:27:25 -04:00
Dylan
fb9e292919
gh-129958: New syntax error in format spec applies to both f-strings and t-strings (#135570)
Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
2025-06-26 15:02:50 +02:00
Weilin Du
ffb2a02f98
gh-135965: Delete duplicate word in isolating-extensions howto (#135964)
Change use use to use.
2025-06-26 07:41:41 -04:00
Petr Viktorin
6be17baeb5
gh-135755: Use private names (_Py*) for header file guards new in 3.14 (GH-135921)
These are private API; let's name new ones accordingly.
2025-06-26 13:05:01 +02:00
Petr Viktorin
9193efdeab
gh-125206: Make _Py_FFI_SUPPORT_C_COMPLEX private (GH-135932) 2025-06-26 11:48:37 +02:00
Peter Bierma
10a3d43188
gh-135755: Move PyFunction_GET_BUILTINS to the private API (GH-135938) 2025-06-26 11:43:08 +02:00
Petr Viktorin
a1da208eec
gh-131591: Add Py_ prefix to MAX_SCRIPT_PATH_SIZE; remove unprefixed struct tag (GH-135924)
Names/macros defined in public headers should have `Py`/`_Py` prefixes.
2025-06-26 09:25:41 +02:00
Terry Jan Reedy
e3ea6f2b3b
gh-135956: Remove duplicate word in _pydatetime docstring (#135957)
_pydatetime.isoformat docstring repeats 'giving'.
2025-06-25 23:44:08 -04:00
Neil Schemenauer
1f5e23fd70
Add whatsnew text for warnings module changes. (gh-135869) 2025-06-25 20:03:24 -07:00
Stan Ulbrych
0fadd9fd20
gh-125142: remove duplicated import in Lib/pydoc.py (gh-135215) 2025-06-25 20:01:25 -07:00
Rob Reynolds
6227662ff3
Docs: Fix indentation in slice class of functions.rst (GH-134393)
Paragraph should not be under `slice.step`. It applies to the whole class.

---------

Co-authored-by: Rob Reynolds <13379223+reynoldsnlp@users.noreply.github.com>
2025-06-25 13:40:00 -04:00
Joseph Tibbertsma
cbfaf41caf
Fix needless spinning in _PyMutex_LockTimed with zero timeout (gh-135872)
The free threading build could spin unnecessarily on `_Py_yield()` if the initial
compare and swap failed.
2025-06-25 16:41:36 +00:00
Ken Jin
a88b49c3f2
gh-135927: Fix MSVC Clatest C builds (GH-135935) 2025-06-25 23:02:53 +08:00
HarryLHW
d2154912b3
Docs: Add cross-reference for positional_item in the calls productionlist (GH-129977)
Add missing hyperlink for `positional_item`
2025-06-25 10:24:58 -04:00
sobolevn
bcc2cbaa7f
gh-135839: Fix module_traverse and module_clear in subinterp modules (#135937) 2025-06-25 14:17:02 +00:00
Petr Viktorin
c2f2fd4eca
gh-131591: Make --without-remote-debug work (GH-135925)
The feature is checked using `defined(Py_REMOTE_DEBUG)`; defining
the macro (even as `0`) enables it.
2025-06-25 13:51:32 +02:00
Petr Viktorin
1b1ae82fab
gh-135755: Move SPECIAL_ constants to a private header (GH-135922)
Macros without a `Py`/`_Py` prefix should not be defined in public headers.
2025-06-25 13:03:05 +02:00
sobolevn
dd59c786cf
gh-135839: Fix module_traverse and module_clear in _interpchannelsmodule (#135840) 2025-06-25 11:54:42 +03:00
Peter Bierma
ca87a47b3d
gh-135755: Docs: C API: Document missing PyFunction_GET* macros (GH-135762)
Co-authored-by: Brian Schubert <brianm.schubert@gmail.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2025-06-25 08:44:55 +00:00
Neil Schemenauer
113de8545f
GH-133136: Revise QSBR to reduce excess memory held (gh-135473)
The free threading build uses QSBR to delay the freeing of dictionary
keys and list arrays when the objects are accessed by multiple threads
in order to allow concurrent reads to proceed with holding the object
lock. The requests are processed in batches to reduce execution
overhead, but for large memory blocks this can lead to excess memory
usage.

Take into account the size of the memory block when deciding when to
process QSBR requests.

Also track the amount of memory being held by QSBR for mimalloc pages.  Advance the write sequence if this memory exceeds a limit.  Advancing the sequence will allow it to be freed more quickly.

Process the held QSBR items from the "eval breaker", rather than from `_PyMem_FreeDelayed()`.  This gives a higher chance that the global read sequence has advanced enough so that items can be freed.

Co-authored-by: Sam Gross <colesbury@gmail.com>
2025-06-25 00:06:32 -07:00
Vinay Sajip
18d32fb646
gh-91555: Revert disabling of logger while handling log record. (GH-135858)
Revert "gh-91555: disable logger while handling log record (GH-131812)"

This reverts commit 2561e148ec.
2025-06-25 06:42:38 +01:00
Brandt Bucher
ee0e22c088
GH-90117: Check for list and tuple before MappingView in pprint (GH-135779) 2025-06-24 14:41:41 -07:00
Brian Schubert
4e6f0d116e
gh-135855: Raise TypeError When Passing Non-dict Object to _interpreters.set___main___attrs (gh-135856) 2025-06-24 12:53:14 -06:00
mpage
fea5ccc55d
gh-135805: Document the X option and env var for controlling thread-local bytecode (#135868)
Document the X option and env var for controlling thread-local bytecode.
2025-06-24 10:02:50 -07:00
sobolevn
b3ab94acd3
gh-135878: Fix crash in types.SimpleNamespace.__repr__ (#135889)
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-06-24 19:33:25 +03:00
Bénédikt Tran
e5f03b94b6
gh-135487: fix reprlib.Repr.repr_int when given very large integers (#135506) 2025-06-24 11:09:46 +00:00
Victor Stinner
15c6d63fe6
gh-135494: Fix python -m test --pgo -x test_re (#135713)
Fix regrtest to support excluding tests from --pgo tests.
2025-06-24 12:21:35 +02:00
Mark Shannon
2060089254
GH-135106: Restrict trashcan to GC'ed objects (GH-135682) 2025-06-24 09:49:38 +01:00
Hugo van Kemenade
39ea593cbb
gh-123299: Update 'What's New in Python 3.14' from 3.14 branch (#135616) 2025-06-24 11:08:23 +03:00
Bénédikt Tran
ef4fc86afa
gh-135532: use defining_class for copying BLAKE-2 and SHA-3 objects (#135838) 2025-06-24 09:58:07 +02:00
Russell Keith-Magee
34393cbdd4
gh-135648: Document that shutil.copyfileobj doesn't flush (#135737)
Adds a note about flush/close on copyfileobj, and updates 
the Emscripten build script to follow documented advice.
2025-06-24 08:55:50 +08:00
Vincent Poulailleau
2793b68f75
Fix example according to PEP 750 in "What's new in 3.14" (GH-134727)
A redundant extra part was written. Added a closing tag, to match the usage in PEP 750.
2025-06-23 19:36:30 -04:00
Yongzi Li
caad163b69
Docs: Use arguments to replace args in argparse.rst (GH-135510) 2025-06-23 18:53:33 -04:00
Neil Schemenauer
ceae4edf81
gh-119786: Add InternalDocs/qsbr.md. (gh-135411)
Add internal doc for the Quiescent-State Based Reclamation (QSBR) implementation.
2025-06-23 22:09:40 +00:00
Noam Cohen
bda121862e
gh-131798: Optimize _UNARY_NEGATIVE (GH-135223) 2025-06-24 03:42:09 +08:00
Ken Jin
569fc6870f
gh-134584: Specialize POP_TOP by reference and type in JIT (GH-135761) 2025-06-24 00:57:14 +08:00
Kumar Aditya
99712c45cc
GH-124878: reenable test_finalize_daemon_thread_hang test under TSAN (#135793) 2025-06-23 21:38:57 +05:30
sobolevn
b3ae76911d
Bump mypy to 1.16.1 (#135720) 2025-06-23 15:29:30 +03:00
Bénédikt Tran
396ca9a641
gh-135823: improve error message in netrc security checks (#135827) 2025-06-23 12:49:27 +02:00
Petr Viktorin
6aa0826ed7
gh-89488: Add warning about Py_BuildValue("p") needing exact int (GH-135610) 2025-06-23 12:35:59 +02:00
Emma Smith
6ab842fce5
gh-134986: Catch PermissionError when trying to call perf in tests (#134987)
Using Ubuntu 24.04 on the Windows Subsystem for Linux, perf will raise a
`PermissionError` instead of `FileNotFoundError`. This commit modifies
the tests to catch that.
2025-06-23 12:28:05 +02:00
Kumar Aditya
0d9d48959e
add async generators section to asyncio internal docs (#135674) 2025-06-23 06:22:28 +00:00
Bénédikt Tran
621a8bd6a8
gh-135532: cleanup clinic module directives for cryptographic modules (#135822) 2025-06-22 20:04:38 +00:00
Bénédikt Tran
b57b619e34
gh-135815: skip netrc security checks if os.getuid is missing (#135816) 2025-06-22 19:48:06 +00:00
Bénédikt Tran
e7295a89b8
gh-135239: simpler use of mutexes in cryptographic modules (#135267) 2025-06-22 16:59:57 +02:00
Kattni
ac9d37c60b
patchcheck: use URL paths to identify upstream remote (GH-135806)
* find defined "(fetch)" remotes with "python/cpython" in their URL
* if there is exactly one, use that remote name
* if there is one named "upstream", "origin", or "python",
  use that remote (in that precedence order)
* otherwise report an error listing the defined remotes
2025-06-22 04:51:23 +00:00
Kumar Aditya
b14986c914
gh-130605: reenable test_concurrent_futures tests under TSAN (#135790) 2025-06-21 22:03:17 +05:30
Rafael Fontenelle
6a16b3c440
Docs: Remove unnecessary trailing backslashes (GH-135781)
This fixes Sphinx's gettext extraction for translations.
2025-06-21 09:01:14 -04:00
Bénédikt Tran
d08b4b2333
gh-135532: optimize calls to PyMem_Malloc in SHAKE digest computation (#135744)
- Add a fast path when the digest length is 0 to avoid calling useless functions.
- Directly allocate via `PyBytes_FromStringAndSize(NULL, length)` when possible.
2025-06-21 14:32:00 +02:00
Bénédikt Tran
7c4361564c
gh-135759: consistently reject negative sizes in SHAKE digests (#135767)
Passing a negative digest length to `_hashilb.HASHXOF.[hex]digest()` now
raises a ValueError instead of a MemoryError or a SystemError. This makes
the behavior consistent with that of `_sha3.shake_{128,256}.[hex]digest`.
2025-06-21 09:43:30 +00:00
Xuanteng Huang
13cac83347
gh-135557: use atomic stores in heapq operations in free-threading (#135601) 2025-06-21 14:13:15 +05:30
sobolevn
8ca1e4d846
gh-135645: Added supports_isolated_interpreters to sys.implementation (#135667)
Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
2025-06-21 10:56:14 +03:00
Hood Chatham
f4911258a8
gh-127146: Skip test_os.test_mode for Emscripten (#135764)
Temporarily skip test_os.test_mode on Emscripten; this fails consistently
on the buildbot, but not on other test configurations. Reported as #135783 
for follow up.
2025-06-21 06:06:59 +00:00
Marcell Perger
4ddf505d99
gh-135756: Fix nonexistent parameter in tkinter docs (#135770)
Remove nonexistent color parameter from tkinter.commondialog.Dialog.show() method documentation.
2025-06-20 18:45:36 -04:00
Eric Snow
c5ea8e8e8f
gh-135698: Fix Cross-interpreter Queue.full() With Negative/Default max_size (gh-135724)
We weren't handling non-positive maxsize values (including the default) properly
in Queue.full().  This change fixes that and adjusts an associated assert.
2025-06-20 14:26:32 -06:00
Kumar Aditya
a8ec511900
gh-135380: enhance critical section held assertions (#135381) 2025-06-20 22:43:23 +05:30
Pastukhov Nikita
3fb6cfe7a9
gh-135721: skip test_trashcan_python_class on wasm buildbots with stack overflow (#135766) 2025-06-20 20:06:01 +03:00
Tomas R.
61532b4bc7
gh-131798: JIT: Optimize _CALL_LEN when the length is known (#135260)
* Add news entry

* Optimize _CALL_LEN

* Simplify tests
2025-06-20 18:21:39 +02:00
Yuki Kobayashi
59963e866a
Docs: Document PyExceptionClass functions in the C API (GH-135697)
* Docs: Document `PyExceptionClass_Name`

`PyExceptionClass_Name` is an undocumented function in the limited API.

* Document `PyExceptionClass_Check`
2025-06-20 09:57:04 -04:00
Kumar Aditya
c825b5d989
gh-135748: use argument clinic for more socket methods (#135749) 2025-06-20 12:02:37 +00:00
Weilin Du
b881e3db1e
gh-89083: add links to RFC 9562 sections in UUID docs (#135684)
We also sync the docs for UUIDv1 and UUIDv6 concerning the node address and clock sequence.

---------

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-06-20 11:03:41 +00:00
Bénédikt Tran
eec7a8ff22
gh-135532: use _Py_strhex in HACL-MD5's hexdigest (#135742) 2025-06-20 09:50:09 +00:00
Bénédikt Tran
57dba7c9a5
gh-135532: update Modules/_hacl/python_hacl_namespaces.h (#135741) 2025-06-20 11:32:38 +02:00
Chris Eibl
82726600be
gh-135379: fix MSVC warning: conversion from 'stwodigits' to 'digit' (GH-135714)
fix warning C4244: 'initializing': conversion from

'stwodigits' to 'digit', possible loss of data
2025-06-20 17:05:33 +08:00
Bénédikt Tran
2dbada179f
gh-135532: simplify handling of HACL* errors in _hmac (#135740) 2025-06-20 10:57:16 +02:00
Ken Jin
b53b0c14da
gh-135608: Add a null check for attribute promotion to fix a JIT crash (GH-135613)
Co-authored-by: devdanzin <74280297+devdanzin@users.noreply.github.com>
2025-06-20 14:33:35 +08:00
Hood Chatham
c8c13f8036
gh-127146: Add skip_emscripten_stack_overflow in a few places (#135722)
More tests that hit stack limits on some platforms.
2025-06-20 05:27:02 +08:00
Nadeshiko Manju
1ddfe59320
gh-135543: Emit sys.remote_exec audit event when sys.remote_exec is called (GH-135544) 2025-06-19 21:23:38 +01:00
Tomas R.
bb9596fcfa
Add tomasr8 as a codeowner for AST, gettext and the Tier 2 optimizer (#135727) 2025-06-19 20:55:13 +01:00
Bénédikt Tran
c765683398
gh-135561: ensure that the GIL is held when handling an HACL* error in _hmac (#135562) 2025-06-19 17:27:19 +00:00
sobolevn
9c3c02019c
gh-135709: Fix two compile warnings on WASM buildbot (#135712) 2025-06-19 18:46:40 +03:00
Rafael Fontenelle
754190287e
Docs: Add missing lines between regex and text (GH-134505) 2025-06-19 11:01:29 -04:00
Andrii Hrimov
7cc8949692
gh-135273: Unify ZoneInfo.from_file signatures (#135274)
Align `ZoneInfo.from_file` pure-Python signature with Argument Clinic signature.
2025-06-19 16:47:35 +02:00
Ken Jin
0243260284
gh-135379: Move PyLong_CheckCompact to private header and rename it (GH-135707) 2025-06-19 13:09:09 +00:00
Rafael Fontenelle
ff639af8ee
Docs: Emphasize parameter name in pkgutil.iter_importers (GH-135597) 2025-06-19 08:56:43 -04:00
Ken Jin
1b969f6d57
gh-135379: Add back const cast to _PyLong_IsCompact (GH-135706) 2025-06-19 13:54:21 +02:00
Stan Ulbrych
13efe3f599
gh-133934: Mention special commands in sqlite3 .help message (GH-135224) 2025-06-19 13:47:29 +02:00
Stan Ulbrych
ecd83e02b1
gh-133439: Fix the error message in the sqlite3 CLI (GH-133807)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-06-19 13:46:33 +02:00
Mark Shannon
9731dd2c8d
GH-135379: Specialize int operations for compact ints only (GH-135668) 2025-06-19 11:10:29 +01:00
Victor Stinner
5c25c884b9
gh-126112: Fix test_os.TimerfdTests: use 10 ms resolution (#135681)
Use 10 ms for CLOCK_RES instead of 100 ms to tolerate slow buildbots.
2025-06-19 11:40:40 +02:00
Petr Viktorin
7a20c72cb6
gh-111758: Run UBSan in GitHub Actions (GH-135578)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-06-19 11:36:56 +02:00
Petr Viktorin
140731ff67
Document that PyType_GetModuleByDef returns a borrowed reference (GH-135666) 2025-06-19 09:00:41 +02:00
Eric Snow
725da50520
gh-133485: Use interpreters.Interpreter in InterpreterPoolExecutor (gh-133957)
Most importantly, this resolves the issues with functions and types defined in __main__.
It also expands the number of supported objects and simplifies the implementation.
2025-06-18 17:57:14 -06:00
Peter Bierma
15f2bac02c
gh-135450: Remove assertion in _PyCode_CheckNoExternalState (gh-135466)
The assertion reflected a misunderstanding of situations where "hidden" variables might exist,
namely generator expressions and comprehensions.
2025-06-18 17:31:23 -06:00
alexey semenyuk
e9b647dd30
gh-134538: Add link to shutil.rmtree example in function docs (GH-135540) 2025-06-18 22:10:20 +01:00
Sam Gross
17ac3933c3
gh-135641: Fix flaky test_capi.test_lock_two_threads test case (gh-135642)
The mutex may have the `_Py_HAS_PARKED` bit set.
2025-06-18 14:24:05 -04:00
Yuki Kobayashi
46c60e0d0b
Docs: Fix markups for emphasis (GH-135598)
The word emphasis character `_` is not supported as sphinx markup, so changed to `*`.
2025-06-18 13:32:43 -04:00
Kumar Aditya
4dea6b48cc
gh-135639: fix test_cycle test (#135662) 2025-06-18 22:11:35 +05:30
Serhiy Storchaka
c55512311b
gh-135376: Fix and improve test_random (GH-135377)
* Remove duplicated code. Tests for Random and SystemRandom now share
  the code.
* Move implementation agnostic tests that was only run for SystemRandom,
  so they are now run for Random too.
* Add tests for __index__() support.
* Add tests for randint().
2025-06-18 18:26:01 +03:00
Petr Viktorin
21f3d15534
gh-135676: lexical analysis: Improve section on Numeric literals (GH-134850) 2025-06-18 16:34:18 +02:00
Victorien
343719d98e
gh-135646: Raise consistent NameError exceptions in ForwardRef.evaluate() (#135663) 2025-06-18 13:00:55 +00:00
Duane Griffin
9877d191f4
gh-135335: flush stdout/stderr in forkserver after preloading modules (#135338)
If a preloaded module writes to stdout or stderr, and the stream is buffered,
child processes will inherit the buffered data after forking. Attempt to
prevent this by flushing the streams after preload.

Co-authored-by: Mikhail Efimov <efimov.mikhail@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-06-18 14:17:02 +02:00
Stan Ulbrych
5f6ab92465
gh-133390: Document SQLITE_KEYWORDS (GH-135659) 2025-06-18 12:56:49 +02:00
Russell Keith-Magee
1c7efaf58a
gh-134632: Add iOS/Android test skip for C API check for headers. (#135656)
iOS and Android don't ship headers in the testbed, so we can't test for their existence.
2025-06-18 14:21:14 +08:00
Hood Chatham
01c80b2650
gh-127146: Enable large files on Emscripten (#135635)
Large files have been fully supported by Emscripten for a long time.
2025-06-18 04:34:30 +00:00
Victorien
504ae606e1
gh-119180: Only fetch globals and locals if necessary in annotationlib.get_annotations() (#135644) 2025-06-17 20:29:13 -07:00
Hood Chatham
e4ccd46bf7
gh-127146: Emscripten: Fix pathlib glob_dotdot test (#135624)
The Emscripten path resolver uses the same mechanism for resolving `..`
at a file system root as for resolving symlinks. This is because
roots don't store their mountpoints. If the parent of a node is itself,
it is a root but it might be a mountpoint in some other file system.

If a path has enough `..`'s at the root, it will return ELOOP.
Enough turns out to be 49.
2025-06-18 11:20:43 +08:00
Hood Chatham
ce58afb400
gh-127146: Emscripten: Fix test failure due to missing os.link (#135626)
Check for existence of os.link, rather than assuming it exists.
2025-06-18 03:19:23 +00:00
Hood Chatham
2a49c54ab2
gh-127146: Emscripten: Skip test_url2pathname_resolve_host (#135634)
Emscripten currently `gethostbyname_r()` returns an incorrect
IP address for `localhost`. Will be resolved by upstream PR:
https://github.com/emscripten-core/emscripten/pull/24593
2025-06-18 10:59:01 +08:00
Hood Chatham
28c71ee4b2
gh-127146: Allow ignored keys to be missing in test_sysconfig (#135622)
Fixes the test on Emscripten where userbase can be missing.
2025-06-18 10:51:46 +08:00
Vladyslav Lazoryk
7117002591
gh-135627: Remove documentation for LOAD_CONST_IMMORTAL opcode (GH-135632)
Remove documentation for LOAD_CONST_IMMORTAL opcode
2025-06-18 10:39:41 +08:00
Donghee Na
52be7f445e
gh-133931: Introduce _PyObject_XSetRefDelayed to replace Py_XSETREF (gh-134377) 2025-06-18 08:36:02 +09:00
Kumar Aditya
cb39410111
Initial internal asyncio docs (#135469)
Currently focused on `_asynciomodule.c` but could also receive updates about internals of the Python package.
2025-06-17 12:21:41 -07:00
Eric Snow
269e19e0a7
gh-132775: Fix Interpreter.call() __main__ Visibility (gh-135595)
As noted in the new tests, there are a few situations we must carefully accommodate
for functions that get pickled during interp.call().  We do so by running the script
from the main interpreter's __main__ module in a hidden module in the other
interpreter.  That hidden module is used as the function __globals__.
2025-06-17 13:16:59 -06:00
Ken Jin
fba5dded6d
gh-134584: Decref elimination for float ops in the JIT (GH-134588)
This PR adds a PyJitRef API to the JIT's optimizer that mimics the _PyStackRef API. This allows it to track references and their stack lifetimes properly. Thus opening up the doorway to refcount elimination in the JIT.
2025-06-17 23:25:53 +08:00
Mark Shannon
8dd8b5c2f0
GH-135379: Support limited scalar replacement for replicated uops in the JIT code generator. (GH-135563)
* Use it to support efficient specializations of COPY and SWAP in the JIT.
2025-06-17 13:43:09 +01:00
PuQing
a9e66a7c50
gh-132815: Add support for JUMP_BACKWARD in specialization stats (#135606) 2025-06-17 14:11:09 +02:00
Emma Smith
acc20a83f4
gh-134262: Catch both URLError and ConnectionError in retries (#135365) 2025-06-17 14:51:23 +03:00
Michał Górny
0d582def34
gh-134632: Fix build-details.json to use INCLUDEPY path (#134633)
* gh-134632: Fix `build-details.json` to use `INCLUDEPY` path

Fix ``build-details.json`` generation to use ``INCLUDEPY``, in order to
reference the ``pythonX.Y`` subdirectory of the include directory, as
required in :pep:`739`, instead of the top-level include directory.

* test_build_details: Add tests for the c_api section

* test_build_details: Expect pkgconfig for CPython unconditionally
2025-06-17 08:05:04 +00:00
Hugo van Kemenade
c51f241c97
gh-123299: Add PEP 779 to What's New in Python 3.14 (#135555) 2025-06-17 09:02:35 +03:00
PuQing
5b3a826888
gh-135489: Show verbose output for failing tests during PGO profiling step with --enable-optimizations (#135512) 2025-06-17 01:06:48 -04:00
Ned Deily
7c685894cd
gh-119132: Update 'Using Python on macOS' documentation. (#135591)
Remove `experimental` qualification for free-threading in the document text. Note that images included in the document will be updated later in the release cycle.
2025-06-16 19:35:59 -04:00
Eric Snow
a450a0ddec
gh-135443: Sometimes Fall Back to __main__.__dict__ For Globals (gh-135491)
For several builtin functions, we now fall back to __main__.__dict__ for the globals
when there is no current frame and _PyInterpreterState_IsRunningMain() returns
true.  This allows those functions to be run with Interpreter.call().

The affected builtins:

* exec()
* eval()
* globals()
* locals()
* vars()
* dir()

We take a similar approach with "stateless" functions, which don't use any
global variables.
2025-06-16 17:34:19 -06:00
Hood Chatham
68b7e1a667
gh-128627: Emscripten: Add missing semicolon in ios detection code (#135590) 2025-06-16 23:17:17 +00:00
Peter Bierma
730133a0ac
Add Peter Bierma as a codeowner for the object and runtime lifecycle (#135588) 2025-06-17 00:03:53 +01:00
Hugo van Kemenade
21bac3aecd
Use replacements to update versions in "Using Python on macOS" (#130400) 2025-06-16 18:07:25 -04:00
Sam Gross
d8994b0a77
gh-132617: Fix dict.update() mutation check (gh-134815)
Use `ma_used` instead of `ma_keys->dk_nentries` for modification check
so that we only check if the dictionary is modified, not if new keys are
added to a different dictionary that shared the same keys object.
2025-06-16 12:55:20 -04:00
sobolevn
4c15505071
gh-135513: Fix unused variable warning in crossinterp.c (#135514) 2025-06-16 18:12:20 +02:00
Donghee Na
f079979599
gh-119132: Remove "experimental" tag from the CPython free-threading. (gh-135550)
* gh-119132: Remove "experimental" tag from the CPython free-threading build

* Address code review

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>

* Add NEWS.d

* Regen configure.ac

* Update doc

* Update

* Update

* Update

* Update Doc/howto/free-threading-python.rst

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>

* Update ctypes.rst

* Update

* Update Doc/howto/free-threading-python.rst

Co-authored-by: T. Wouters <thomas@python.org>

* Apply suggestions from code review

Co-authored-by: T. Wouters <thomas@python.org>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>

---------

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: T. Wouters <thomas@python.org>
2025-06-16 23:32:52 +09:00
Rafael Fontenelle
b102f091fe
gh-120608: fix NEWS entry typo (#135535) 2025-06-16 13:11:49 +03:00
Nadeshiko Manju
667a86e076
gh-131798: JIT: replace _CHECK_METHOD_VERSION with _CHECK_FUNCTION_VERSION_INLINE (GH-135022)
Signed-off-by: Manjusaka <me@manjusaka.me>
Co-authored-by: Brandt Bucher <brandtbucher@gmail.com>
2025-06-16 13:25:50 +08:00
Dan Lenski
60181f4ed0
gh-67022: Document bytes/str inconsistency in email.header.decode_header() and suggest email.headerregistry.HeaderRegistry as a sane alternative (#92900)
* gh-67022: Document bytes/str inconsistency in email.header.decode_header()

This function's possible return types have been surprising and error-prone
for the entirety of its Python 3.x history. It can return either:

1. `typing.List[typing.Tuple[bytes, typing.Optional[str]]]` of length >1
2. or `typing.List[typing.Tuple[str, None]]`, of length exactly 1

This means that any user of this function must be prepared to accept either
`bytes` or `str` for the first member of the 2-tuples it returns, which is a
very surprising behavior in Python 3.x, particularly given that the second
member of the tuple is supposed to represent the charset/encoding of the
first member.

This patch documents the behavior of this function, and adds test cases
to demonstrate it.

As discussed in bpo-22833, this cannot be changed in a backwards-compatible
way, and some users of this function depend precisely on the existing
behavior.

Add warnings about obsolescence of 'email.header.decode_header' and 'email.header.make_header' functions.

Recommend use of `email.headerregistry.HeaderRegistry` instead, as suggested
in https://github.com/python/cpython/pull/92900#discussion_r1112472177
2025-06-15 15:29:38 -04:00
Bénédikt Tran
54e29ea4eb
gh-111178: fix UBSan failures for RemoteUnwinderObject (#135539) 2025-06-15 21:00:58 +02:00
Nadeshiko Manju
076f87468a
gh-135361: update documentation for remote_debugger_script audit event (#135362) 2025-06-15 20:49:49 +02:00
Pablo Galindo Salgado
b9a1b04982
gh-135371: Clean tags from pointers in all cases in remote debugging module (#135534) 2025-06-15 18:32:32 +00:00
Jacob Austin Lincoln
81237fbcf6
gh-65697: Improved error msg for configparser key validation (#135527)
* Improved error msg for configparser key validation and added note in 3.14 whatsnew

* Properly added change to configparser

* 📜🤖 Added by blurb_it.

---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2025-06-15 12:13:19 -04:00
Jeremy Cline
2bd3895fca
gh-127319: Disable port reuse on HTTP, XMLRPC, and logging TCP servers (GH-135405)
Prior to issue #120485 these servers did not allow port reuse, which
makes sense as the behavior of port reuse is surprising if you're not
expecting it. It's unclear to me why these services were switched to
allow port reuse, but I believe the desired behavior (unless subclasses
opt in) is to not allow port reuse.

See also: https://bugzilla.redhat.com/show_bug.cgi?id=2323170
2025-06-15 06:34:29 +01:00
Serhiy Storchaka
8979d3afe3
gh-135171: Update documentation for the generator expression (GH-135351)
* gh-135171: Update documentation for the generator expression

Document that the iterator for the leftmost "for" clause is created
immediately.

* Update Doc/reference/expressions.rst

Co-authored-by: Brian Skinn <brian.skinn@gmail.com>

---------

Co-authored-by: Brian Skinn <brian.skinn@gmail.com>
2025-06-14 17:32:44 -07:00
Caleb Xu
2e15a50851
gh-135497: fix MAXLOGNAME detection in configure.ac (#135508) 2025-06-14 16:04:16 +00:00
sobolevn
fc413ecb8f
gh-135504: Document LIBZSTD_CFLAGS and LIBZSTD_LIBS config options (#135505) 2025-06-14 16:07:19 +01:00
Pablo Galindo Salgado
028309fb47
gh-135371: Fix asyncio introspection output to include internal coroutine chains (#135436) 2025-06-14 13:48:25 +01:00
Ken Jin
7b15873ed0
gh-135474: Specialize arithmetic only on compact ints (GH-135479)
Specialize arithmetic only on compact ints. This also makes int operations non-escaping in the JIT and in tier 1.
2025-06-14 17:13:32 +08:00
sobolevn
c8319a3fea
gh-135368: Fix mocks on dataclass specs with instance=True (#135421)
* gh-135368: Fix mocks on dataclass specs with `instance=True`

* Extend dataclass mock_methods

---------

Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
2025-06-14 09:46:43 +01:00
GiGaGon
c2bb3f9843
gh-135496: Fix f string exclamation mark error typo (#135495) 2025-06-14 00:40:42 -04:00
Eric Snow
56eabea056
gh-135437: Account For Duplicate Names in _PyCode_SetUnboundVarCounts() (gh-135438) 2025-06-13 16:47:49 -06:00
Eric Snow
c7f4a80079
gh-132775: Clean Up Cross-Interpreter Error Handling (gh-135369)
In this refactor we:

* move some code around
* make a couple of typedefs opaque
* decouple errors from session state
* improve tracebacks for propagated exceptions

This change helps simplify several upcoming changes.
2025-06-13 16:45:21 -06:00
Serhiy Storchaka
6eb6c5dbfb
gh-135462: Fix quadratic complexity in processing special input in HTMLParser (GH-135464)
End-of-file errors are now handled according to the HTML5 specs --
comments and declarations are automatically closed, tags are ignored.
2025-06-13 19:57:48 +03:00
Blaise Pabon
14c1d093d5
gh-106318: Add example for str.expandtabs() (#134525) 2025-06-13 18:44:21 +03:00
Steve Dower
afc5ab6cce
gh-135455: Fix version and architecture detection in PC/layout script. (GH-135461) 2025-06-13 16:04:43 +01:00
Petr Viktorin
f4bc3a9320
gh-134160: Split extension module init from PyModule docs; emphasize multi-phase init (GH-135126)
Document behaviour of single-phase init. Call it "legacy".

Reorganize PyModule docs.

Move PyInit_modulename docs from the tutorial to reference documentation.

Move PyMODINIT_FUNC docs from generic macros to the new page.

Add doc stubs for `PYTHON_API_VERSION` & `PYTHON_ABI_VERSION`

Remove incorrect refcounts.dat entry for `PyModuleDef_Init`.
This removes the "Return value: Borrowed reference." note.
Instead, note that the function sometimes returns a borrowed reference,
sometimes as strong one.
(IMO, it's best to not think of `PyModuleDef` as a `PyObject` at all,
and act like it can't be reference-counted.)


Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-06-13 16:39:35 +02:00
LamentXU
394d7985da
gh-135244: improve wording of uuid8 docs about CSPRNG (#135433) 2025-06-13 16:06:11 +02:00
Sergey B Kirpichev
c646846c1e
gh-126703: Add freelist for PyComplexObject's (gh-135233) 2025-06-13 22:32:26 +09:00
Blaise Pabon
eed827ed09
gh-106318: Add example for str.endswith() (#134523)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-06-13 11:54:16 +00:00
Blaise Pabon
273459562e
gh-106318: Add example for str.encode() (#134520)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-06-13 11:32:07 +00:00
Sergey B Kirpichev
747d390045
gh-135308: clarify math.issubnormal() description (GH-135324) 2025-06-13 08:30:44 +02:00
Zanie Blue
2b0c684e07
GH-134273: Allow setting JIT compiler flags at build time with CFLAGS_JIT (GH134276) 2025-06-12 16:11:08 -07:00
Peter Bierma
73431356d3
Revert "gh-135410: use a critical section around StringIO.__next__ (#135412)" (#135439)
This reverts commit e6c3039cb3.
2025-06-13 07:32:27 +09:00
Tian Gao
b03309fe5f
gh-135429: Fix the argument mismatch in lsprof throw event (#135442) 2025-06-12 14:46:47 -07:00
Eric Hanchrow
f273fd77d7
doc: Remove what was essentially duplicate wording. (GH-135431) 2025-06-12 18:47:12 +01:00
Petr Viktorin
e7a3c20b92
gh-133390: Support SQL keyword completion for sqlite3 CLI (GH-133393) (GH-135292)
Co-authored-by: Tan Long <tanloong@foxmail.com>
2025-06-12 16:28:30 +02:00
Peter Bierma
e6c3039cb3
gh-135410: use a critical section around StringIO.__next__ (#135412) 2025-06-12 16:41:05 +05:30
Gyeongjae Choi
d447129758
gh-128627: Fix iPad detection in wasm-gc (#135388)
On some iPad versions, Safari reports as "macOS". Modifies the GC trampoline detection
to add a feature-based check to detect this case.
2025-06-12 04:04:13 +00:00
Victorien
71f5fafdfb
Fix presentation of dataclasses' unsafe_hash default value (#116532)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-06-11 21:30:33 -04:00
Eric Snow
62143736b6
gh-134939: Add the concurrent.interpreters Module (gh-133958)
PEP-734 has been accepted (for 3.14).

(FTR, I'm opposed to putting this under the concurrent package, but
doing so is the SC condition under which the module can land in 3.14.)
2025-06-11 17:35:48 -06:00
Malcolm Smith
b706ff003c
gh-133264: Correct documentation of how Py_Main and Py_RunMain handle SystemExit (#135337) 2025-06-11 17:23:47 +02:00
Mark Shannon
c87b5b2cb6
GH-135379: Remove types from stack items in code generator. (GH-135384)
* Make casts explicit in the instruction definitions
2025-06-11 15:52:25 +01:00
Petr Viktorin
49d72365cd
gh-127545: Add _Py_ALIGNED_DEF(N, T) and use it for PyObject (GH-135209)
* Replace _Py_ALIGN_AS(V) by _Py_ALIGNED_DEF(N, T)

This is now a common façade for the various `_Alignas` alternatives,
which behave in interesting ways -- see the source comment.

The new macro (and MSVC's `__declspec(align)`) should not be used
on a variable/member declaration that includes a struct declaraton.
A workaround is to separate the struct definition.
Do that for `PyASCIIObject.state`.

* Specify minimum PyGC_Head and PyObject alignment

As documented in InternalDocs/garbage_collector.md, the garbage collector
stores flags in the least significant two bits of the _gc_prev pointer
in struct PyGC_Head. Consequently, this pointer is only capable of storing
a location that's aligned to a 4-byte boundary.

Encode this requirement using _Py_ALIGNED_DEF.

This patch fixes a segfault in m68k, which was previously investigated
by Adrian Glaubitz here:
https://lists.debian.org/debian-68k/2024/11/msg00020.html
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1087600
Original patch (using the GCC-only Py_ALIGNED) by Finn Thain.

Co-authored-by: Finn Thain <fthain@linux-m68k.org>
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
2025-06-11 12:44:58 +02:00
Justin Applegate
2b8b4774d2
gh-135321: Always raise a correct exception for BINSTRING argument > 0x7fffffff in pickle (GH-135322)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-06-11 10:15:12 +00:00
Serhiy Storchaka
5ae669fc4e
gh-135326: Test support of __index__ in random.getrandbits() (#135356) 2025-06-10 18:51:08 -07:00
Serhiy Storchaka
0f866cbfef
gh-133967: Do not normalize locale name 'C.UTF-8' to 'en_US.UTF-8' (#135347) 2025-06-10 13:38:32 +00:00
Pablo Galindo Salgado
ff2b5f40c2
gh-130077: Properly match full soft keywords in the parser (#135317) 2025-06-10 14:19:03 +01:00
Ajay Kamdar
598aa7cc98
gh-132969: Fix error/hang when shutdown(wait=False) and task exited abnormally (GH-133222)
When shutdown is called with wait=False, the executor thread keeps running
even after the ProcessPoolExecutor's state is reset. The executor then tries
to replenish the worker processes pool resulting in an error and a potential hang
when it comes across a worker that has died. Fixed the issue by having
_adjust_process_count() return without doing anything if the ProcessPoolExecutor's
state has been reset.

Added unit tests to validate two scenarios:
max_workers < num_tasks (exception)
max_workers > num_tasks (exception + hang)
2025-06-10 13:28:31 +02:00
Erlend E. Aasland
ee7345d507
gh-118928: Amend sqlite3 execute*() deprecation notes (#135163) 2025-06-10 13:24:33 +02:00
Alexander Shadchin
c23eec2960
Docs: fix docstring of email.message.Message.add_header (#134355) 2025-06-10 12:35:37 +02:00
Bénédikt Tran
754e7c9b51
gh-133157: remove usage of _Py_NO_SANITIZE_UNDEFINED in Parser/pegen.c (#134048) 2025-06-10 01:08:30 +01:00
Chris Eibl
49fc1f215a
Fix warnings set but not used [-Wunused-but-set-variable] in remote_debug.h (#135290) 2025-06-10 01:05:06 +01:00
Zanie Blue
2e1ad6eb26
Fix definition of _Py_RemoteDebug_ symbols for static linking (#135146) 2025-06-10 01:03:55 +01:00
Alper
a58026a5e3
gh-116738: Make _heapq module thread-safe (#135036)
Use critical sections to make heapq methods that update the heap thread-safe when the GIL is disabled.

---------

Co-authored-by: mpage <mpage@meta.com>
2025-06-09 10:57:29 -07:00
Chris Eibl
cc8e6d2703
GH-131296: Suppress clang-cl warnings in socketmodule.c (GH-131821) 2025-06-09 17:38:41 +01:00
Petr Viktorin
28d91d06f1
gh-127833: Reword and expand the Notation section (GH-134443)
Prepare the docs for using the notation used in the `python.gram`
file. If we want to sync the two, the meta-syntax should be the same.

Link the Full Grammar docs here; keep only a few extras.

Also, remove the distinction between lexical and syntactic rules,
except for whitespace handling.
With f- and t-strings, the line between the two is blurry.

Co-authored-by: Blaise Pabon <blaise@gmail.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
Co-authored-by: Colin Marquardt <cmarqu42@gmail.com>
2025-06-09 15:50:11 +02:00
Wulian233
f90483e13a
gh-135001: Explicitly specify the encoding parameter value of calendar.HTMLCalendar as 'utf-8' (#135002) 2025-06-09 15:40:09 +02:00
Victor Stinner
aaad2e81ce
gh-133968: Update PyUnicodeWriter_WriteASCII() documentation (#135297)
The function was added to Python 3.14.
2025-06-09 14:47:02 +02:00
Chris Eibl
0045100ccb
GH-135287: clang-cl PGO builds on Windows fail with could not open '/GENPROFILE' (GH-135289) 2025-06-09 12:52:38 +01:00
Noam Cohen
b150b6aca7
gh-131798: Optimize _UNARY_INVERT (GH-135222) 2025-06-09 18:33:18 +08:00
Bénédikt Tran
c19e36cc4e
gh-131316: fix invalid DECREF in _md5.md5.copy() (#135291)
This amends commit 261633bd3f.
2025-06-09 09:10:32 +00:00
Edward Z. Yang
8441b263af
bpo-45210: Document that error indicator may be set in tp_dealloc (#28358)
Signed-off-by: Edward Z. Yang <ezyang@fb.com>
Signed-off-by: Edward Z. Yang <ezyang@meta.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-06-09 08:56:32 +00:00
Bénédikt Tran
3cb109796d
gh-135004: rewrite and cleanup blake2module.c (#135006)
* Cleanup imports and update module docstring.
* Simplify detection of SIMD support.
* Correctly guard `update()` cases.
* Rewrite `py_blake2b_or_s_new` and rename it to `py_blake2_new`.
* Rewrite `blake2_blake2b_copy_locked` and `py_blake2_clear`.
* Refactor computations of `digest` and `hexdigest`.
* Simplify `py_blake2b_get_name` and `py_blake2b_get_block_size`.
* Add `hacl_get_blake2_info` to extract static BLAKE-2 information.
   This new helper is used by `py_blake2b_get_digest_size`, but can
   be later used to expose `key_length` more easily.
2025-06-09 09:17:43 +02:00
Bénédikt Tran
83b94e856e
gh-135234: improve _hashlib exceptions when reporting an OpenSSL function failure (#135250)
- Refactor `get_openssl_evp_md_by_utf8name` error branches.
- Refactor `HASH.{digest,hexdigest}` computations.
- Refactor `_hashlib_HASH_copy_locked` and `locked_HMAC_CTX_copy`.
2025-06-09 09:13:29 +02:00
Ezio Melotti
2677dd017a
Use f-strings in csv docs example (#135245) 2025-06-08 15:28:37 -07:00
Vladyslav Lazoryk
8d17a412da
gh-135263: Fix typo in token.NAME documentation (#135275) 2025-06-08 22:59:26 +03:00
Jason R. Coombs
8d6eb0c262
gh-135276: Refresh zipfile.Path from zipp 3.23 (#135277)
Apply changes from zipp 3.23
2025-06-08 19:20:20 +00:00
Alper
aac22ea212
Add compile_commands.json to .gitignore (#135111) 2025-06-08 17:55:12 +01:00
Stan Ulbrych
254bdac711
Update tutorial for new "Copy" button (#135007)
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
2025-06-08 19:33:19 +03:00
Bénédikt Tran
aee45fd03f
gh-134531: refactor _hashlib logic for handling NIDs and EVP_MDs (#135254) 2025-06-08 12:34:57 +00:00
Yongzi Li
158e5162bf
gh-134976: document the exception type that can be raised by s[i] (#134977) 2025-06-08 14:28:55 +02:00
LamentXU
1cb7163872
gh-135244: generate UUID random Node ID with a CSPRNG as per RFC 9562, §6.10.3 (#135226)
This aligns with the recommendations of RFC 9562, Section 6.10, paragraph 3 [1].

[1]: https://www.rfc-editor.org/rfc/rfc9562.html#section-6.10-3.

---------

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-06-08 11:46:16 +00:00
Bénédikt Tran
4372011928
gh-134531: fix _hashlib clinic directive post GH-134626 (#135249) 2025-06-08 07:43:32 +00:00
Jiucheng(Oliver)
bcb6b45cb8
gh-134151 Fix TypeError in email.utils.decode_params when sorting RFC 2231 continuations (#134687)
- Fix sorting logic in `email.utils.decode_params` to handle None values.
- Update tests for RFC 2231 continuation sorting.
2025-06-08 09:13:21 +02:00
Bénédikt Tran
d610f11d21
gh-133579: correctly report C curses errors in _curses_panel (#134629)
This is a follow-up to ee36db5500.
2025-06-08 09:10:52 +02:00
Amit Lavon
8fdbbf8b18
GH-131798: Type-propagate string/list/tuple slices (GH-134671) 2025-06-07 14:08:44 -07:00
Daniel Golding
ac9c3431cc
gh-134876: Add fallback for when process_vm_readv fails with ENOSYS (#134878) 2025-06-07 19:32:06 +01:00
Petr Viktorin
24069fbca8
Revert "gh-133390: Support SQL keyword completion for sqlite3 CLI (#133393)" temporarily (GH-135232)
This reverts commit 62b3d2d443,
which broke buildbots
2025-06-07 08:56:43 +00:00
Tomas R.
46151648ca
GH-131798: Optimize away type(x) in the JIT when the result is known (GH-135194) 2025-06-06 16:44:43 -07:00
Yuki Kobayashi
f00512db20
Docs: Update PyExc_* tables in the c-api documentation (GH-131640)
Add `PyExc_BaseExceptionGroup` and `PyExc_EncodingWarning`
2025-06-06 17:51:47 +02:00
Tan Long
62b3d2d443
gh-133390: Support SQL keyword completion for sqlite3 CLI (#133393) 2025-06-06 16:52:41 +02:00
Petr Viktorin
b22b964a5c
gh-57089: Note _layout_ in the bitfield docs (GH-134148)
Co-authored-by: Meador Inge <meadori@gmail.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2025-06-06 16:51:40 +02:00
Petr Viktorin
1adca08d65
gh-134160: Use PyModuleDef.m_free in the example module xxlimited (GH-135174)
Co-authored-by: neonene <53406459+neonene@users.noreply.github.com>
2025-06-06 14:08:58 +00:00
Petr Viktorin
e413e26719
gh-134891: Add PyUnstable_Unicode_GET_CACHED_HASH (GH-134892) 2025-06-06 15:51:00 +02:00
Jean-Louis GUENEGO
343182853f
feat(docs): type fix - apply pep8 by using docstring instead of comment in the doc. (#135181)
Giving the right example incitates the tutorial readers to do the same in the future.
2025-06-06 15:16:12 +02:00
Rafael Fontenelle
39859fcac5
Fix versionadded directive rendering in c-api/arg.rst (#135199) 2025-06-06 14:23:07 +02:00
Victor Stinner
82415acf62
gh-134036: Update test_syntax for gh-133999 (#135204) 2025-06-06 12:22:14 +00:00
Victor Stinner
e004cf8fd5
gh-134993: Add os.lstat() to os.supports_dir_fd (#135188) 2025-06-06 14:11:49 +02:00
Serhiy Storchaka
6ef06fad84
gh-135120: Add test.support.subTests() (GH-135121) 2025-06-06 13:52:48 +02:00
sobolevn
0d9ccc87a2
gh-134036: Improve error messages for invalid raise statements (#134077) 2025-06-06 01:51:06 +01:00
Weipeng Hong
a7d41e8aab
gh-135155: Added dependencies required for compiling the _zstd module (GH-135156) 2025-06-06 00:44:25 +00:00
Mark Shannon
b90ecea9e6
GH-132554: Fix tier2 FOR_ITER implementation and optimizations (GH-135137) 2025-06-05 18:53:57 +01:00
Sergey Miryanov
d9cad074d5
gh-134155: fix AttributeError in email._header_value_parser.get_address (#134194)
Append the defect to defects instead of to the parse tree.

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-06-05 13:28:11 -04:00
Weipeng Hong
1b55e12766
gh-135166: Fix exception type expected by test.test_zstd (GH-135167) 2025-06-05 17:00:07 +01:00
rialbat
8919cb4ad9
gh-135161: Remove redundant NULL check for 'exc' after dereference in ceval.c (#135162) 2025-06-05 17:08:48 +02:00
Victor Stinner
9258f3da91
gh-134989: Fix Py_RETURN_NONE in the limited C API (GH-135165)
Fix Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE macros in the
limited C API 3.11 and older:
Don't treat Py_None, Py_True and Py_False as immortal.
2025-06-05 14:43:47 +02:00
Emma Smith
4b44b3409a
gh-134938: Add set_pledged_input_size() to ZstdCompressor (GH-135010) 2025-06-05 14:31:49 +03:00
Victor Stinner
3d396ab759
gh-135124: Change stdout errors in regrtest worker process (#135138)
Set sys.stdout encoder error handler to backslashreplace in regrtest
workers to avoid UnicodeEncodeError when printing a traceback
or any other non-encodable character.

Move the code from the Regrtest class to setup_process().

Call setup_process() earlier, before displaying regrtest headers.
2025-06-05 11:17:03 +02:00
Malcolm Smith
2e1544fd2b
gh-131531: android.py enhancements to support cibuildwheel (#132870)
Modifies the environment handling and execution arguments of the Android management
script to support the compilation of third-party binaries, and the use of the testbed to 
invoke third-party test code.

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
2025-06-05 13:46:16 +08:00
mpage
6b77af257c
gh-134889: Fix handling of a few opcodes when optimizing LOAD_FAST (#134958)
We were incorrectly handling a few opcodes that leave their operands on the stack. Treat all of these conservatively; assume that they always leave operands on the stack.
2025-06-04 16:07:58 -07:00
T. Wouters
e598eecf4c
gh-135144: Add _remote_debugging to the MSI (legacy) Windows installers. (#135145)
Add _remote_debugging to the MSI (legacy) installers.
2025-06-04 21:39:00 +02:00
Brett Cannon
a10b321a58
Update the devcontainer image to the latest version (GH-135143)
Fixes an issue where the WASI tools were being incorrectly installed under the ARM image.
2025-06-04 17:06:10 +00:00
Terry Jan Reedy
0df15d0d4d
gh-129876: Update IDLE News3.txt to May 2025 (#135139) 2025-06-04 11:26:19 -04:00
Victor Stinner
c21113072c
gh-134989: Implement PyObject_DelAttr() as a macro in the limited C API (GH-135021) 2025-06-04 15:07:52 +02:00
Thomas Grainger
40c8be0008
gh-126483: disable warnings filters mutation in concurrent test (GH-132694)
The `test_ssl_in_multiple_threads` test failed because `test_check_hostname_idn()`
modified the global warnings filters via `warnings_helper.check_no_resource_warning()`.
Only check for warnings when the context aware warnings feature is enabled, which makes
the warnings filter context-local and thread-safe.
2025-06-04 09:00:25 -04:00
Daniel Hollas
bc00ce941e
gh-135074: Fix exception messages in test.support module (GH-135076) 2025-06-04 14:58:34 +02:00
Furkan Onder
5b3865418c
gh-135108: Fix utmp.h inclusion in posixmodule.c on NetBSD (GH-135109) 2025-06-04 08:51:18 -04:00
Pablo Galindo Salgado
1f51510444
Use a more clear example for the PEP 758 what's new section (#135118) 2025-06-04 09:23:08 +00:00
Sam Gross
cc581f32bf
gh-135099: Only wait on _PyOS_SigintEvent() in main thread (GH-135100)
On Windows, the `_PyOS_SigintEvent()` event handle is used to interrupt
the main thread when Ctrl-C is pressed. Previously, we also waited on
the event from other threads, but ignored the result. However, this can
race with interpreter shutdown because the main thread closes the handle
in `_PySignal_Fini` and threads may still be running and using mutexes
during interpreter shtudown.

Only use `_PyOS_SigintEvent()` in the main thread in parking_lot.c, like
we do in other places in the CPython codebase.
2025-06-04 09:35:56 +02:00
Christian Veenhuis
8f778f7bb9
gh-135103: Remove an unused local variable in Lib/code.py (GH-135104)
remove unused local variable
2025-06-04 13:57:31 +09:00
Joe Rickerby
dba9de731b
gh-135101: When choosing the default simulator device, don't use simctl --set testing (#135102)
On a fresh Xcode install (including some CI provider configurations), there is
no pre-existing testing set that can be used to identify simulator models. Use
the default device set to detect available models instead. Live testing 
simulators are still created in the testing set.
2025-06-04 08:31:43 +08:00
Duane Griffin
1ffe913c20
gh-127081: use getlogin_r if available (gh-132751)
The `getlogin` function is not thread-safe: replace with `getlogin_r` where
available.
2025-06-03 13:28:58 -04:00
tpburns
54ca55978e
gh-134248 test_getallocatedblocks pre-check to ignore immortalized strings (#134871)
When sanity checking against gettotalrefcount(), we exclude the blocks for
immortalized strings since their references are not tracked/reported. This
now matches refleak.py's book-keeping using the same functions.
2025-06-03 18:00:25 +02:00
Łukasz Langa
3612d8f517
gh-135034: Normalize link targets in tarfile, add os.path.realpath(strict='allow_missing') (#135037)
Addresses CVEs 2024-12718, 2025-4138, 2025-4330, and 2025-4517.

Signed-off-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Seth Michael Larson <seth@python.org>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-06-03 12:42:11 +02:00
Roei Ben Artzi
ec12559eba
gh-131884: Fix incorrect formatting in json.dumps() when using indent and skipkeys=True (GH-132200) 2025-06-03 10:40:25 +03:00
stratakis
485b499610
gh-128605: Add branch protections for x86_64 in asm_trampoline.S (#128606)
Apply Intel Control-flow Technology for x86-64 on asm_trampoline.S.

Required for mitigation against return-oriented programming (ROP)
and Call or Jump Oriented Programming (COP/JOP) attacks.

Manual application is required for the assembly files.

See also: https://sourceware.org/annobin/annobin.html/Test-cf-protection.html
2025-06-03 09:09:43 +02:00
Victor Stinner
6e80f11eb5
gh-135028: Increase parser MAXSTACK for nested parenthesis (#135031) 2025-06-03 08:40:45 +02:00
Donghee Na
b525e31b7f
gh-134875: Fix mimallc build error for the old compilers (gh-134994) 2025-06-03 08:40:40 +09:00
Stan Ulbrych
0ac9e17fb4
gh-134830: Fix reference in Doc/extending/windows.rst (GH-134831)
Co-authored-by: Miro Hrončok <miro@hroncok.cz>
2025-06-03 00:08:20 +02:00
Serhiy Storchaka
df98a47a61
gh-132813: Improve error messages for incorrect types and values of csv.Dialog attributes (GH-133241)
Make them similar to PyArg_Parse error messages, mention None as
a possible value, show a wrong type and the string length.
2025-06-02 23:35:41 +03:00
Serhiy Storchaka
e814f43f2c
gh-74232: Add a note about roundtrip of non-float numerics in CSV (GH-134963) 2025-06-02 23:31:06 +03:00
Serhiy Storchaka
7a79f52d83
gh-133454: Mark test_queue tests with many threads as bigmem (gh-134575)
50 producer and 50 consumer threads need more than 5GB of memory.
2025-06-02 23:25:32 +03:00
Rafael Fontenelle
c7051a3669
Remove newline in Doc/c-api/lifecycle.rst for gettext builder (GH-135013) 2025-06-02 21:13:08 +03:00
Serhiy Storchaka
0cec424af5
gh-66234: Add flag to disable the use of mmap in dbm.gnu (GH-135005)
This may harm performance, but improve crash tolerance.
2025-06-02 21:08:26 +03:00
Duane Griffin
44fb7c361c
gh-134908: Protect textiowrapper_iternext with critical section (gh-134910)
The `textiowrapper_iternext` function called `_textiowrapper_writeflush`, but did not
use a critical section, making it racy in free-threaded builds.
2025-06-02 17:22:41 +00:00
Łukasz Langa
055827528f
gh-130999: Fix globals() poisoning in test_traceback (gh-135030) 2025-06-02 16:57:08 +02:00
Pieter Eendebak
26a1cd4e8c
gh-123471: make concurrent iteration over itertools.cycle safe under free-threading (#131212)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-06-02 20:13:32 +05:30
Duane Griffin
b6237c3602
gh-117852: fix argument checking of async_generator.athrow (#134868)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-06-02 20:04:26 +05:30
Sergey B Kirpichev
9c72658e49
gh-130662: Accept leading zeros in precision/width for Decimal's formatting (#132549)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-06-02 15:30:52 +02:00
Sergey B Kirpichev
5bc2d99126
gh-130662: Accept leading zeros in precision/width for Fraction's formatting (#130663)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-06-02 15:28:20 +02:00
devdanzin
baccfdb3d4
gh-130999: Avoid exiting the new REPL when there are non-string candidates for suggestions (gh-131001) 2025-06-02 13:04:59 +02:00
Sergey B Kirpichev
5f61cde80a
gh-132908: Add math.isnormal/issubnormal() functions (GH132935) 2025-06-02 13:38:05 +03:00
GalaxySnail
128195e12e
gh-122153: indicate that Windows does not support socket.{send,recv}_fds (#134960)
This amends commit e3b6ff19aa.
2025-06-02 12:23:52 +02:00
Sergey B Kirpichev
7828d52680
gh-134449: fix grammar for precision_with_grouping in format description (#134608)
This amends commit f39a07be47.
2025-06-02 11:45:48 +02:00
Bénédikt Tran
ee65ebdb50
gh-134978: deprecate string keyword parameter for hash function constructors (#134979) 2025-06-02 10:25:50 +02:00
Sam Ng
ac7511062b
gh-130478: fix HACL* build for macOS Silicon (#134188) 2025-06-01 17:35:58 +02:00
Andrea-Oliveri
f806463e16
gh-134004: Added the reorganize() methods to dbm.sqlite, dbm.dumb and shelve (GH-134028)
They are similar to the same named method in dbm.gnu.
2025-06-01 15:30:04 +03:00
Serhiy Storchaka
b595237166
gh-132983: Minor fixes and clean up for the _zstd module (GH-134930) 2025-06-01 11:22:15 +03:00
Rihaan Meher
fe6f8a3619
gh-133503: clarify compileall -s/-p docs (#134756)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-06-01 10:18:31 +02:00
Michał Górny
965c480566
gh-134970: Fix exception message in argparse module (GH-134971)
Fix the "unknown action" exception in argparse.ArgumentParser.add_argument_group()
to correctly replace the action class.
2025-06-01 08:56:56 +03:00
sobolevn
cebae977a6
gh-133891: Add missing error check to SET_COUNT macro in _testinternalcapi.c (#133892) 2025-06-01 00:33:02 +03:00
Stan Ulbrych
3704171415
gh-134835: Remove outdated list from howto/urllib2.rst (GH-134844)
🫖
2025-05-31 10:48:51 -07:00
Itamar Oren
f58873e4b2
gh-134954: Hard-cap max file descriptors in subprocess test fd_status (#134955)
* Hard-cap max file descriptors in subprocess test fd_status

On some systems, `SC_OPEN_MAX` may return a very large value (i.e. 10**30), leading to the subprocess test timing out (or run forever).
Prevent this situation by applying a hard cap on how many file descriptors are checked.

* Fix typo in usage docstring

s/fd_stats/fd_status/
2025-05-31 07:29:03 -07:00
sobolevn
5507eff19c
Improve format of InternalDocs/exception_handling.md (#134969) 2025-05-31 14:56:33 +03:00
CF Bolz-Tereick
895119ec24
skip test for sys._stdlib_dir if that is not present (#134973) 2025-05-31 13:46:22 +02:00
CF Bolz-Tereick
af0d3268d9
Skip test as cpython_only that checks whether setattr interns the attribute or not (#134972)
Skip test that checks whether setattr interns the attribute or not

The details of when a string is being interned or not is implementation
dependent.
2025-05-31 13:38:05 +02:00
Nice Zombies
c81446af1d
gh-133968: Create the Unicode writer on demand in json (#133832) 2025-05-31 13:35:51 +02:00
Bénédikt Tran
379d0bc956
gh-134696: fix hashlib tests for FIPS-only BLAKE-2 buildbot (#134968) 2025-05-31 12:48:34 +02:00
Serhiy Storchaka
ad39f01788
gh-108885: Use subtests for doctest examples run by unittest (GH-134890)
Run each example as a subtest in unit tests synthesized by
doctest.DocFileSuite() and doctest.DocTestSuite().

Add the doctest.DocTestRunner.report_skip() method.
2025-05-31 13:01:46 +03:00
Serhiy Storchaka
3c66e59766
gh-134918: Fix and improve doctest's documentation (GH-134919) 2025-05-31 12:03:08 +03:00
Serhiy Storchaka
68784fed78
gh-133489: Remove size restrictions on getrandbits() and randbytes() (GH-133658)
random.getrandbits() can now generate more that 2**31 bits.
random.randbytes() can now generate more that 256 MiB.
2025-05-31 11:23:01 +03:00
Bénédikt Tran
c6e63d9d35
gh-134696: align OpenSSL and HACL*-based hash functions constructors AC signatures (#134713)
OpenSSL and HACL*-based hash functions constructors now support both `data` and `string` parameters.
Previously these constructor functions inconsistently supported sometimes `data` and sometimes `string`,
while the documentation expected `data` to be given in all cases.
2025-05-31 09:37:47 +02:00
Serhiy Storchaka
4d31d19a1d
gh-134718: Omit optional Load() values in ast.dump() (GH-134934) 2025-05-31 10:32:53 +03:00
László Kiss Kollár
8e8786f898
gh-91048: Reorder result tuple of parse_code_object (#134898)
Reorder result tuple of parse_code_object

The standard followed by APIs like pstat.Stats is to take a file, line,
function triplet. The parse_code_object function (and callers exposing
this in Python like RemoteUnwinder.get_stack_trace) return function,
file, line triplets which requires the caller to reorder these when
using it in classes like pstat.Stats.
2025-05-31 00:32:36 +00:00
Steve Dower
8865b4f95b
gh-134923: Use /GENPROFILE and /USEPROFILE for Windows PGO builds (GH-134924) 2025-05-30 19:37:29 +01:00
Gregory P. Smith
310c8cd5e5
rearrange my gitingore addition w/comment to make backporting easier (#134945) 2025-05-30 18:28:14 +00:00
Gregory P. Smith
98a5b830d2
.gitignore personal Claude Code configs (#134942)
.gitignore personal Claude Code configs.

https://docs.anthropic.com/en/docs/claude-code/memory
2025-05-30 17:46:16 +00:00
Serhiy Storchaka
1a89991d23
gh-134733: Fix documentation for the show_empty option of ast.dump() (GH-134925)
Optional None values are always omitted.
2025-05-30 15:52:36 +00:00
Eric Snow
52deabefd0
gh-132775: Expand the Capability of Interpreter.call() (gh-133484)
It now supports most callables, full args, and return values.
2025-05-30 09:15:00 -06:00
Petr Viktorin
eb145fabbd
gh-134160: Improve multi-phase init note on isolation & subinterpreters (GH-134775)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-05-30 16:27:54 +02:00
Serhiy Storchaka
cc344e8dd0
gh-134718: Fix ast.dump() for empty non-default values (GH-134926) 2025-05-30 17:25:07 +03:00
Mark Shannon
ce6a6371a2
GH-134879: Fix INSTRUMENT_FOR_ITER for list/tuple (#134897)
Fix INSTRUMENT_FOR_ITER for list/tuple
2025-05-30 07:11:42 -07:00
Bénédikt Tran
c600310663
gh-134586: mark _mi_assert_fail as noreturn, cold and throw (#134624)
We add the following attributes on `_mi_assert_fail` to help IDE introspection:

* `__attribute__((__noreturn__))`
* `__attribute__((cold))`
* `__THROW` (GCC only)
2025-05-30 14:44:03 +02:00
Victor Stinner
ebf6d13567
gh-134745: Change PyThread_allocate_lock() implementation to PyMutex (#134747)
Co-authored-by: Sam Gross <colesbury@gmail.com>
2025-05-30 10:15:47 +00:00
Jelle Zijlstra
45c6c48afc
gh-134885: zstd: Use Py_XSETREF (GH-134886) 2025-05-30 11:30:05 +02:00
Inada Naoki
b367e27af9
Doc: remove unnecessary section header (GH-134917) 2025-05-30 17:59:23 +09:00
Sam James
2f2bee2111
gh-134768: Fix definition of mt_continue_should_break() (#134769)
In 121ed71f4e, mt_continue_should_break
was changed to be guarded by `Py_DEBUG`, but it's used in `compress_mt_continue_lock_held`
with just `assert`, so it needs to be available when `NDEBUG` is undefined
too.

`Py_DEBUG` implies `NDEBUG` is undefined, so we can check just that.

Fixes: 121ed71f4e
2025-05-30 04:42:19 +00:00
Emma Smith
5f60d0fccc
gh-134906: Document CompressionParameter.content_size_flag (#134907)
* Document CompressionParameter.content_size_flag
2025-05-29 21:37:43 -07:00
Jelle Zijlstra
381020d41f
ast docs: Fix description of ast.Constant (#134741)
Contrary to the current docs, ast.Constant will never hold containers
such as frozenset or tuple; the Python parser only emits it for simple
literals.

For precision, add the exact list of types that may be contained in an
ast.Constant.
2025-05-29 21:11:20 -07:00
Savannah Bailey
a4251411a9
GH-106235: Clarify parse_known_args documentation by removing "remaining" (#126921) 2025-05-29 20:34:34 -07:00
Serhiy Storchaka
cb8a72b301
gh-134857: Improve error report for doctests run with unittest (GH-134858)
Remove doctest module frames from tracebacks and redundant newline
character from a failure message.
2025-05-30 00:32:44 +03:00
Eric Snow
dafd14146f
gh-132775: Fix _PyFunctIon_VerifyStateless() (#134900)
The problem we're fixing here is that we were using PyDict_Size() on "defaults",
which it is actually a tuple.  We're also adding some explicit type checks.

This is a follow-up to gh-133221/gh-133528.
2025-05-29 20:13:12 +00:00
Collin Funk
d96343679f
gh-134771: Fix time_clockid_converter() on Cygwin (#134772)
Use long for clockid_t instead of int.
2025-05-29 19:35:53 +02:00
Victor Stinner
f49a07b531
gh-133968: Add PyUnicodeWriter_WriteASCII() function (#133973)
Replace most PyUnicodeWriter_WriteUTF8() calls with
PyUnicodeWriter_WriteASCII().

Unrelated change to please the linter: remove an unused
import in test_ctypes.

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-05-29 14:54:30 +00:00
Petr Viktorin
4109a9c6b3
gh-133260: Remove claim that PyUnicode_InternFromString immortalizes (GH-134213) 2025-05-29 15:36:59 +02:00
Bénédikt Tran
cafbcd666a
gh-133866: remove deprecated and undocumented function ctypes.SetPointerType (GH-133869) 2025-05-29 15:28:57 +02:00
Stan Ulbrych
b783e1791b
gh-69011: : clarify & deduplicate ctypes.create_*_buffer docs (GH-132858)
This adds a warning about the possibly-missing NUL terminator, but in a way
that doesn't make it sound like a bug/wart.
2025-05-29 15:16:20 +02:00
Emma Smith
e64395e8eb
gh-134262: Fix off by one errors in download retry functions (GH-134867) 2025-05-28 18:15:39 -05:00
Emma Smith
e9d845b41d
gh-134262: Add retries to downloads in PCbuild\get_external.py (GH-134820) 2025-05-28 22:18:34 +01:00
Pablo Galindo Salgado
e496444fdf
Add a tool to benchmark external inspection (#134810) 2025-05-28 21:27:24 +01:00
Mark Shannon
9fbd66a93d
GH-133912: Fix PyObject_GenericSetDict to handle inline values (GH-134725) 2025-05-28 19:03:41 +01:00
Serhiy Storchaka
f6324bc7ee
gh-108885: Imporove tests for doctest (GH-134832)
Test the error and failure report in more detail.
2025-05-28 20:14:56 +03:00
Serhiy Storchaka
bac3fcba5b
gh-108512: Add and use new replacements for PySys_GetObject() (GH-111035)
Add functions PySys_GetAttr(), PySys_GetAttrString(),
PySys_GetOptionalAttr() and PySys_GetOptionalAttrString().
2025-05-28 20:11:09 +03:00
Adam Turner
b265a7ddeb
GH-134848: Use a set to store `AuditEvents.sources` (#134849) 2025-05-28 17:30:53 +01:00
Victor Stinner
4635115c3f
gh-133711: Fix test_readline.test_nonascii() for UTF-8 Mode (#134841)
Skip the test if the Python UTF-8 Mode is enabled and the LC_CTYPE
encoding is not UTF-8.
2025-05-28 17:43:52 +02:00
Victor Stinner
d9ec0ee733
gh-133711: Log Windows OEM code page in test.pythoninfo (#134840)
Add _winapi.GetOEMCP() function.
2025-05-28 17:41:11 +02:00
Serhiy Storchaka
d83576bf48
gh-128840: Fix parsing long IPv6 addresses with embedded IPv4 address (#134836) 2025-05-28 08:24:24 -07:00
Victor Stinner
91618278e7
gh-133711: Fix test_regrtest for PYTHONUTF8=1 (#134839)
Use "backslashreplace" error handler to decode stdout and stderr.
Example:

    vstinner@WIN C:\victor\python\main\build\test_python_worker_8360\x91>
    "C:\victor\python\main\PCbuild\amd64\python_d.exe"  -m test
    --fast-ci --slow-ci --testdir
    C:\Users\vstinner\AppData\Local\Temp\tmp0t59e8da
    test_regrtest_noop1 test_regrtest_noop2 test_regrtest_noop3
    test_regrtest_noop4

Notice the "\x91" byte at the end of the first line: it's the
non-ASCII U+00E6 character encoded to the OEM cp437 code page.
2025-05-28 17:19:50 +02:00
Adam Turner
11f7a939de
gh-132983: Split `_zstd_set_c_parameters` (#133921) 2025-05-28 14:45:08 +00:00
Petr Viktorin
0d499c7e93
gh-128629: Add _Py_PACK_VERSION for CPython's own definitions (GH-134247)
Add _Py_PACK_VERSION for CPython's own definitions

Py_PACK_VERSION was added to limited API in 3.14, so if
Py_LIMITED_API is lower, the macro can't be used.
Add a private version that can be used in CPython headers
for checks like `Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 14)`.
2025-05-28 15:24:40 +02:00
Petr Viktorin
469a56470b
gh-134160: Block multiple module initialization (#134773)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-05-28 08:53:04 +01:00
Hugo van Kemenade
21672b694b
Update outdated statement from math about C standard (#134621)
Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
2025-05-28 08:30:04 +01:00
Allen Hernandez
7be5916f6d
gh-134817: Document [Timed]RotatingFileHandler shouldRollover method (GH-134818)
Co-authored-by: Allen Hernandez <2349718+AllenSH12@users.noreply.github.com>
2025-05-28 07:44:38 +01:00
larryhastings
d7256ae4d7
Fix typing.TYPE_CHECKING docs to reflect PEP 649. (#134813)
typing.TYPE_CHECKING should no longer steer users towards
manual or automatic stringization (and PEP 563); PEP 649
makes all that unnecessary.
2025-05-27 23:08:52 -07:00
Neil Schemenauer
fbbbc10055
gh-127266: avoid data races when updating type slots (gh-133177)
In the free-threaded build, avoid data races caused by updating type
slots or type flags after the type was initially created.  For those
(typically rare) cases, use the stop-the-world mechanism.  Remove the
use of atomics when reading or writing type flags.
2025-05-27 18:27:41 -07:00
Wulian233
7ca6d79fa3
gh-134580: Modernizing difflib.HtmlDiff for HTML Output (#134581)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-05-28 03:46:41 +03:00
Sam Gross
a4d37f88b6
gh-134679: Fix assertion failure in QSBR (gh-134811)
This is the same underlying bug as gh-130519. The destructor may call
arbitrary code, changing the `tstate->qsbr pointer` and invalidating the
old `struct _qsbr_thread_state`.
2025-05-27 16:21:16 -04:00
Rishabh Singh
967f361993
gh-134789: Document del s[i] operation for mutable sequences (#134804)
[main] Update stdtypes.rst

- Added explicit mention of `del s[i]` (item deletion by index) to the Mutable Sequence Types section.
- Clarified that this operation removes the item at the specified index from the sequence.
- Addresses issue #134789.
2025-05-27 14:48:04 -04:00
Noam Cohen
79d81f7cba
gh-131798: Optimize _ITER_CHECK_TUPLE (GH-134803) 2025-05-28 02:30:17 +08:00
Kumar Aditya
ac539e7e0d
gh-132917: fix data race on last_mem in free-threading gc (#134692) 2025-05-27 22:42:08 +05:30
Kumar Aditya
a380d57873
gh-134043: use stackrefs in vectorcalling methods (#134044)
Adds `_PyObject_GetMethodStackRef` which uses stackrefs and takes advantage of deferred reference counting in free-threading while calling method objects in vectorcall.
2025-05-27 22:28:27 +05:30
Emma Smith
3f9eb55e09
gh-134262: increase retries in Tools/build/generate_sbom.py (#134558) 2025-05-27 19:02:17 +03:00
Eric Snow
9b5e80000e
gh-132775: Always Set __builtins__ In _PyFunction_FromXIData() (gh-134758)
This is a small follow-up to gh-133481.  There's a corner case
in the behavior of PyImport_ImportModuleAttrString(), where
it expects __builtins__ to be set if __globals__ is set.
2025-05-27 15:42:24 +00:00
Victor Stinner
c3c88064f5
gh-133678: Document C API third party tools (#134526)
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Steve Dower <steve.dower@python.org>
2025-05-27 17:38:30 +02:00
Mark Shannon
f6f4e8a662
GH-132554: "Virtual" iterators (GH-132555)
* FOR_ITER now pushes either the iterator and NULL or leaves the iterable and pushes tagged zero

* NEXT_ITER uses the tagged int as the index into the sequence or, if TOS is NULL, iterates as before.
2025-05-27 15:59:45 +01:00
Victor Stinner
9300a596d3
gh-134744: Fix fcntl error handling (#134748)
Fix also reference leak on buffer overflow.
2025-05-27 15:09:46 +02:00
Wulian233
176b059fa0
Update README.rst informations from 3.14 to 3.15 (#134649)
Co-authored-by: Wulian233 <1055917385@qq.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-05-27 12:45:54 +00:00
Bénédikt Tran
30dde1eeb3
gh-133579: consistently report C curses function failures (#134327)
Some curses module-level functions and window methods now raise
a `curses.error` when a call to a C curses function fails:

- Module-level functions: assume_default_colors, baudrate, cbreak,
  echo, longname, initscr, nl, raw, termattrs, termname, and unctrl.
- Window methods: addch, addnstr, addstr, border, box, chgat,
  getbkgd, inch, insstr, and insnstr.

In addition, `curses.window.refresh` and `curses.window.noutrefresh`
now raise a `TypeError` instead of a `curses.error` when called with an
incorrect number of arguments for pads.

See also ee36db5500 for similar
changes.
2025-05-27 10:15:16 +00:00
Bénédikt Tran
604f83550b
gh-134210: refactor signal handling in _curses.window.{get_wch,getkey} (#134646) 2025-05-27 10:57:41 +02:00
Bénédikt Tran
51762b6cad
gh-134210: handle signals in _curses.window.getch (#134326) 2025-05-27 10:51:05 +02:00
Eric V. Smith
579686d9fb
gh-134752: Improve speed of test_tokenize.StringPrefixTest.test_prefixes. (#134766) 2025-05-27 04:49:28 -04:00
Bénédikt Tran
737b4ba020
gh-134635: add zlib.{adler32,crc32}_combine to combine checksums (#134650) 2025-05-27 10:48:34 +02:00
Miro Hrončok
8704d6b391
gh-62824: Adjust test_alias_modules_exist test to use imports instead of file checks (#134777) 2025-05-27 10:25:12 +02:00
Shamil
92ea1eb38f
gh-134664: document cleanup_socket parameter in asyncio.start_unix_server (#134750) 2025-05-27 08:23:06 +00:00
Emma Smith
9bf03c6c30
gh-134583: Update devcontainer reference to include image with libzstd-devel (gh-134765)
Update devcontainer reference
2025-05-27 10:24:38 +09:00
neonene
96905bdd27
gh-134160: Use multi-phase init in documentation examples (#134296)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-05-26 21:43:35 +00:00
Kumar Aditya
3c0525126e
gh-134637: Fix performance regression in calling ctypes function pointer in free threading. (#134702)
Fix performance regression in calling `ctypes` function pointer in `free threading`.
2025-05-26 18:26:40 +00:00
Eric Snow
56743afe87
gh-132775: Unrevert "Use _PyCode GetScriptXIData()" (gh-134735)
This reverts commit 8a793c4a36, AKA gh-134599.

This effectively re-applies commit 09e72cf (gh-134511)
2025-05-26 11:50:10 -06:00
Eric V. Smith
08c78e02fa
gh-134675: Add t-string prefixes to tokenizer module, lexical analysis doc, and add a test to make sure we catch this error in the future. (#134734)
* Add t-string prefixes to _all_string_prefixes, and add a test to make sure we catch this error in the future.

* Update lexical analysis docs for t-string prefixes.
2025-05-26 13:49:39 -04:00
neonene
c60f39ada6
gh-134557: Suppress immortalization in _PyCode_GetScriptXIData under free-threading (gh-134686)
Disable immortalization around Py_CompileString*().

The same approach as 332356b that fixed the refleaks in compile() and eval().

E: 09e72cf can pass test_capi, test_sys and test__interpchannels with this patch for me.
2025-05-26 11:46:49 -06:00
Hugo van Kemenade
b8a885ce63
Add CODEOWNERS and YAML to end-of-file-fixer and trailing-whitespace (#134730)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-05-26 18:42:38 +01:00
Jelle Zijlstra
7291eaba8b
gh-119180: Updates to PEP 649/749 docs (#134640)
- Mention (again) that `type.__annotations__` is unsafe. It is now safe
  when using only classes defined under PEP 649 semantics, but not with
  classes defined using `from __future__ import annotations`.
- Mention that annotations on instances no longer work. There was already
  an issue about this.
- Mention the general changes in the "Porting to Python 3.14" section.
- `annotationlib` was proposed by PEP-749, not PEP-649.

Co-authored-by: Emma Smith <emma@emmatyping.dev>
Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
2025-05-26 08:35:04 -07:00
sobolevn
806107d7a2
gh-134693: Fix [-Wmaybe-uninitialized] warning in _remote_debugging_module.c (#134694) 2025-05-26 16:06:33 +01:00
Adam Turner
f2ce4bbdfd
gh-132983: Convert dict_content to take Py_buffer in `ZstdDict()` (#133924) 2025-05-26 14:48:41 +00:00
Pablo Galindo Salgado
7774869b1b
Add trailing line to CODEOWNERS (#134722) 2025-05-26 15:47:09 +01:00
Pablo Galindo Salgado
ce0561fa59
Add CODEOWNERS for remote debugging (#134720) 2025-05-26 14:36:30 +00:00
Pablo Galindo Salgado
0909d6d8e8
gh-91048: Add better error messages for remote debugging for CI builds (#134682) 2025-05-26 15:31:47 +01:00
Russell Keith-Magee
965662ee4a
gh-91048: Correct Apple platform includes for iOS. (#134712)
Correct Apple platform includes for iOS.
2025-05-26 12:44:41 +00:00
Bénédikt Tran
9eb84d83e0
gh-132710: add missing NEWS entry for GH-132901 (#134705) 2025-05-26 10:38:16 +00:00
Bénédikt Tran
cb8045e86c
gh-134531: cleanup _hashopenssl.c to support EVP_MAC (#134626)
Rename components related to `_hashlib.{HASH,HASHXOF}` objects.

- The `EVPobject` structure is renamed `HASHobject`.
- Non-clinic `HASH` methods are now prefixed by `_hashlib_HASH_*`.
  A similar change is made for non-clinic `HASHXOF` methods.
- Functions extracting information from `EVP_MD` objects and functions
  constructing `EVP_MD` objects now include `openssl_evp_md` in their name.

This change allows us to avoid future ambiguities between the `EVP_MD`
and the `EVP_MAC` APIs (currently, we only use `EVP_MD` for hash functions
and rely on the legacy interface for HMAC instead of using `EVP_MAC`).
2025-05-26 10:12:32 +00:00
tmlnv
71290a6fbe
gh-134559: Add versionadded for `object.__replace__()` (#134672) 2025-05-26 10:39:04 +01:00
Bénédikt Tran
3bffada467
gh-132710: only use stable _uuid.generate_time_safe() to deduce MAC address (#132901) 2025-05-26 10:56:31 +02:00
Bénédikt Tran
29e8115964
gh-134208: remove dead AC directives for _curses.window.{chgat,getstr,instr} (#134325) 2025-05-26 10:52:19 +02:00
Pieter Eendebak
fb09db1b93
gh-129594: Remove redundant check on varargs in _PyArg_CheckPositional (#129595) 2025-05-26 10:51:12 +02:00
Sergey B Kirpichev
cf8941c603
gh-132876: workaround broken ldexp() on Windows 10 (#133135)
* gh-132876: workaround broken ldexp() on Windows 10

ldexp() fails to round subnormal results before Windows 11,
so hide their bug.

Co-authored-by: Tim Peters <tim.peters@gmail.com>
2025-05-25 21:44:33 -05:00
Loïc Simon
0e3bc962c6
gh-69605: Disable PyREPL module autocomplete fallback on regular completion (gh-134181)
Co-authored-by: Loïc Simon <loic.simon@napta.io>
2025-05-26 01:05:08 +02:00
R. David Murray
a32ea45699
gh-134152: Fix UnboundLocalError in email._header_value_parser _get_ptext_to_endchars (#134233)
Fix an UnboundLocalError that can occur when parsing certain delimited constructs in headers (domain literals, quoted strings, comments). After the fix the _get_ptext_to_endchars returns an empty string if there is no content after the opening delimiter. The calling code is responsible for handling the lack of the trailing delimiter, which it already does; this edge case was the header ending immediately after the opening delimiter.
2025-05-25 18:09:32 -04:00
Pablo Galindo Salgado
7b1a700231
Heavily comment Python/perf_jit_trampoline.c to improve maintainability (#134527)
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
2025-05-25 21:37:15 +01:00
Pablo Galindo Salgado
42b25ad4d3
gh-91048: Refactor and optimize remote debugging module (#134652)
Completely refactor Modules/_remote_debugging_module.c with improved
code organization, replacing scattered reference counting and error
handling with centralized goto error paths. This cleanup improves
maintainability and reduces code duplication throughout the module while
preserving the same external API.

Implement memory page caching optimization in Python/remote_debug.h to
avoid repeated reads of the same memory regions during debugging
operations. The cache stores previously read memory pages and reuses
them for subsequent reads, significantly reducing system calls and
improving performance.

Add code object caching mechanism with a new code_object_generation
field in the interpreter state that tracks when code object caches need
invalidation. This allows efficient reuse of parsed code object metadata
and eliminates redundant processing of the same code objects across
debugging sessions.

Optimize memory operations by replacing multiple individual structure
copies with single bulk reads for the same data structures. This reduces
the number of memory operations and system calls required to gather
debugging information from the target process.

Update Makefile.pre.in to include Python/remote_debug.h in the headers
list, ensuring that changes to the remote debugging header force proper
recompilation of dependent modules and maintain build consistency across
the codebase.

Also, make the module compatible with the free threading build as an extra :)

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2025-05-25 20:19:29 +00:00
Hugo van Kemenade
328a778db8
gh-134357: Remove unused imports in tests (#134340) 2025-05-25 20:09:02 +00:00
Julien Palard
24a47155d2
Fix sphinx-lint warnings (default-role used). (GH-134647) 2025-05-25 21:22:52 +02:00
Chris Eibl
1000283694
GH-130328: Fix WindowsConsoleGetEventTests after gh-133728 (gh-134660) 2025-05-25 20:17:13 +02:00
Jelle Zijlstra
57fef27cfc
gh-133960: Improve typing.evaluate_forward_ref (#133961)
As explained in #133960, this removes most of the behavior differences with ForwardRef.evaluate.
The remaining difference is about recursive evaluation of forwardrefs; this is practically useful
in cases where an annotation refers to a type alias that itself is string-valued.

This also improves several edge cases that were previously not handled optimally. For example,
the function now takes advantage of the partial evaluation behavior of ForwardRef.evaluate() to
evaluate more ForwardRefs in the FORWARDREF format.

This also fixes #133959 as a side effect, because the buggy behavior in #133959 derives from
evaluate_forward_ref().
2025-05-25 17:26:39 +00:00
Jelle Zijlstra
b51b08a0a5
annotationlib docs: note that ForwardRef.evaluate eventually defaults to empty globals (#134661) 2025-05-25 17:23:28 +00:00
Loïc Simon
52509cc94b
gh-134582: Fix t-strings untokenize() roundtrip removing space between braces (#134603) 2025-05-25 17:23:38 +01:00
Jelle Zijlstra
3e562b3942
gh-133684: Fix get_annotations() where PEP 563 is involved (#133795) 2025-05-25 08:40:58 -07:00
Jelle Zijlstra
4443110c34
gh-133778: Fix setting __annotations__ under PEP 563 (#133794) 2025-05-25 08:38:18 -07:00
Chris Eibl
91b48868a8
GH-130328: Speedup pasting in legacy console on Windows (gh-133728) 2025-05-25 15:17:43 +02:00
ggqlq
2fd09b0110
gh-134168: fix http.server CLI support for IPv6 and --directory when serving over HTTPS (#134169) 2025-05-24 12:19:20 +00:00
Bénédikt Tran
5d9c8fe3f6
gh-131178: add E2E mockless tests for http.server command-line interface (#134279) 2025-05-24 13:48:50 +02:00
Jasper Wong
7b1010a57d
gh-134595: Update HOWTO to reflect change in CIBW option (#134598) 2025-05-24 10:15:00 +03:00
Eddy Mulyono
80284b5c5e
gh-80334: fix multiprocessing.freeze_support for other spawn platforms (GH-134462)
Doc/library/multiprocessing.rst: freeze_support: Change to specify spawn method instead of platform
Have multiprocessing.freeze_support() enable on spawn, not just win32.

---------

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2025-05-24 03:50:19 +00:00
Anthony Sottile
74a9c60f3e
gh-134546: ensure remote pdb script is readable (#134552) 2025-05-23 23:07:39 -04:00
Seth Michael Larson
47f1161d3a
gh-128840: Limit the number of parts in IPv6 address parsing (GH-128841)
GH-128840: Limit the number of parts in IPv6 address parsing
Limit length of IP address string to 39

---------

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2025-05-24 02:57:13 +00:00
Emma Smith
973b8f69d3
gh-132983: Make _zstd C code PEP 7 compliant (GH-134605)
Make _zstd C code PEP 7 compliant
2025-05-23 19:03:21 -07:00
Emma Smith
f478331f98
gh-132983: Slightly tweak error messages for _zstd compressor/decompressor options dict (#134601)
Slightly tweak error messages for options dict
2025-05-23 14:51:41 -07:00
Eric Snow
8a793c4a36
gh-134557: Revert "gh-132775: Use _PyCode GetScriptXIData()" (gh-134599)
This reverts commit 09e72cf091, AKA gh-134511.

We are reverting due to refleaks on free-threaded builds.
2025-05-23 20:04:20 +00:00
Jiucheng(Oliver)
9a2346df86
gh-134381: Fix RuntimeError when starting not-yet started Thread after fork (gh-134514) 2025-05-23 15:22:14 -04:00
Daniel Li
05a19b5e56
gh-120170: Exclude __mp_main__ in C version of whichmodule() (#120171)
Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
2025-05-23 21:45:45 +03:00
Serhiy Storchaka
393773ae87
gh-134565: Use ExceptionGroup to handle multiple errors in unittest.doModuleCleanups() (GH-134566) 2025-05-23 21:07:49 +03:00
Serhiy Storchaka
77eade39f9
gh-134578: Mark more slow tests (GH-134579) 2025-05-23 19:59:10 +03:00
Serhiy Storchaka
fc0c9c2412
gh-133454: Reduce the number of threads in test_racing_getbuf_and_releasebuf (GH-133458)
The original reproducer only used 10 threads.
2025-05-23 19:58:34 +03:00
Tomas R.
71dea74865
gh-131798: Small improvements to remove_unneeded_uops (GH-134554)
Improve remove_unneeded_uops
2025-05-23 20:48:45 +08:00
Collin Funk
b8f55266bf
gh-134486: Fix missing alloca() symbol in _ctypes on NetBSD (#134487)
Previously the module would fail to load because the `alloca()` symbol
was undefined. Now we check for GCC/Clang builtins for systems who do
not define `alloca()` in headers.
2025-05-23 13:11:04 +02:00
Steve Dower
99a9ab1c64
Further improves Advanced installation docs for PyManager (GH-134541) 2025-05-23 11:17:18 +01:00
Blaise Pabon
1729468016
gh-106318: Add example for str.count() (#134519) 2025-05-23 12:47:11 +03:00
Blaise Pabon
da9b5c1c9c
gh-106318: Add example for str.center() (#134518) 2025-05-23 12:44:15 +03:00
Kumar Aditya
366d95d862
gh-133372: remove out of date todos from types module about generator wrapper (#134563) 2025-05-23 05:19:41 +00:00
Evgeny Demchenko
f9324cb3cb
gh-134451: Converted asyncio.tools.CycleFoundException from dataclass to a regular exception type. (#134513) 2025-05-23 05:15:21 +00:00
Kumar Aditya
5804ee7b46
gh-114177: avoid calling connection lost callbacks when loop is already closed in asyncio subprocess (#134508) 2025-05-23 10:03:16 +05:30
Emma Smith
8dbc119719
gh-133885: Use locks instead of critical sections for _zstd (gh-134289)
Move from using critical sections to locks for the (de)compression methods.
Since the methods allow other threads to run, we should use a lock rather
than a critical section.
2025-05-22 23:30:10 -04:00
Cheery
a7ed9dfcbe
Docs: fix link in free-threading-python.rst (#134548) 2025-05-22 20:37:20 -04:00
Thomas Grainger
a3d0306ca0
gh-128307: Update docs for asyncio.create_task, TaskGroup.create_task, asyncio.create_task (#134202) 2025-05-22 15:54:56 -07:00
Brett Cannon
2da2be4b84
GH-131769: fix detecting a pydebug build of the build Python when building for WASI (GH-134015) 2025-05-22 14:41:50 -07:00
Josh Cannon
9b292ff022
Avoid __file__ in hashlib example (GH-134540) 2025-05-22 14:32:00 -07:00
Brett Cannon
ad42dc1909
GH-130397: remove special-casing of C stack depth for WASI (#134469)
Removed special-casing for WASI when setting C stack depth limits. Since WASI has its own C stack checking this isn't a security risk.

Also disabled some tests that stopped passing. They all happened to have already been disabled under Emscripten.
2025-05-22 14:08:44 -07:00
Kattni
742d5b5c5d
Docs: Add note to tutorial clarifying scope (#134534)
* Add note to tutorial

* Update formatting
2025-05-22 14:26:47 -04:00
Tomas R.
d1ea8edbd7
GH-131798: Optimize away isinstance calls in the JIT (GH-134369) 2025-05-22 14:05:43 -04:00
Eric Snow
ac06b534ee
gh-132775: Fix Recently Introduced Warnings (gh-134530) 2025-05-22 17:24:09 +00:00
Tomas R.
484e00379b
GH-131798: Optimize away isinstance calls in the JIT (GH-134369) 2025-05-22 12:52:47 -04:00
Duprat
fade146cfb
gh-134322: Fix repr(threading.RLock) (#134389)
Fix the `__repr__` value of `threading.RLock` from `_thread` module, when just created.
2025-05-22 16:46:57 +00:00
Eric Snow
4a4ac3ab4d
gh-132775: Make _PyXI_session Opaque (gh-134452)
This is mostly a refactor to clean things up a bit, most notably the "XI namespace" code.

Making the session opaque requires adding the following internal-only functions:

* _PyXI_NewSession()
* _PyXI_FreeSession()
* _PyXI_GetMainNamespace()
2025-05-22 10:14:04 -06:00
Brandt Bucher
ec736e7dae
GH-131798: Optimize cached class attributes and methods in the JIT (GH-134403) 2025-05-22 11:15:03 -04:00
Eric Snow
09e72cf091
gh-132775: Use _PyCode GetScriptXIData() (gh-134511) 2025-05-22 08:40:33 -06:00
Victor Stinner
899c7dc283
gh-133740: Fix locale.nl_langinfo(ALT_DIGITS) (#134468)
Set the LC_CTYPE locale to the LC_TIME locale even if
nl_langinfo(ALT_DIGITS) result is ASCII. The result is a list
separated by NUL characters and the code only checks the first list
item which can be ASCII whereas following items are non-ASCII.

Fix test__locale for the uk_UA locale on RHEL 7.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-05-22 16:05:07 +02:00
Nadeshiko Manju
8c5e5557c6
GH-131798: Turn _LOAD_SMALL_INT into _LOAD_CONST_INLINE_BORROW in the JIT (GH-134406) 2025-05-22 09:54:57 -04:00
Duprat
3effede97c
gh-134323: Fix the new threading.RLock.locked method (#134368)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-05-22 13:48:24 +00:00
Alex Kautz
bd4046f4f8
gh-134370: Added clarification on instance annotations (#134387)
Instances of classes cannot have annotations,
however sometimes they will erroneously have the
__annotations__ attribute
2025-05-22 06:46:29 -07:00
Eric Snow
d0eedfa10e
gh-132775: Use _PyObject_GetXIData (With Fallback) (gh-134440)
This change includes some semi-related refactoring of queues and channels.
2025-05-22 06:50:06 -06:00
Michał Górny
d706eb9e0f
gh-134455: Fix build-details.json to use the `c_api.headers` key (#134456)
Fix `build-details.json` generation to use the correct `c_api.headers`
key as defined in PEP 739, instead of `c_api.include`.

Co-authored-by: Filipe Laíns 🇵🇸 <lains@riseup.net>
2025-05-22 11:28:35 +00:00
Duane Griffin
458e33018a
gh-127081: lock non-re-entrant *pwent calls in free-threading (#132748) 2025-05-22 15:52:02 +05:30
Serhiy Storchaka
2602d8ae98
gh-71339: Use new assertion methods in tests (GH-129046) 2025-05-22 13:17:22 +03:00
Hugo van Kemenade
bb244fd33d
Consistent sentence case in docs template files (#134412) 2025-05-22 12:51:02 +03:00
Mark Shannon
fbe7b87c06
GH-131688: Mark instructions and uops with DECREF_INPUTS as escaping. (GH-133501) 2025-05-22 09:54:35 +01:00
Mark Shannon
29f6dc6323
GH-133932: Tagged ints are heap safe (GH-134244) 2025-05-22 09:54:04 +01:00
Petr Viktorin
1f0a294e8c
Add notes on nogil & reinitialization to the Opt-Out section in Module Isolation HOWTO (GH-134141)
Co-authored-by: Sam Gross <colesbury@gmail.com>
2025-05-22 09:36:37 +02:00
Sergey Miryanov
7309eb60c0
gh-131357: Add some extra tests for empty bytes and bytearray (#134458) 2025-05-22 09:01:46 +02:00
Kira
979d81a179
gh-134309: Add `github.actor` to the GitHub Actions concurrency key (#134310)
When inexperienced users create a PR from their default branch, all of the concurrency keys
collide as there is no namespacing. This becomes an issue at events with many new contributors,
where workflow runs are cancelled on other pull requests.
Disambiguate by adding the username of the relevant 'actor' to the concurrency key.

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Sviatoslav Sydorenko <sviat@redhat.com>
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
Authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-05-22 04:49:07 +01:00
Gregory P. Smith
296a66051e
gh-127840: Revert "gh-127840: pass flags and address from send_fds (GH-127841)" (#134482)
Revert "gh-127840: pass flags and address from send_fds (GH-127841)"

This reverts commit 518c95b552.
2025-05-22 03:38:44 +00:00
Mike Salvatore
f3fc0c16e0
gh-134062: Fix hash collisions in IPv4Network and IPv6Network (GH-134063)
gh-134062: Fix hash collisions in IPv4Network and IPv6Network
gh-134062: Add hash collision regression test
2025-05-21 19:48:10 -07:00
Marcin Bachry
518c95b552
gh-127840: pass flags and address from send_fds (GH-127841)
socket: pass flags and address from send_fds

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-05-21 19:38:01 -07:00
Yuichiro Tachibana (Tsuchiya)
b1b8962443
gh-127960 Fix the REPL to set the correct namespace by setting the correct __main__ module (gh-134275)
The `__main__` module imported in the `_pyrepl` module points to the `_pyrepl` module itself when the interpreter was launched without `-m` option and didn't execute a module,
while it's an unexpected behavior that `__main__` can be `_pyrepl` and relative imports such as `from . import *` works based on the `_pyrepl` module.

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2025-05-22 02:18:00 +02:00
Eric Snow
a66bae8bb5
gh-132775: Use _PyFunction_VerifyStateless() and _PyCode_VerifyStateless() (gh-134439) 2025-05-21 14:16:55 -06:00
Emma Smith
fb68776591
gh-132983: Fix refleak in zstd dictionary functions (gh-134459) 2025-05-21 19:09:34 +00:00
Bénédikt Tran
1a07a01014
gh-132124: improve safety nets for creating AF_UNIX socket files (GH-134085)
* ensure that we can create AF_UNIX socket files
* emit a warning if system-wide temporary directory is used
2025-05-21 10:10:31 -07:00
Cody Maloney
e1f891414b
gh-80050: Update BufferedReader.read docs around non-blocking (GH-130653) 2025-05-21 16:06:40 +00:00
Emma Smith
c64a21454b
gh-132983: Refactor shared code in train_dict and finalize_dict (GH-134432)
Refactor shared code in train_dict and finalize_dict
2025-05-21 08:53:13 -07:00
Cody Maloney
0a68068bd2
gh-62184: Remove _pyio import of _io.FileIO (gh-134192)
This was added in the add of `_io`, isn't used since bpo-21859 when a
`_pyio` implementation was added which defines `FileIO` lower down in
the file.
2025-05-21 17:29:18 +02:00
Cody Maloney
5b0e827521
gh-133982: Run unclosed file test on all io implementations (gh-134165)
Update `test_io` `_check_warn_on_dealloc` to use `self.` to dispatch to
different I/O implementations.

Update the `_pyio` implementation to match expected behavior, using the
same `_dealloc_warn` design as the C implementation uses to report the
topmost `__del__` object.

The FileIO one now matches all the others, so can use IOBase. There was
a missing check on closing (self._fd must be valid), add that check
2025-05-21 16:51:56 +02:00
Cody Maloney
06eaf4055c
gh-71253: Match _io exception in _pyio (gh-133985)
Test was only testing _io, expanded to cover _pyio.

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-05-21 16:45:00 +02:00
Cody Maloney
84d5f8d799
gh-133982: Update test_bufio to use self.open (gh-133983) 2025-05-21 16:40:50 +02:00
Cody Maloney
b529b60fc2
gh-132246: Add special buffer methods to C API Type Object docs (gh-132247)
Two special methods, __buffer__ and __release_buffer__ were added to
Python 3.12 by PEP 688. The C API Type Object documentation for slots
includes `tp_as_buffer`, and sub-slots `bf_getbuffer`, `bf_releasebuffer`
but does not refer to the Python Data Model version of those. Add the
missing references.
2025-05-21 16:21:57 +02:00
Emma Smith
d862b6de1b
gh-132983: Add documentation for compression.zstd (GH-133911)
Add documentation for compression & compression.zstd.

🎉

---------

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Sumana Harihareswara <sh@changeset.nyc>
Co-authored-by: Martin Panter <vadmium@users.noreply.github.com>
2025-05-21 07:18:21 -07:00
Yash Vijay
4eacf3883d
gh-134026: Fix grammar description of for statement (GH-134034) 2025-05-21 16:09:28 +02:00
Petr Viktorin
c7364f79b2
gh-127833: lexical analysis: Improve section on Names (GH-131474)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Blaise Pabon <blaise@gmail.com>
2025-05-21 16:01:52 +02:00
Christian Harries
109f7597d2
gh-90871: fix connection backlog offset in asyncio (gh-134392)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-05-21 15:59:09 +02:00
Yuki Kobayashi
15a8b5b9bd
gh-110631: Fix some incorrect indents in the documentation (#129312) 2025-05-21 13:52:02 +00:00
Eric Snow
88f8102a8f
gh-132775: Support Fallbacks in _PyObject_GetXIData() (gh-133482)
It now supports a "full" fallback to _PyFunction_GetXIData() and then `_PyPickle_GetXIData()`.  There's also room for other fallback modes if that later makes sense.
2025-05-21 07:23:48 -06:00
Emma Smith
0c5a8b0b55
gh-134262: Add retries to generate_sbom.py (#134263)
Co-authored-by: Semyon Moroz <donbarbos@proton.me>
2025-05-21 16:14:36 +03:00
Peter Bierma
b8998fe2d8
gh-131185: Use a proper thread-local for cached thread states (gh-132510)
Switches over to a _Py_thread_local in place of autoTssKey, and also fixes a few other checks regarding PyGILState_Ensure after finalization.

Note that this doesn't fix concurrent use of PyGILState_Ensure with Py_Finalize; I'm pretty sure zapthreads doesn't work at all, and that needs to be fixed seperately.
2025-05-21 07:01:25 -06:00
sobolevn
dcfc91e4e5
Fix signature of _curses.assume_default_colors in the docs (#134409) 2025-05-21 15:56:34 +03:00
Noam Cohen
e6dde10a69
gh-132542: Only run test_native_id_after_fork if native_id is supported (GH-134408) 2025-05-21 14:10:57 +03:00
Sofia Toro
c740fe3bd0
gh-134360 Add processName attribute to logging.Formatter docstring (GH-134371) 2025-05-21 05:49:06 +01:00
Tim Hatch
1298511b41
gh-72680: Fix false positives when using zipfile.is_zipfile() (GH-134250)
bpo-28494: Improve zipfile.is_zipfile reliability

The zipfile.is_zipfile function would only search for the EndOfZipfile
section header. This failed to correctly identify non-zipfiles that
contained this header. Now the zipfile.is_zipfile function verifies
the first central directory entry.

Changes:
* Extended zipfile.is_zipfile to verify zipfile catalog
* Added tests to validate failure of binary non-zipfiles
* Reuse 'concat' handling for is_zipfile

Co-authored-by: John Jolly <john.jolly@gmail.com>
2025-05-20 18:32:41 -07:00
Pablo Galindo Salgado
d327159eb4
gh-91048: Fix error path result in _remote_debugging_module (#134347) 2025-05-20 19:54:09 -04:00
ivonastojanovic
6856a04d68
Add documentation for remote debugging with pdb (#134260)
* Mention remote debugging via -p PID in usage text

Adds a brief note to the pdb help summary about attaching to a running
process using the -p option, making the remote debugging feature
more visible.

* Mention remote debugging in pdb.rst
2025-05-20 19:50:49 -04:00
Brandt Bucher
2f0570caf4
GH-131798: Narrow types more aggressively in the JIT (GH-134373) 2025-05-20 18:09:51 -04:00
Nadeshiko Manju
e1c0c451a2
GH-131798: Narrow the return type of _GET_LEN to int (GH-133345) 2025-05-20 18:02:50 -04:00
Chris Eibl
e4fbfb1288
GH-130727: Avoid race condition in _wmimodule by copying shared data (GH-134313) 2025-05-20 22:21:25 +01:00
tigerding
aadda87b3d
gh-134209: use heap-allocated memory in _curses.window.{instr,getstr} (GH-134283)
* made curses buffer heap allocated instead of stack
* change docs to explicitly mention the max buffer size
* changing GetStr() function to behave similarly too
* Update Doc/library/curses.rst
* Update instr with proper return error handling
* Update Modules/_cursesmodule.c
* change to strlen and better memory safety
* change from const int to Py_ssize_t
* add mem allocation guard
* update versionchanged to mention it was an increase.
* explicitly use versionchanged 3.14 as that is its own branch now.

TESTED: `python -m test -u curses test_curses`

---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-05-20 20:36:04 +00:00
Kevin Hernández
a3a3cf6d15
gh-134215: PyREPL: Do not show underscored modules by default during autocompletion (gh-134267)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2025-05-20 22:26:48 +02:00
Chris Patti
c91ad5da9d
gh-128066: Properly handle history file writes for RO fs on PyREPL (gh-134380)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2025-05-20 21:47:57 +02:00
devdanzin
c7f8e706e1
gh-90117: handle dict and mapping views in pprint (#30135)
* Teach pprint about dict views with PrettyPrinter._pprint_dict_view and ._pprint_dict_items_view.
* Use _private names for _dict_*_view attributes of PrettyPrinter.
* Use explicit 'items' keyword when calling _pprint_dict_view from _pprint_dict_items_view.
* 📜🤖 Added by blurb_it.
* Improve tests
* Add tests for collections.abc.[Keys|Items|Mapping|Values]View support in pprint.
* Add support for collections.abc.[Keys|Items|Mapping|Values]View in pprint.
* Split _pprint_dict_view into _pprint_abc_view, so pretty-printing normal dict views and ABC views is handled in two simple methods.
* Simplify redundant code.
* Add collections.abc views to some existing pprint tests.
* Test that views from collection.UserDict are correctly formatted by pprint.
* Handle recursive dict and ABC views.
* Test that subclasses of ABC views work in pprint.
* Test dict views coming from collections.Counter.
* Test ABC views coming from collections.ChainMap.
* Test odict views coming from collections.OrderedDict.
* Rename _pprint_abc_view to _pprint_mapping_abc_view.
* Add pprint test for mapping ABC views where ._mapping has a custom __repr__ and fix ChainMap test.
* When a mapping ABC view has a ._mapping that defines a custom __repr__, dispatch pretty-printing it by that __repr__.
* Add tests for ABC mapping views subclasses that don't replace __repr__, also handling those that delete ._mapping on instances.
* Simplify the pretty printing of ABC mapping views.
* Add a test for depth handling when pretty printing dict views.
* Fix checking whether the view type is a subclass of an items view, add a test.
* Move construction of the views __repr__ set out of _safe_repr.

---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Éric <merwok@netwok.org>
Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2025-05-20 12:30:00 -07:00
Hood Chatham
91e6a58e2d
gh-127146: xfail more Emscripten stack overflows (#134358)
Adds some additional test xfails for Emscripten stack overflows. Also corrects a test skip for test_io.
2025-05-20 18:41:14 +00:00
Hood Chatham
3b7888bf3d
gh-106213: Shorten Emscripten wasm-gc trampoline by a little (#133984)
Using the if instruction results in slightly shorter trampoline code.
2025-05-20 14:22:49 -04:00
Alex Kautz
36eb711d2f
gh-85045: clarified that the underlying buffer of a TextIOBase can be a RawIOBase (GH-134372)
Added a clarification that the underlying binary buffer of a TextIOBase can be a BufferedIOBase OR a RawIOBase
2025-05-20 18:18:58 +00:00
Kumar Aditya
b430e92dd8
gh-127945: Update What's New in Python 3.14 for free-threaded ctypes (#134332) 2025-05-20 22:27:23 +05:30
Kumar Aditya
0584533dc7
gh-128002: add what's new docs for asyncio (#134324) 2025-05-20 22:11:58 +05:30
Stan Ulbrych
99b580857f
gh-122781: Allow empty offset for %z in strptime (#132922)
* commit

* Move tests
2025-05-20 16:39:58 +00:00
Brandt Bucher
7ad90463df
GH-133779: Fix finding pyconfig.h on Windows JIT builds (GH-134349) 2025-05-20 12:32:26 -04:00
Noam Cohen
6b73502313
gh-132542: Set native thread ID after fork (GH-132701) 2025-05-20 16:20:25 +00:00
Stan Ulbrych
86397cf65d
gh-76075: Correct datetime.timestamp documentation (#131202)
* Clean up timestamp docs

* Update datetime.rst

* Suggestion
2025-05-20 12:18:53 -04:00
Kumar Aditya
ec39fd2c20
gh-133980: use atomic store in PyObject_GenericSetDict (#133988) 2025-05-20 21:11:47 +05:30
Donghee Na
317c496223
gh-129748: Update mimalloc to use atomic store for mi_block_set_nextx (#134238) 2025-05-20 11:39:56 -04:00
Pablo Galindo Salgado
dd7f113057
gh-115999: Add PyCodeObject.co_tlbc to the debug offsets (#134286)
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
2025-05-20 15:31:37 +00:00
Mark Shannon
6dcb0fdfe0
GH-134282: Always borrow references LOAD_CONST (GH-134284) 2025-05-20 11:24:11 -04:00
Christian Harries
f695eca60c
gh-86802: Fix asyncio memory leak; shielded task exceptions log once through the exception handler (gh-134331)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2025-05-20 17:14:27 +02:00
Yuki Kobayashi
f3acbb72ff
gh-101100: Fix Sphinx warnings in library/decimal.rst (#134303) 2025-05-20 17:46:13 +03:00
Bas Bloemsaat
5ab66a882d
gh-62824: Add alias for iso-8859-8-i which is the same as iso-8859-8 (gh-134306)
Co-authored-by: David Goncalves <davegoncalves@gmail.com>
Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
2025-05-20 15:14:02 +02:00
Richard Hansen
3246ea514d
gh-75459: Doc: C API: Improve object life cycle documentation (GH-125962)
* Add "cyclic isolate" to the glossary.
  * Add a new "Object Life Cycle" page.
  * Improve docs for related API, with special focus on cross-references and warnings

Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-05-20 14:25:50 +02:00
abstractedfox
306f9e04e5
gh-131357: Add tests for zero-sized bytes objects in test_bytes.py (#134234)
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-05-20 12:24:27 +00:00
Serhiy Storchaka
a31bbc951a
gh-53189: Document peculiarities of InteractiveConsole in relation to pickle (GH-123069)
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2025-05-20 14:08:40 +02:00
Sergey B Kirpichev
175ba3639f
gh-72902: improve Fraction constructor speed for typical inputs (GH-134320)
This moves abc check for numbers.Rational - down.
2025-05-20 12:47:27 +03:00
Bénédikt Tran
e007e62ba7
gh-125843: fix test_curses.test_attributes on x86-64 macOS (#134252)
While some `libcurses` functions are meant to return OK on success,
this is not always the case for all implementations. As such, we relax
the checks on the return values and allow any non-ERR value to be
considered equivalent to OK.
2025-05-20 09:15:39 +00:00
Guido van Rossum
28625d4f95
gh-128307: Update what's new in 3.13 and 3.14 with create_task changes of asyncio (#134304)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-05-20 14:11:22 +05:30
Serhiy Storchaka
e29171bf8a
Clean up test_posixpath (GH-134315)
* Ensure that created files and dirs are always removed after test.
  Now addCleanup() does not conflict with tearDown().
* Use os_helper.unlink() and os_helper.rmdir().
* Import TESTFN from os_helper.
2025-05-20 10:51:44 +03:00
Inada Naoki
652d6938ef
gh-133374: fix test_python_legacy_windows_stdio (GH-134080) 2025-05-20 13:33:54 +09:00
Gustaf
e3dda8f818
gh-133940: test_strftime incorrectly calculates expected week (GH-134281)
Let the system determine the correct tm_wday and tm_isdst.
2025-05-19 17:54:48 -07:00
Alek Binion
66aaad6103
gh-134201: Expand explanation of Base85 encodings in base64 docs (#134288)
Explain history of de-facto standard and how to pick between the two Base-85 encoding functions in the base-64 module.

---------

Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
2025-05-19 18:59:06 -05:00
Stan Ulbrych
46d7c114d8
gh-132983: Add zstd version info to test.pythoninfo (#134230)
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-05-20 00:06:04 +02:00
Tomas R.
a7f317d730
GH-131798: Add _POP_CALL_TWO_LOAD_CONST_INLINE_BORROW (GH-134268) 2025-05-19 18:00:53 -04:00
Bénédikt Tran
1fbb0603a8
gh-131178: remove runtime tests for http.server CLI (#134287)
The runtime behavior of `http.server` CLI is hard to test on an arbitrary platform.
As such, tests asserting the correctness of `python -m http.server` are temporarily
removed and will be rewritten later once a universal solution has been found.
2025-05-19 21:59:14 +00:00
Tom Wang
8421b03b16
gh-134235: Import Autocomplete for Builtin Modules (GH-134277)
* added enhancement auto completing import with sys builtins

---------

Co-authored-by: Hunter <hyoung3@gmail.com>
2025-05-19 14:21:30 -07:00
John Keith Hohm
470941782f
gh-88994: Change datetime.datetime.now to half-even rounding (#134258)
Change `datetime.datetime.now` to half-even rounding
for consistency with `datetime.fromtimestamp`.
2025-05-19 22:48:55 +02:00
Diego Russo
42d03f3933
GH-131798: Split CALL_LIST_APPEND into several uops (GH-134240) 2025-05-19 15:48:55 -04:00
Sahil Shah
92f85ff3a0
gh-80184: Set getattr(socket, "SOMAXCONN", 5) as the default queue size for TCPServer (GH-134249)
socketserver.TCPServer default queue size becomes SOMAXCONN instead of 5 when possible.
2025-05-19 19:28:09 +00:00
Peter Bierma
27bd08273c
Revert "gh-128639: Don't assume one thread in subinterpreter finalization (gh-128640)" (gh-134256)
This reverts commit 9859791f9e.

The original change broke the iOS and android buildbots, where the tests are run single-process.
2025-05-19 12:22:05 -06:00
Serhiy Storchaka
871d269875
gh-117596: Add more tests for os.path with invalid paths (GH-134189) 2025-05-19 21:17:58 +03:00
Victor Stinner
e79f640eb6
Simplify interp_look_up_id() (#134257)
Don't use PyInterpreterState_GetID() but get directly the interpreter
'id' member which cannot fail.
2025-05-19 18:09:10 +00:00
Semyon Moroz
71c42b778d
gh-126883: Add check that timezone fields are in range for datetime.fromisoformat (#127242)
It was previously possible to specify things like `+00:90:00` which would be equivalent to `+01:30:00`, but is not a valid ISO8601 string.

---------

Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Co-authored-by: Paul Ganssle <1377457+pganssle@users.noreply.github.com>
2025-05-19 14:07:11 -04:00
Tomas R.
8d490b3687
GH-131798: Narrow the return type of isinstance for some known arguments in the JIT (GH-133172) 2025-05-19 13:19:24 -04:00
Peter Bierma
9859791f9e
gh-128639: Don't assume one thread in subinterpreter finalization (gh-128640)
Incidentally, this also fixed the warning not showing up if a subinterpreter wasn't
cleaned up via _interpreters.destroy. I had to update some of the tests as a result.
2025-05-19 10:24:08 -06:00
László Kiss Kollár
c4ad92e155
Fix typo in get_stack_trace docstring (#134246) 2025-05-19 16:07:39 +00:00
sobolevn
a36ce264a9
GH-134236: make regen-all (GH-134237) 2025-05-19 11:39:43 -04:00
naya451
c45e661226
gh-131505: Move len boundary assertions before using len. (#131536)
Move len boundary assertions before using len.
2025-05-19 08:10:23 -07:00
Dino Viehland
3fa30d9e9c
gh-128045: Syncs w/ latest opcode metadata (#134231)
Fix opcode metadata
2025-05-19 11:08:50 -04:00
Duprat
de70614c13
gh-132795: Add docs for multiprocessing.Semaphore.locked (#133299) 2025-05-19 20:06:09 +05:30
Jessica Temporal
faebf87b37
gh-134214: Fix test case in pyrepl (gh-134223) 2025-05-19 16:26:04 +02:00
Dino Viehland
cc9add695d
gh-128045: Mark unknown opcodes as deopting to themselves (#128044)
* Mark unknown opcodes as deopting to themselves
2025-05-19 10:15:16 -04:00
Loïc Simon
71ea6a6798
gh-134158: Fix PyREPL coloring of double braces in f/t-strings (gh-134159)
Co-authored-by: Loïc Simon <loic.simon@napta.io>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2025-05-19 16:12:23 +02:00
Étienne Pelletier
b22460c44d
gh-125225: Fix column misalignment in help('topics') output (gh-125226)
The 'help("topics")' output was misaligned due to "ASSIGNMENTEXPRESSIONS"
exceeding the implicit maximum default column width of 19 characters.

Reduced the number of columns from 4 to 3 in the listtopics()
function to allow more space for longer topic names.

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2025-05-19 16:10:17 +02:00
Bénédikt Tran
ee36db5500
gh-125843: indicate which C function caused a curses.error (#125844)
- Rename error helpers with a `curses_set_error_*` prefix instead of `PyCurses*`.
- Cleanly report both NULL and ERR cases.
- Raise `curses.error` in `is_linetouched` instead of a `TypeError`.
2025-05-19 15:53:39 +02:00
Kirill Podoprigora
c31547a591
gh-134097: Print number of refs & blocks after each statement in new REPL (gh-134136)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2025-05-19 15:30:43 +02:00
Serhiy Storchaka
44b73d3cd4
gh-122055: Clarify documentation for empty matches in RE (GH-133169) 2025-05-19 15:27:50 +02:00
ggqlq
605022aeb6
gh-131178: Add tests for http.server command-line interface (#132540) 2025-05-19 12:15:04 +00:00
Steve Dower
986c367028
gh-133779: Revert Windows generation of pyconfig.h and go back to a static header. (GH-133966)
Extension builders must specify Py_GIL_DISABLED if they want to link to the free-threaded builds.
This was usually the case already, but this change guarantees it in all circumstances.
2025-05-19 11:35:22 +01:00
BecoKo
d55e11b804
gh-76023: Make os.path.realpath to ignore WinError 1005 in non-strict mode (GH-128328) 2025-05-19 09:33:15 +00:00
Bénédikt Tran
d6dc33ed80
gh-134087: enforce signature of threading.RLock (#134178)
- Reject positional and keyword arguments in `_thread.RLock.__new__`.
- Convert `_thread.lock.__new__` to AC.
2025-05-19 11:26:14 +02:00
Serhiy Storchaka
9983c7d441
gh-133890: Handle UnicodeEncodeError in tarfile (GH-134147)
UnicodeEncodeError is now handled the same way as OSError during
TarFile member extraction.
2025-05-18 22:21:06 +03:00
Serhiy Storchaka
5cbc8c632e
gh-133889: Only show the path of the URL in the SimpleHTTPRequestHandler page (GH-134135)
The query and fragment are ambiguous and not used.
2025-05-18 18:09:51 +00:00
da-woods
bb32f3c698
document Py_VISIT as a macro in the docs (#133688) 2025-05-18 21:58:43 +05:30
Nybblista
2cc99b3dd3
Docs: Fix the _PyGenObject_HEAD reference in the InternalDocs/generators.md (#133739) 2025-05-18 21:56:58 +05:30
Dave Jagoda
a1e2e6ca91
Fix example in Doc/howto/functional.rst (#133978) 2025-05-18 21:56:17 +05:30
Yongzi Li
4ce91871a9
fix indent in controlflow.rst docs (#134008) 2025-05-18 21:51:02 +05:30
Stan Ulbrych
b1c33294ca
gh-134114: Clarify FAQ note about dictonary keys (#134118) 2025-05-18 15:59:20 +00:00
J. Nick Koston
53da1e8c8c
gh-134173: optimize state transfer between concurrent.futures.Future and asyncio.Future (#134174)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-05-18 21:26:20 +05:30
b-pass
f2de1e6861
gh-134144: Fix use-after-free in zapthreads() (#134145) 2025-05-18 20:32:29 +05:30
Bénédikt Tran
0a160bf14c
gh-133157: remove usage of _Py_NO_SANITIZE_UNDEFINED in faulthandler (#134047)
In `faulthandler_sigfpe()`, instead of using 1/0 arithmetic, we explicitly raise SIGFPE.
We also remove `faulthandler._read_null()` since reading from NULL is an undefined
behavior and `faulthandler` should not check for low-level C undefined behaviors.
2025-05-18 10:16:10 +02:00
Bénédikt Tran
22e4a40d90
gh-134082: modernize string.Formatter class docstring (#134125)
fixup Formatter class docstring
2025-05-18 10:10:54 +02:00
Nico-Posada
4e9005d32f
gh-134100: Fix use-after-free in PyImport_ImportModuleLevelObject (#134117) 2025-05-18 12:41:38 +05:30
Micha Albert
fa4e088668
gh-134150: Clarify distinction between JSON and Python objects (#134154)
* gh-134150: Clarify distinction between JSON objects and Python objects in json module docs

* Revert change to JSON introduction

* Clarify occurrences of "object literal" as JSON
2025-05-17 21:47:37 -04:00
Victor Stinner
009e7b3698
gh-134064: Fix sys.remote_exec() error checking (#134067) 2025-05-18 00:24:40 +02:00
Jelle Zijlstra
fc7f4c3666
gh-134119: Fix crash from calling next() on exhausted template iterator (#134120)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-05-17 12:23:19 -07:00
sobolevn
84914ad0e5
gh-133999: Fix except parsing regression in 3.14 (#134035) 2025-05-17 17:57:02 +03:00
Kirill Podoprigora
7a9d46295a
gh-88275: Add missing __init__ method to match example (#120281) 2025-05-17 15:11:19 +02:00
Clifford Gama
b41d79c776
Docs: fix spelling of "test case" in unittest documentation (#134137) 2025-05-17 13:36:38 +02:00
Peter Bierma
af6b3b825f
Docs: C API: Improve documentation around non-Python threads with subinterpreters (GH-131087)
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-05-17 10:58:41 +02:00
Victorien
9d73875072
gh-113878: fix versionadded in dataclasses.field() documentation (#134065) 2025-05-17 10:00:13 +02:00
Oleg Burnaev
c1c9ad1d5a
gh-133881: add forward reference to list.sort() in lambda expression tutorial (#133910) 2025-05-17 09:59:37 +02:00
Bénédikt Tran
faac627e47
gh-133810: remove http.server.CGIHTTPRequestHandler and --cgi flag (#133811)
The CGI HTTP request handler has been deprecated since Python 3.13.
2025-05-17 09:58:16 +02:00
Serhiy Storchaka
2f1ecb3bc4
gh-134098: Fix handling %-encoded trailing slash in SimpleHTTPRequestHandler (GH-134099) 2025-05-17 10:11:34 +03:00
Serhiy Storchaka
fcaf009907
gh-133889: Improve tests for SimpleHTTPRequestHandler (GH-134102) 2025-05-17 10:00:56 +03:00
Serhiy Storchaka
71cf4dd622
gh-134109: Fix showing comments in pydoc output for argparse (GH-134110)
Comments immediately preceding the object's source code are used
if the object has no docstring.
Comments that do not describe the object should be separated from
the following source code by an empty line.
2025-05-16 23:29:14 +03:00
Saleh Dehqanpour
ea2d707bd5
gh-117026: Remove outdated sentence in SimpleHTTPRequestHandler docs (GH-117027)
The code was changed in 0f7cddc308 (bpo-839496/gh-39531).
2025-05-16 19:12:40 +00:00
alexey semenyuk
ac8df4b589
gh-133286: add explanation about seq for pathlib Pattern Language (#133340) 2025-05-16 18:42:06 +00:00
Bénédikt Tran
b5febf73b9
gh-134082: modernize docstrings in string.Formatter (#134083) 2025-05-16 18:36:48 +00:00
Kumar Aditya
d94b1e9cac
gh-133515: fix docs for unawaited coroutines in debug mode (#134081) 2025-05-16 21:01:15 +05:30
Alexey Makridenko
7a4a6cf2b8
gh-133604: remove deprecated java_ver function (#133888) 2025-05-16 16:17:54 +02:00
Semyon Moroz
62f66caa8c
gh-124210: Add introduction to threading docs (#127046)
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-05-16 15:17:29 +03:00
Bénédikt Tran
73d71a416f
gh-132388: test HACL* and OpenSSL hash functions in pure Python HMAC (#134051) 2025-05-16 14:00:01 +02:00
aeiouaeiouaeiouaeiouaeiouaeiou
1566c34dc7
gh-134069: bump HACL* revision to incoporate memset_s (#134027)
Bumps the HACL* revision to include recent revisions that corrects issues
building with legacy/cross-platform macOS SDKs.

Signed-off-by: aeiouaeiouaeiouaeiouaeiouaeiou <aeioudev@outlook.com>
2025-05-16 06:23:11 -04:00
AN Long
7a504b3d5d
gh-130000: Release the GIL in winreg when doing Windows API calls (GH-130001) 2025-05-16 00:00:06 +01:00
Steve Dower
6a22963291
Improve the administrative install docs for Python Install Manager (GH-134066) 2025-05-15 22:11:31 +01:00
Max Bachmann
20095fb29a
Fix GetNamedPipeHandleStateW on non-desktop Windows API partitions (GH-134049) 2025-05-15 21:12:10 +01:00
Semyon Moroz
52a7a22a6b
gh-77065: Use putwch instead of putch in getpass.win_getpass (#134058) 2025-05-15 15:14:31 +00:00
Bénédikt Tran
3f61ea3add
gh-133873: remove deprecated mark interface for wave.Wave_{read,write} objects (#133874) 2025-05-15 14:52:07 +00:00
Hugo van Kemenade
319acf3d6c
gh-133410: Fix PR detection in build workflow (#133671) 2025-05-15 16:10:56 +03:00
Semyon Moroz
d029a1a1cb
gh-77065: add missing parameter echo_char in getpass.fallback_getpass (#133849) 2025-05-15 15:07:34 +02:00
Max Bachmann
74c4e35ff1
Let PyUnicode_FromWideChar calculate the input length (GH-134045) 2025-05-15 11:56:50 +00:00
Max Bachmann
1c4b34c6cb
gh-134041: Make _winapi functions compatible with non-desktop API partitions (GH-134042) 2025-05-15 11:50:46 +00:00
Max Bachmann
43410953c2
gh-133572: Avoid using NTSTATUS on unsupported WinAPI partitions (GH-133573) 2025-05-15 11:59:11 +01:00
Hugo van Kemenade
54a6875adb
gh-119535: 3.15 minus π (#134037)
* Revert "gh-119535: Support 𝜋thon in Python 3.14 venvs (#125035)"

This reverts commit fcef3fc9a5.

* Revert "gh-119535: python𝜋 (#119536)"

This reverts commit 3fc673e97d.
2025-05-15 02:39:42 -07:00
sobolevn
7eaa097390
gh-133403: Check Tools/build/deepfreeze.py with mypy (#133802) 2025-05-15 12:13:03 +03:00
sobolevn
c3a1da5b93
gh-133970: Make PEP750 types generic (#133976) 2025-05-15 09:11:46 +03:00
Serhiy Storchaka
e123a1d09b
Test also error messages in test_limit_int. (GH-134018) 2025-05-14 17:53:51 +00:00
Duane Griffin
ffaeb3dddf
gh-127081: add critical sections to dbm objects (gh-132749) 2025-05-14 13:49:35 -04:00
Serhiy Storchaka
17d0fec702
Improve tests for str to Fraction conversion (GH-134010) 2025-05-14 20:16:07 +03:00
Maciej Olko
0afbd4e42a
Docs: remove link elements in builders other than HTML (#133720)
Fixes epub build
2025-05-14 10:03:07 -04:00
Jelle Zijlstra
9836503b48
gh-133701: Fix incorrect __annotations__ on TypedDict defined under PEP 563 (#133772) 2025-05-14 06:24:33 -07:00
Max Bachmann
5d118d0a92
gh-133580: Add missing exception to _sys_getwindowsversion_from_kernel32 (GH-133574) 2025-05-14 14:10:35 +01:00
Emma Smith
b44c824856
gh-132983: Style improvements for compression.zstd (#133547)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-05-14 12:08:27 +00:00
Max Bachmann
e7ad59bd73
gh-133568: Only set HAVE_AF_HYPERV on supported WinAPI partitions (GH-133569) 2025-05-14 11:42:33 +00:00
Max Bachmann
e528aef7e2
gh-133562: Skip security descriptors on unsupported Windows API partitions (GH-133563) 2025-05-14 11:34:41 +00:00
Joey Smith
3e23047363
gh-133986: Document string split algorithm when sep is None and maxsplit is 0 (#133987)
* Document string split algorithm when sep is None and maxsplit is 0

* Update Doc/library/stdtypes.rst

Co-authored-by: Semyon Moroz <donbarbos@proton.me>

---------

Co-authored-by: Ned Batchelder <ned@nedbatchelder.com>
Co-authored-by: Semyon Moroz <donbarbos@proton.me>
2025-05-14 06:17:26 -04:00
Rafael Fontenelle
6df39765e6
Remove trailing whitespace from python.gram (#133858)
Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
2025-05-14 10:52:19 +03:00
Sebastian Pipping
2eb49d278e
gh-133577: Add parameter formatter to logging.basicConfig (GH-133578) 2025-05-14 07:45:00 +01:00
Peter Hawkins
9ad0c7b0f1
gh-132641: fix race in lru_cache under free-threading (#133787)
Fix race in `lru_cache` by acquiring critical section on the cache object itself and call the lock held variant of dict functions to modify the underlying dict.
2025-05-13 17:38:57 +00:00
Carey Metcalfe
35f47d0589
gh-132983: Fix small issues with zstd support in zipfile (#133723)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Emma Smith <emma@emmatyping.dev>
2025-05-13 16:43:09 +01:00
Serhiy Storchaka
18bf8f84aa
gh-95380: Remove the 1024 bytes limit in fcntl.fcntl() and fcntl.ioctl() (GH-132907) 2025-05-13 14:44:07 +00:00
Victor Stinner
fe9f6e829a
gh-133968: Add fast path to PyUnicodeWriter_WriteStr() (#133969)
Don't call PyObject_Str() if the input type is str.
2025-05-13 15:31:41 +02:00
Steve Dower
fc3cddd90a
gh-133928: Improvements to using/windows.rst (GH-133952) 2025-05-13 12:38:59 +01:00
Petr Viktorin
e575190abb
gh-132983: Call Py_XDECREF rather than PyObject_GC_Del in failed __new__ (GH-133962)
Call Py_XDECREF rather than PyObject_GC_Del in failed __new__

This will call tp_dealloc and clear all members.
2025-05-13 11:11:52 +02:00
Serhiy Storchaka
c09cec5d69
gh-133886: Fix sys.remote_exec() for non-UTF-8 paths (GH-133887)
It now supports non-ASCII paths in non-UTF-8 locales and
non-UTF-8 paths in UTF-8 locales.
2025-05-13 11:55:24 +03:00
Eric Snow
8cf4947b0f
gh-132775: Add _PyFunction_GetXIData() (gh-133481) 2025-05-12 22:10:56 +00:00
Erlend E. Aasland
121ed71f4e
gh-132983: Fix compiler warning about unused function `mt_continue_should_break()` (#133947) 2025-05-12 20:23:40 +01:00
sobolevn
e8665d4d46
gh-133885: skip test_compress_locking in test_zstd (#133943) 2025-05-12 19:15:44 +00:00
changlehung(牧牛的铃铛)
ae74e3f863
gh-133926: pass commands via remote_pdb.set_trace instead of using remote_pdb.rcLines.extend (#133933) 2025-05-12 15:11:36 -04:00
ppaez
86c1d439e0
gh-133413: Fix references to removed Request.has_data (GH-133414)
The has_data() method of http.request.Request
was removed in version 3.4.
2025-05-12 21:17:57 +03:00
Barney Gale
5dbd27db7d
GH-128520: pathlib ABCs: add JoinablePath.__vfspath__() (#133437)
In the abstract interface of `JoinablePath`, replace `__str__()` with
`__vfspath__()`. This frees user implementations of `JoinablePath` to
implement `__str__()` however they like (or not at all.)

Also add `pathlib._os.vfspath()`, which calls `__fspath__()` or
`__vfspath__()`.
2025-05-12 19:00:36 +01:00
Serhiy Storchaka
9f69a58623
gh-133767: Fix use-after-free in the unicode-escape decoder with an error handler (GH-129648)
If the error handler is used, a new bytes object is created to set as
the object attribute of UnicodeDecodeError, and that bytes object then
replaces the original data. A pointer to the decoded data will became invalid
after destroying that temporary bytes object. So we need other way to return
the first invalid escape from _PyUnicode_DecodeUnicodeEscapeInternal().

_PyBytes_DecodeEscape() does not have such issue, because it does not
use the error handlers registry, but it should be changed for compatibility
with _PyUnicode_DecodeUnicodeEscapeInternal().
2025-05-12 20:42:23 +03:00
Serhiy Storchaka
734e15b70d
gh-133653: Fix argparse.ArgumentParser with the formatter_class argument (GH-133813)
* Fix TypeError when formatter_class is a custom subclass of
  HelpFormatter.
* Fix TypeError when formatter_class is not a subclass of
  HelpFormatter and non-standard prefix_char is used.
* Fix support of colorizing when formatter_class is not a subclass of
  HelpFormatter.
* Remove the prefix_chars parameter of HelpFormatter.
2025-05-12 20:27:34 +03:00
Serhiy Storchaka
14305a83d3
gh-133677: Fix tests when running in non-UTF-8 locale (GH-133865) 2025-05-12 19:09:11 +03:00
Stan Ulbrych
d1533115ba
gh-133530: Modify Heapq docs image settings (gh-133937)
Add class
2025-05-12 11:03:28 -05:00
Jelle Zijlstra
8d478c7953
gh-133925: Make typing._UnionGenericAlias hashable (#133929) 2025-05-12 08:22:55 -07:00
mkaraev
27ed64575d
gh-133904: Fix math.factorial documentation (#133907)
Co-authored-by: sobolevn <mail@sobolevn.me>
2025-05-12 09:41:15 +00:00
Victor Stinner
c2989b7070
gh-133744: Fix multiprocessing interrupt test: add an event (#133746)
Add an event to synchronize the parent process with the child
process: wait until the child process starts sleeping.
2025-05-12 11:10:48 +02:00
Adam Turner
d29ddbd90c
gh-132983: Convert zstd `__new__` methods to Argument Clinic (#133860) 2025-05-12 08:51:53 +00:00
Jelle Zijlstra
0eb448cae5
gh-119180: annotationlib: Fix values of Format members in docs (#133841)
gh-119180: Fix values of Format members in docs
2025-05-11 08:43:24 -07:00
Jelle Zijlstra
3396df56d0
gh-119180: More documentation for PEP 649/749 (#133552)
The SC asked that the Appendix in PEP-749 be added to the docs.

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-05-11 08:43:17 -07:00
Sebastian Rittau
1d3eacedb8
gh-133893: asyncio.graph: Replace TextIO annotation with io.Writer (#133894) 2025-05-11 17:59:56 +03:00
Bénédikt Tran
13cb8ca3da
gh-133879: Copyedit "What's New in Python 3.15" (#133880) 2025-05-11 09:14:20 +00:00
Kumar Aditya
9b9cdb6440
gh-100926: use explicit stginfo lock for pointer cache (#133867) 2025-05-11 08:24:20 +00:00
Lauta
c838e21fda
gh-133590: ensure that TableEntry.linenumber_borrow is initialized (#133681) 2025-05-11 10:16:28 +02:00
Bénédikt Tran
f91127ae1a
gh-133823: update "Pending Removal in 3.15" notes about TypedDict (#133864) 2025-05-11 10:10:54 +02:00
Bénédikt Tran
87312119da
gh-133823: require explicit empty sequence for 0-field TypedDict objects (#133863) 2025-05-11 08:04:45 +00:00
Bénédikt Tran
add828951e
gh-92897: document removal of check_home in Doc/whatsnew/3.15.rst (#133815) 2025-05-11 07:47:14 +00:00
Bénédikt Tran
c5e1775825
gh-133817: remove keyword arguments syntax for NamedTuple (#133822) 2025-05-11 09:05:56 +02:00
Inada Naoki
92337f666e
gh-133703: dict: fix calculate_log2_keysize() (GH-133809) 2025-05-11 14:44:21 +09:00
Rogdham
878e0fb8b4
gh-132983: Remove leftovers from EndlessZstdDecompressor (#133856)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-05-11 02:04:25 +00:00
Adam Turner
1a87b6e9ae
gh-132983: Make zstd types immutable (#133784) 2025-05-10 22:37:17 +00:00
Bénédikt Tran
dc191d2484
gh-133336: Remove comment about reserved -J in `initconfig.c` (#133821) 2025-05-10 22:31:45 +01:00
Adam Turner
1a548c0a50
gh-132983: Reduce the size of `_zstdmodule.h` (#133793) 2025-05-10 22:25:22 +01:00
Tian Gao
4f2f780d53
Add classmethod to setUpClass in test_pdb (#133840) 2025-05-10 14:10:58 -04:00
Kumar Aditya
70f9b3de36
gh-100926: fix thread safety of ctypes __pointer_type__ (#133843) 2025-05-10 17:38:06 +00:00
Waylan Limberg
53383e90e4
gh-86155: Fix data loss after unclosed script or style tag in HTMLParser (GH-22658)
When calling .close() the HTMLParser should flush all remaining content,
even when that content is in an unclosed script or style tag.
2025-05-10 17:36:06 +00:00
Jelle Zijlstra
7dddb4e667
gh-133783: Fix __replace__ on AST nodes for optional attributes (#133797) 2025-05-10 09:17:38 -07:00
Ayappan Perumal
47f1722d80
gh-117088: Fix AIX build (GH-132595) 2025-05-10 18:35:59 +03:00
Kentaro Jay Takahashi
efcc42ba70
gh-132642: document how to render human-readable timedelta objects (#133825) 2025-05-10 17:33:28 +02:00
Ezio Melotti
76c0b01bc4
gh-77057: Fix handling of invalid markup declarations in HTMLParser (GH-9295)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-05-10 17:31:43 +03:00
Tim Golden
e7741dd773
Tiny doc fix to double up backslashes in a Windows filesystem path (#133828) 2025-05-10 13:45:46 +00:00
Stan Ulbrych
dbca27cfca
gh-133379: Fix misuse of the term "arguments" in error messages (GH-133382)
The right term is "parameters".
2025-05-10 15:00:43 +03:00
Donghee Na
f28cbc9fd3
gh-115999: Note Python 3.14 free-threaded changes in What's New (gh-131285)
---------

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: T. Wouters <thomas@python.org>
Co-authored-by: mpage <mpage@cs.stanford.edu>
2025-05-10 19:30:16 +09:00
Stan Ulbrych
30b1d8f11d
gh-133447: Add basic color to sqlite3 CLI (#133461) 2025-05-10 07:59:01 +00:00
Bénédikt Tran
116a9f9b37
gh-133009: fix UAF in xml.etree.ElementTree.Element.__deepcopy__ (#133010) 2025-05-10 09:32:39 +02:00
Kokona
d13d5fdf61
gh-132971: Update shutil.which() docs (GH-133067) 2025-05-10 10:06:19 +03:00
Nybblista
832058274d
gh-133713: Compare the f->stackpointer to the result of _PyFrame_Stackbase(f) (GH-133714) 2025-05-10 11:04:32 +08:00
Rogdham
50b5370664
gh-132983: Don't allow trailer data in ZstdFile (#133736) 2025-05-10 03:32:22 +01:00
Tan Long
c896dae029
Fix a typo in Misc/NEWS.d/3.140a1.rst (#133790) 2025-05-10 03:31:24 +01:00
Jelle Zijlstra
cb6596c6aa
gh-132493: Remove __annotations__ usage in inspect._signature_is_functionlike (#133415)
This check is potentially problematic because it could force evaluation of
annotations unnecessarily. This doesn't trigger for builtin objects (functions,
classes, or modules) with annotations, but it could trigger for third-party objects.

The check was not particularly useful anyway, because it succeeds if ``__annotations__``
is a dict or None, so the only thing this did was guard against objects that have an
``__annotations__`` attribute that is of some other type. That doesn't seem particularly
useful, so I just removed the check.
2025-05-09 18:42:53 -07:00
Adam Turner
1978904a2f
GH-132983: PEP 7 and Argument Clinic changes for zstd (#133791) 2025-05-10 00:33:45 +00:00
Adam Turner
98e2c3af47
GH-132983: remove empty_bytes from _zstd module state (#133785) 2025-05-09 20:17:12 +00:00
Adam Turner
bbe9c31edc
gh-132983: Simplify `_zstd_exec()` (#133775) 2025-05-09 20:15:19 +01:00
Stan Ulbrych
aed28eb5a0
Update HTTP links in the _pydatetime docstrings (GH-133025) 2025-05-09 21:38:37 +03:00
Stan Ulbrych
74f897e25e
Remove unused code from _pydatetime.py (GH-133768)
It should have been removed in PR #7549 (bcb032e4ac).
2025-05-09 21:32:25 +03:00
AN Long
4274b47156
gh-133519: Add console to resources in libregrtest (#133520)
Add console to resources in libregrtest
2025-05-09 18:30:13 +02:00
Victor Stinner
67086282fc
gh-133741: Fix _can_strace(): check --trace option (#133766)
The --trace option needs strace 5.5 or newer.
2025-05-09 18:25:47 +02:00
Victor Stinner
6d9ec4e9d7
gh-133644: Avoid deprecated Py_SetProgramName() in _testembed.c (#133665)
* Rename _testembed_Py_InitializeFromConfig() to
  _testembed_initialize().
* Replace _testembed_Py_Initialize() with _testembed_initialize().
2025-05-09 17:50:21 +02:00
Éric
de28651a7f
gh-123299: Some copyedits to What's New in 3.14 (#133622) 2025-05-09 11:32:26 -04:00
Stan Ulbrych
4fd1095280
gh-133610: Remove PyUnicode_AsDecoded/Encoded functions (#133612) 2025-05-09 17:31:24 +02:00
Stan Ulbrych
f34ec09ba5
gh-46236: Document PyUnicode_BuildEncodingMap (#133270) 2025-05-09 17:19:07 +02:00
sobolevn
cd2f234ad2
gh-133403: Check Tools/build/generate-build-details.py with mypy (#133735) 2025-05-09 17:21:49 +03:00
Yongzi Li
076004ae54
Docs: use boolean constants for returning boolean value (GH-133325) 2025-05-09 17:11:50 +03:00
Stefano Rivera
2a630a35cf
Manpage: -X gil is not related to PYTHON_HISTORY (#133753) 2025-05-09 17:11:21 +03:00
Adam Turner
2c7cac4c0d
GH-132983: Restore libzstd fallback detection (#133565) 2025-05-09 15:09:20 +01:00
Adam Turner
c2a5d4b383
gh-132983: Clean-ups for `_zstd` (#133670) 2025-05-09 15:08:51 +01:00
Akshat Gupta
a2a0fa91c4
gh-133682: Fix inconsistent set ordering in annotationlib test (#133702) 2025-05-09 07:01:01 -07:00
Bénédikt Tran
3ed8d6fdd1
gh-133644: update Py_InteractiveFlag deprecation notice (#133749) 2025-05-09 15:42:42 +02:00
Tan Long
ebd4881db2
gh-133439: Fix dot commands with trailing spaces are mistaken for multi-line sqlite statements in the sqlite3 command-line interface (GH-133440) 2025-05-09 11:41:10 +00:00
Bénédikt Tran
5044e85265
gh-133644: Remove deprecated Python initialization getter functions (#133661)
Remove functions:

* Py_GetExecPrefix()
* Py_GetPath()
* Py_GetPrefix()
* Py_GetProgramFullPath()
* Py_GetProgramName()
* Py_GetPythonHome()
2025-05-09 11:39:23 +00:00
Tomas R.
f52de8a937
gh-133017: Improve error message for invalid typecodes in multiprocessing.{Array,Value} (GH-133252) 2025-05-09 11:46:45 +03:00
Kumar Aditya
2cd24ebfe9
fix thread safety of io.StringIO.truncate (#133732) 2025-05-09 07:59:17 +00:00
Jelle Zijlstra
308ceffc68
gh-133581: Fix refleak in t-string AST unparsing (#133724) 2025-05-09 09:10:52 +02:00
Will Childs-Klein
6801bd32cb
gh-133623: Add ssl.HAS_PSK_TLS13 to detect external TLS 1.3 PSK support (#133624) 2025-05-09 09:09:09 +02:00
Nybblista
f77dac66e1
gh-133412: amend docs for the inst definition (#133708)
The `stack_effect` is incorrectly documented as being allowed to be optional.
2025-05-09 09:06:22 +02:00
vfdev
8054184f9f
gh-133253: making linecache thread-safe (#133305)
Co-authored-by: Sam Gross <colesbury@gmail.com>
2025-05-09 12:15:16 +05:30
Nybblista
6d5a8c2ec1
gh-133476: Assert with the PyStackRef_IsTaggedInt function (GH-133477) 2025-05-09 08:17:50 +08:00
Tomas R.
c492ac7252
GH-131798: Split up and optimize CALL_ISINSTANCE (GH-133339) 2025-05-08 14:26:30 -07:00
Łukasz Langa
b2fabce6ab
gh-133541: Handle SyntaxError raised by the tokenizer on user input (#133606) 2025-05-08 21:14:38 +01:00
Steve Dower
6ce469dcba
gh-133626: Ensure the traditional Windows installer doesn't accidentally pick up site-packages (GH-133693) 2025-05-08 20:47:36 +01:00
Rafael Fontenelle
9546eeea90
Fix typo in pending-removal-in-3.14.rst (GH-133680) 2025-05-08 18:57:23 +00:00
Tomasz Pytel
5dd3a3a58c
gh-132551: make io.BytesIO thread safe (#132616)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-05-08 18:51:36 +00:00
Adam Turner
bd7c5859c6
GH-132983: Remove subclassing support from zstd types (#133694)
For consistency with ``bz2``, ``lzma``, and ``zlib``.
2025-05-08 18:35:22 +00:00
Steve Dower
dd670fa7ca
Adds docs to help with troubleshooting pip installs. (GH-133692) 2025-05-08 19:30:01 +01:00
Adam Turner
6f6f48d289
gh-103092: Support subinterpreters in `_zstd` (#133674) 2025-05-08 19:11:34 +01:00
Tomas R.
3f2f59a91d
gh-133273: Keep instruction definitions in bytecodes.c and optimizer_bytecodes.c in sync (GH-133320) 2025-05-09 01:54:49 +08:00
Flosckow
5f3d3f2a6c
gh-133403: Check Tools/build/verify_ensurepip_wheels.py with mypy (#133453)
Co-authored-by: Daniil Dumchenko <dumchenko.de@sibvaleo.com>
Co-authored-by: sobolevn <mail@sobolevn.me>
2025-05-08 17:53:47 +00:00
Angela Liss
421ba589d0
gh-132762: Fix underallocation bug in dict.fromkeys()(gh-133627)
The function `dict_set_fromkeys()` adds elements of a set to an existing
dictionary. The size of the expanded dictionary was estimated with
`PySet_GET_SIZE(iterable)`, which did not take into account the size of the
existing dictionary.
2025-05-08 13:13:11 -04:00
Kumar Aditya
2d82ab761a
gh-132886: use relaxed atomics for sock_fd in gil builds in socket module (#133208) 2025-05-08 22:33:41 +05:30
Brett Cannon
7d129f99ab
Clarify some wording in wasi(\.py)? (GH-133619) 2025-05-08 09:54:46 -07:00
Eric Snow
c81fa2b9cd
gh-132775: Add _PyCode_GetScriptXIData() (gh-133480)
This converts functions, code, str, bytes, bytearray, and memoryview objects to PyCodeObject,
and ensure that the object looks like a script.  That means no args, no return, and no closure.
_PyCode_GetPureScriptXIData() takes it a step further and ensures there are no globals.

We also add _PyObject_SupportedAsScript() to the internal C-API.
2025-05-08 15:07:46 +00:00
Xuehai Pan
f0f93ba5fa
gh-131942: Use the Python-specific Py_DEBUG macro rather than _DEBUG in Windows-related C code (GH-131944) 2025-05-08 15:01:25 +00:00
Serhiy Storchaka
e15bbfafbc
gh-131031: Fix test_pickle when invoked directly (GH-133356) 2025-05-08 17:51:18 +03:00
Jelle Zijlstra
bfac7d2edc
gh-133581: Improve AST unparsing of t-strings (#133635) 2025-05-08 06:13:57 -07:00
Bénédikt Tran
a2c4467d06
gh-133644: remove deprecated PyImport_ImportModuleNoBlock (#133655) 2025-05-08 13:08:43 +00:00
Serhiy Storchaka
26839eae20
gh-133454: Mark tests with many threads that use much memory as bigmem (GH-133456) 2025-05-08 15:57:30 +03:00
Serhiy Storchaka
dcf93c4c93
gh-133595: Clean up sqlite3.Connection APIs (GH-133605)
* All parameters of sqlite3.connect() except "database" are now keyword-only.
* The first three parameters of methods create_function() and
  create_aggregate() are now positional-only.
* The first parameter of methods set_authorizer(), set_progress_handler()
  and set_trace_callback() is now positional-only.
2025-05-08 15:42:00 +03:00
Duane Griffin
2561e148ec
gh-91555: disable logger while handling log record (GH-131812)
Prevent the possibility of re-entrancy leading to deadlock or infinite recursion (caused by logging triggered by logging), by disabling logging while the logger is handling log messages.
2025-05-08 13:33:06 +01:00
Adam Turner
8bb92863de
Update the PCbuild sub-projects list (GH-133397) 2025-05-08 12:31:24 +01:00
Sergey Miryanov
0ec8fc83a8
gh-133597: Fix memory leak if error occurred in _sys_getwindowsversion_from_kernel32 (GH-133598) 2025-05-08 12:09:20 +01:00
Petr Viktorin
45bb5ba61a
gh-127833: Add links to token types to the lexical analysis intro (#131468)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-05-08 09:38:29 +00:00
Serhiy Storchaka
4c914e7a36
gh-133583: Add support for fixed size unsigned integers in argument parsing (GH-133584)
* Add Argument Clinic converters: uint8, uint16, uint32, uint64.
* Add private C API: _PyLong_UInt8_Converter(),
  _PyLong_UInt16_Converter(), _PyLong_UInt32_Converter(),
  _PyLong_UInt64_Converter().
2025-05-08 12:27:50 +03:00
Stan Ulbrych
3224b99872
Doc: Allow translating a code block in the tutorial (#131353)
Co-authored-by: Chris Markiewicz <effigies@gmail.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-05-08 09:22:04 +00:00
Tan Long
4617d68d73
gh-133639: Fix test_auto_indent_default() doesn't run input_code (#133640) 2025-05-08 09:24:19 +01:00
dgpb
afed5f8835
gh-125028: Prohibit placeholders in partial keywords (GH-126062) 2025-05-08 10:53:53 +03:00
Jonas Obrist
4fcd377563
gh-133641: Doc: Add missing source link in `concurrent.futures` (#133642)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-05-08 07:21:51 +00:00
Neil Schemenauer
8679c8d5cc
gh-133467: Add TSAN suppressions for races in typeobject (gh-133534) 2025-05-08 04:46:23 +00:00
Neil Schemenauer
8598e57942
gh-133532: Run GC fast cycles test in subprocess. (gh-133533)
This makes the test more reliable since there are not extra objects on the heap leftover
from other tests.
2025-05-08 04:38:57 +00:00
Neil Schemenauer
751db4e649
gh-132917: Use /proc/self/status for mem usage info. (#133544)
On Linux, use /proc/self/status for mem usage info.  Using smaps_rollup is quite a lot slower and
we can get the similar info from /proc/self/status.
2025-05-08 04:32:23 +00:00
Jelle Zijlstra
0a3ccb8dff
gh-133551: Skip annotationlib for now in ast roundtrip tests (#133634) 2025-05-07 19:35:44 -07:00
Stan Ulbrych
0552ce0fb2
gh-127833: lexical analysis: Add backticks to BOM example (#132407) 2025-05-08 02:34:48 +01:00
Alex Prengère
b48599b801
gh-133555: Allow regenerating the parser with Python < 3.14 (#133557)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-05-08 02:28:20 +01:00
Jelle Zijlstra
90f476e0f8
gh-133551: Support t-strings in annotationlib (#133553)
I don't know why you'd use t-strings in annotations, but now if you do,
the STRING format will do a great job of recovering the source code.
2025-05-07 18:10:35 -07:00
Rogdham
2cc6de77bd
gh-132983: Remove pyzstd in identifiers (#133535) 2025-05-08 01:47:42 +01:00
Stan Ulbrych
9fcebb3611
gh-133530: Replace binary tree textual digram with image (gh-133591)
Replace with image
2025-05-07 19:05:06 -05:00
Eric Snow
27128e4fa8
gh-132775: Unrevert "Add _PyCode_VerifyStateless()" (gh-133528)
This reverts commit 3c73cf5 (gh-133497), which itself reverted
the original commit d270bb5 (gh-133221).

We reverted the original change due to failing android tests.
The checks in _PyCode_CheckNoInternalState() were too strict,
so we've relaxed them.
2025-05-08 00:00:33 +00:00
Yongzi Li
61ac88c06e
gh-133361: move the explanation of dict equal before its use (#133424)
Also move up the explanation of insertion order preservation.  Both paragraphs seemed out of place down where they were.
---------

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2025-05-07 18:04:49 -04:00
Victor Stinner
79b8a32fcb
gh-133558: Skip test_pdb tests on FreeBSD (#133566)
'\x08' is not interpreted as backspace on FreeBSD.
2025-05-07 22:59:29 +02:00
Zachary Ware
14291faa52
wasi: Update the location of the 'config.site' file in the build script (GH-133611)
Also remove Tools/wasm from mypy CI workflow
2025-05-07 20:48:41 +00:00
Zachary Ware
74e2acddf6
Test fixes for 3.15 (GH-133599)
Followup to 942673ed19 (GH-133588)

* Update configure for Python 3.15

* Update magic number for 3.15

* Remove deprecated 'check_home' argument from sysconfig.is_python_build

* Add warningignore entries for Modules/_sqlite/clinic/connection.c.h

* Work around c-analyzer complaints about _testclinic deprecation tests

---------

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-05-07 14:50:39 -05:00
Max Bachmann
1460ccefd0
gh-133537: Avoid using console I/O in WinAPI partitions that don't support it (GH-133538) 2025-05-07 20:47:05 +01:00
Max Bachmann
427f8c366d
gh-133517: Remove os.listdrive, os.listvolumes and os.listmounts in non-desktop Windows builds (GH-133518) 2025-05-07 20:45:42 +01:00
Brett Cannon
1a137bc320 Merge branch 'main' of https://github.com/python/cpython 2025-05-07 12:12:01 -07:00
sobolevn
50b52cba2d
gh-133403: Type Tools/build/update_file.py and check it with mypy (#133404) 2025-05-07 22:11:04 +03:00
Brett Cannon
ee49644cc9 GH-133600: Refactor wasi.py into wasi/__main__.py
Along the way, also move related files into their appropriate directories and update `.github/CODEOWNERS`.
2025-05-07 12:10:53 -07:00
Bénédikt Tran
a054af6edd
gh-133575: eliminate legacy checks in Lib/curses/__init__.py (#133576) 2025-05-07 20:28:32 +02:00
TERESH1
d9b0b07098
gh-133516: Raise ValueError when constants True, False or None are used as an identifier after NFKC normalization (#133523) 2025-05-07 19:11:25 +01:00
Hugo van Kemenade
942673ed19
Finishing touches to update main branch for 3.15 (#133588) 2025-05-07 20:46:41 +03:00
Hugo van Kemenade
5ea24116b0 Merge branch 'main' of https://github.com/python/cpython 2025-05-07 18:53:08 +03:00
Brian Schubert
ee76e36d76
gh-131535: Fix stale example in html.parser docs, make examples doctests (GH-131551) 2025-05-07 18:50:05 +03:00
Sascha Ißbrücker
77b14a6d58
gh-69426: HTMLParser: only unescape properly terminated character entities in attribute values (GH-95215)
According to the HTML5 spec, named character references in attribute values
should only be processed if they are not followed by an ASCII alphanumeric,
or an equals sign.

https://html.spec.whatwg.org/multipage/parsing.html#named-character-reference-state
2025-05-07 18:49:49 +03:00
Hugo van Kemenade
9748fb3867 Python 3.15.0a0 2025-05-07 18:47:42 +03:00
2137 changed files with 215516 additions and 90161 deletions

View file

@ -1,13 +1,10 @@
{
"image": "ghcr.io/python/devcontainer:2024.09.25.11038928730",
"image": "ghcr.io/python/devcontainer:latest",
"onCreateCommand": [
// Install common tooling.
"dnf",
"install",
"-y",
"which",
"zsh",
"fish",
// For umask fix below.
"/usr/bin/setfacl"
],

View file

@ -0,0 +1,73 @@
{
"image": "ghcr.io/python/wasicontainer:latest",
"onCreateCommand": [
// Install common tooling.
"dnf",
"install",
"-y",
// For umask fix below.
"/usr/bin/setfacl"
],
"updateContentCommand": {
// Using the shell for `nproc` usage.
"python": "python3 Tools/wasm/wasi build --quiet -- --with-pydebug -C"
},
"postCreateCommand": {
// https://github.com/orgs/community/discussions/26026
"umask fix: workspace": ["sudo", "setfacl", "-bnR", "."],
"umask fix: /tmp": ["sudo", "setfacl", "-bnR", "/tmp"]
},
"customizations": {
"vscode": {
"extensions": [
// Highlighting for Parser/Python.asdl.
"brettcannon.zephyr-asdl",
// Highlighting for configure.ac.
"maelvalais.autoconf",
// C auto-complete.
"ms-vscode.cpptools",
// Python auto-complete.
"ms-python.python"
],
"settings": {
"C_Cpp.default.compilerPath": "/usr/bin/clang",
"C_Cpp.default.cStandard": "c11",
"C_Cpp.default.defines": [
"CONFIG_64",
"Py_BUILD_CORE"
],
"C_Cpp.default.includePath": [
"${workspaceFolder}/*",
"${workspaceFolder}/Include/**"
],
// https://github.com/microsoft/vscode-cpptools/issues/10732
"C_Cpp.errorSquiggles": "disabled",
"editor.insertSpaces": true,
"editor.rulers": [
80
],
"editor.tabSize": 4,
"editor.trimAutoWhitespace": true,
"files.associations": {
"*.h": "c"
},
"files.encoding": "utf8",
"files.eol": "\n",
"files.insertFinalNewline": true,
"files.trimTrailingWhitespace": true,
"python.analysis.diagnosticSeverityOverrides": {
// Complains about shadowing the stdlib w/ the stdlib.
"reportShadowedImports": "none",
// Doesn't like _frozen_importlib.
"reportMissingImports": "none"
},
"python.analysis.extraPaths": [
"Lib"
],
"[restructuredtext]": {
"editor.tabSize": 3
}
}
}
}
}

View file

@ -1,11 +1,11 @@
root = true
[*.{py,c,cpp,h,js,rst,md,yml,yaml}]
[*.{py,c,cpp,h,js,rst,md,yml,yaml,gram}]
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
[*.{py,c,cpp,h}]
[*.{py,c,cpp,h,gram}]
indent_size = 4
[*.rst]

4
.gitattributes vendored
View file

@ -10,6 +10,7 @@
*.ico binary
*.jpg binary
*.pck binary
*.pdf binary
*.png binary
*.psd binary
*.tar binary
@ -67,6 +68,7 @@ PCbuild/readme.txt dos
**/clinic/*.cpp.h generated
**/clinic/*.h.h generated
*_db.h generated
Doc/c-api/lifecycle.dot.svg generated
Doc/data/stable_abi.dat generated
Doc/library/token-list.inc generated
Include/internal/pycore_ast.h generated
@ -81,6 +83,7 @@ Include/opcode_ids.h generated
Include/token.h generated
Lib/_opcode_metadata.py generated
Lib/keyword.py generated
Lib/idlelib/help.html generated
Lib/test/certdata/*.pem generated
Lib/test/certdata/*.0 generated
Lib/test/levenshtein_examples.json generated
@ -101,3 +104,4 @@ Python/stdlib_module_names.h generated
Tools/peg_generator/pegen/grammar_parser.py generated
aclocal.m4 generated
configure generated
*.min.js generated

825
.github/CODEOWNERS vendored
View file

@ -1,142 +1,261 @@
# See https://help.github.com/articles/about-codeowners/
# for more info about CODEOWNERS file
# for further details about the .github/CODEOWNERS file.
# It uses the same pattern rule for gitignore file
# https://git-scm.com/docs/gitignore#_pattern_format
# Notably, a later match overrides earlier matches, so order matters.
# If using a wildcard pattern, try to be as specific as possible to avoid
# matching unintended files or overriding previous entries.
# To exclude a file from ownership, add a line with only the file.
# See the exclusions section at the end of the file for examples.
# GitHub
.github/** @ezio-melotti @hugovk @AA-Turner
# =======
# Purpose
# =======
#
# An entry in this file does not imply 'ownership', despite the name of the
# file, but instead that those listed take an interest in that part of the
# project and will automatically be added as reviewers to PRs that affect
# the matching files.
# See also the Experts Index in the Python Developer's Guide:
# https://devguide.python.org/core-developers/experts/
#
# =========
# Structure
# =========
#
# The CODEOWNERS file is organised by topic area.
# Please add new entries in alphabetical order within the relevant section.
# Where possible, keep related files together. For example, documentation,
# code, and tests for a given item should all be listed in the same place.
#
# GitHub usernames should be aligned to column 31, or the next multiple
# of three if the relevant paths are too long to fit.
#
# Top-level sections are:
#
# * Buildbots, Continuous Integration, and Testing
# project-wide configuration files, internal tools for use in CI,
# linting.
# * Build System
# the Makefile, autoconf, and other autotools files.
# * Documentation
# broader sections of documentation, documentation tools
# * Internal Tools & Data
# internal tools, integration with external systems,
# entries that don't fit elsewhere
# * Platform Support
# relating to support for specific platforms
# * Interpreter Core
# the grammar, parser, compiler, interpreter, etc.
# * Standard Library
# standard library modules (from both Lib and Modules)
# and related files (such as their tests and docs)
# * Exclusions
# exclusions from .github/CODEOWNERS should go at the very end
# because the final matching pattern will take precedence.
# pre-commit
.pre-commit-config.yaml @hugovk @AlexWaygood
# ----------------------------------------------------------------------------
# Buildbots, Continuous Integration, and Testing
# ----------------------------------------------------------------------------
# Azure Pipelines
.azure-pipelines/ @AA-Turner
# GitHub & related scripts
.github/ @ezio-melotti @hugovk @AA-Turner
Tools/build/compute-changes.py @AA-Turner
Tools/build/verify_ensurepip_wheels.py @AA-Turner @pfmoore @pradyunsg
# Pre-commit
.pre-commit-config.yaml @hugovk
.ruff.toml @hugovk @AlexWaygood @AA-Turner
# Build system
configure* @erlend-aasland @corona10
Makefile.pre.in @erlend-aasland
Modules/Setup* @erlend-aasland
# Patchcheck
Tools/patchcheck/ @AA-Turner
# argparse
**/*argparse* @savannahostrowski
# asyncio
**/*asyncio* @1st1 @asvetlov @kumaraditya303 @willingc
# ----------------------------------------------------------------------------
# Build System
# ----------------------------------------------------------------------------
# Core
**/*context* @1st1
**/*genobject* @markshannon
**/*hamt* @1st1
**/*jit* @brandtbucher @savannahostrowski
Objects/set* @rhettinger
Objects/dict* @methane @markshannon
Objects/typevarobject.c @JelleZijlstra
Objects/unionobject.c @JelleZijlstra
Objects/type* @markshannon
Objects/codeobject.c @markshannon
Objects/frameobject.c @markshannon
Objects/call.c @markshannon
Python/ceval*.c @markshannon
Python/ceval*.h @markshannon
Python/codegen.c @markshannon @iritkatriel
Python/compile.c @markshannon @iritkatriel
Python/assemble.c @markshannon @iritkatriel
Python/flowgraph.c @markshannon @iritkatriel
Python/instruction_sequence.c @iritkatriel
Python/bytecodes.c @markshannon
Python/optimizer*.c @markshannon
Python/optimizer_analysis.c @Fidget-Spinner
Python/optimizer_bytecodes.c @Fidget-Spinner
Python/symtable.c @JelleZijlstra @carljm
Lib/_pyrepl/* @pablogsal @lysnikolaou @ambv
Lib/test/test_patma.py @brandtbucher
Lib/test/test_type_*.py @JelleZijlstra
Lib/test/test_capi/test_misc.py @markshannon
Lib/test/test_pyrepl/* @pablogsal @lysnikolaou @ambv
Tools/c-analyzer/ @ericsnowcurrently
# Autotools
configure* @erlend-aasland @corona10 @AA-Turner @emmatyping
Makefile.pre.in @erlend-aasland @AA-Turner @emmatyping
Modules/makesetup @erlend-aasland @AA-Turner @emmatyping
Modules/Setup* @erlend-aasland @AA-Turner @emmatyping
Tools/build/regen-configure.sh @AA-Turner
# dbm
**/*dbm* @corona10 @erlend-aasland @serhiy-storchaka
# generate-build-details
Tools/build/generate-build-details.py @FFY00
Lib/test/test_build_details.py @FFY00
# Doc/ tools
Doc/conf.py @AA-Turner @hugovk
# ----------------------------------------------------------------------------
# Documentation
# ----------------------------------------------------------------------------
# Internal Docs
InternalDocs/ @AA-Turner
# Tools, Configuration, etc
Doc/Makefile @AA-Turner @hugovk
Doc/_static/ @AA-Turner @hugovk
Doc/conf.py @AA-Turner @hugovk
Doc/make.bat @AA-Turner @hugovk
Doc/requirements.txt @AA-Turner @hugovk
Doc/_static/** @AA-Turner @hugovk
Doc/tools/** @AA-Turner @hugovk
Doc/tools/ @AA-Turner @hugovk
# runtime state/lifecycle
**/*pylifecycle* @ericsnowcurrently
**/*pystate* @ericsnowcurrently
**/*preconfig* @ericsnowcurrently
**/*initconfig* @ericsnowcurrently
**/*pathconfig* @ericsnowcurrently
**/*sysmodule* @ericsnowcurrently
# PR Previews
.readthedocs.yml @AA-Turner
# Sections
Doc/reference/ @willingc @AA-Turner
Doc/whatsnew/ @AA-Turner
# ----------------------------------------------------------------------------
# Internal Tools and Data
# ----------------------------------------------------------------------------
# Argument Clinic
Tools/clinic/ @erlend-aasland @AA-Turner
Lib/test/test_clinic.py @erlend-aasland @AA-Turner
Doc/howto/clinic.rst @erlend-aasland @AA-Turner
# C Analyser
Tools/c-analyzer/ @ericsnowcurrently
# C API Documentation Checks
Tools/check-c-api-docs/ @ZeroIntensity
# Fuzzing
Modules/_xxtestfuzz/ @ammaraskar
# Limited C API & Stable ABI
Doc/c-api/stable.rst @encukou
Doc/data/*.abi @encukou
Misc/stable_abi.toml @encukou
Tools/build/stable_abi.py @encukou
# SBOM
Misc/externals.spdx.json @sethmlarson
Misc/sbom.spdx.json @sethmlarson
Tools/build/generate_sbom.py @sethmlarson
# ----------------------------------------------------------------------------
# Platform Support
# ----------------------------------------------------------------------------
# Android
Android/ @mhsmith @freakboy3742
Doc/using/android.rst @mhsmith @freakboy3742
Lib/_android_support.py @mhsmith @freakboy3742
Lib/test/test_android.py @mhsmith @freakboy3742
# iOS
Doc/using/ios.rst @freakboy3742
Lib/_ios_support.py @freakboy3742
Apple/ @freakboy3742
iOS/ @freakboy3742
# macOS
Mac/ @python/macos-team
Lib/_osx_support.py @python/macos-team
Lib/test/test__osx_support.py @python/macos-team
# WebAssembly
Tools/wasm/README.md @brettcannon @freakboy3742 @emmatyping
# WebAssembly (Emscripten)
Tools/wasm/config.site-wasm32-emscripten @freakboy3742 @emmatyping
Tools/wasm/emscripten @freakboy3742 @emmatyping
# WebAssembly (WASI)
Tools/wasm/wasi-env @brettcannon @emmatyping
Tools/wasm/wasi.py @brettcannon @emmatyping
Tools/wasm/wasi @brettcannon @emmatyping
# Windows
PC/ @python/windows-team
PCbuild/ @python/windows-team
# Windows installer packages
Tools/msi/ @python/windows-team
Tools/nuget/ @python/windows-team
# Windows Launcher
PC/launcher.c @python/windows-team @vsajip
# ----------------------------------------------------------------------------
# Interpreter Core
# ----------------------------------------------------------------------------
# AST
Lib/_ast_unparse.py @isidentical @JelleZijlstra @eclips4 @tomasr8
Lib/ast.py @isidentical @JelleZijlstra @eclips4 @tomasr8
Lib/test/test_ast/ @eclips4 @tomasr8
Parser/asdl.py @isidentical @JelleZijlstra @eclips4 @tomasr8
Parser/asdl_c.py @isidentical @JelleZijlstra @eclips4 @tomasr8
Python/ast.c @isidentical @JelleZijlstra @eclips4 @tomasr8
Python/ast_preprocess.c @isidentical @eclips4 @tomasr8
# Built-in types
Objects/call.c @markshannon
Objects/codeobject.c @markshannon
Objects/dict* @methane @markshannon
Objects/frameobject.c @markshannon
**/*genobject* @markshannon
Objects/object.c @ZeroIntensity
Objects/set* @rhettinger
Objects/type* @markshannon
Objects/typevarobject.c @JelleZijlstra
Objects/unionobject.c @JelleZijlstra
# Byte code interpreter ('the eval loop')
Python/bytecodes.c @markshannon
Python/ceval* @markshannon
Tools/cases_generator/ @markshannon
# Compiler (AST to byte code)
Python/assemble.c @markshannon @iritkatriel
Python/codegen.c @markshannon @iritkatriel
Python/compile.c @markshannon @iritkatriel
Python/flowgraph.c @markshannon @iritkatriel
Python/instruction_sequence.c @iritkatriel
Python/symtable.c @JelleZijlstra @carljm
# Context variables & HAMT
**/contextvars* @1st1
**/*hamt* @1st1
Include/cpython/context.h @1st1
Include/internal/pycore_context.h @1st1
Lib/test/test_context.py @1st1
Python/context.c @1st1
# Core Modules
**/*bltinmodule* @ericsnowcurrently
**/*gil* @ericsnowcurrently
Include/internal/pycore_runtime.h @ericsnowcurrently
Include/internal/pycore_interp.h @ericsnowcurrently
Include/internal/pycore_tstate.h @ericsnowcurrently
Include/internal/pycore_*_state.h @ericsnowcurrently
Include/internal/pycore_*_init.h @ericsnowcurrently
Include/internal/pycore_atexit.h @ericsnowcurrently
Include/internal/pycore_freelist.h @ericsnowcurrently
Include/internal/pycore_global_objects.h @ericsnowcurrently
Include/internal/pycore_obmalloc.h @ericsnowcurrently
Include/internal/pycore_pymem.h @ericsnowcurrently
Include/internal/pycore_stackref.h @Fidget-Spinner
Modules/main.c @ericsnowcurrently
Programs/_bootstrap_python.c @ericsnowcurrently
Programs/python.c @ericsnowcurrently
Tools/build/generate_global_objects.py @ericsnowcurrently
# Initialization
Doc/library/sys_path_init.rst @FFY00
Doc/c-api/init_config.rst @FFY00
# getpath
**/*getpath* @FFY00
# site
**/*site.py @FFY00
Doc/library/site.rst @FFY00
**/*sysmodule* @ericsnowcurrently
# Exceptions
Lib/test/test_except*.py @iritkatriel
Objects/exceptions.c @iritkatriel
# Hashing & cryptographic primitives
**/*hashlib* @gpshead @tiran @picnixz
**/*hashopenssl* @gpshead @tiran @picnixz
**/*pyhash* @gpshead @tiran @picnixz
Modules/*blake* @gpshead @tiran @picnixz
Modules/*md5* @gpshead @tiran @picnixz
Modules/*sha* @gpshead @tiran @picnixz
Modules/_hacl/** @gpshead @picnixz
**/*hmac* @gpshead @picnixz
# Getpath
Lib/test/test_getpath.py @FFY00
Modules/getpath* @FFY00
# libssl
**/*ssl* @gpshead @picnixz
# Hashing / ``hash()`` and related
Include/cpython/pyhash.h @gpshead @picnixz
Include/internal/pycore_pyhash.h @gpshead @picnixz
Include/pyhash.h @gpshead @picnixz
Python/pyhash.c @gpshead @picnixz
# logging
**/*logging* @vsajip
# venv
**/*venv* @vsajip @FFY00
# Launcher
/PC/launcher.c @vsajip
# HTML
/Lib/html/ @ezio-melotti
/Lib/_markupbase.py @ezio-melotti
/Lib/test/test_html*.py @ezio-melotti
/Tools/build/parse_html5_entities.py @ezio-melotti
# Import (including importlib).
# The import system (including importlib)
**/*import* @brettcannon @ericsnowcurrently @ncoghlan @warsaw
/Python/import.c @kumaraditya303
Python/dynload_*.c @ericsnowcurrently
Python/import.c @brettcannon @ericsnowcurrently @ncoghlan @warsaw @kumaraditya303
**/*freeze* @ericsnowcurrently
**/*frozen* @ericsnowcurrently
**/*modsupport* @ericsnowcurrently
@ -147,19 +266,171 @@ Python/dynload_*.c @ericsnowcurrently
**/*pythonrun* @ericsnowcurrently
**/*runpy* @ericsnowcurrently
**/*singlephase* @ericsnowcurrently
Lib/test/test_module/ @ericsnowcurrently
Doc/c-api/module.rst @ericsnowcurrently
**/*importlib/resources/* @jaraco @warsaw @FFY00
**/*importlib/metadata/* @jaraco @warsaw
Lib/test/test_module/ @ericsnowcurrently
Python/dynload_*.c @ericsnowcurrently
# Initialisation
**/*initconfig* @ericsnowcurrently
**/*pathconfig* @ericsnowcurrently
**/*preconfig* @ericsnowcurrently
Doc/library/sys_path_init.rst @FFY00
Doc/c-api/init_config.rst @FFY00
# Interpreter main program
Modules/main.c @ericsnowcurrently
Programs/_bootstrap_python.c @ericsnowcurrently
Programs/python.c @ericsnowcurrently
# JIT
Include/internal/pycore_jit.h @brandtbucher @savannahostrowski @diegorusso
Python/jit.c @brandtbucher @savannahostrowski @diegorusso
Tools/jit/ @brandtbucher @savannahostrowski @diegorusso
InternalDocs/jit.md @brandtbucher @savannahostrowski @diegorusso @AA-Turner
# Micro-op / μop / Tier 2 Optimiser
Python/optimizer.c @markshannon
Python/optimizer_analysis.c @markshannon @tomasr8 @Fidget-Spinner
Python/optimizer_bytecodes.c @markshannon @tomasr8 @Fidget-Spinner
Python/optimizer_symbols.c @markshannon @tomasr8
# Parser, Lexer, and Grammar
Grammar/python.gram @pablogsal @lysnikolaou
Lib/test/test_peg_generator/ @pablogsal @lysnikolaou
Lib/test/test_tokenize.py @pablogsal @lysnikolaou
Lib/tokenize.py @pablogsal @lysnikolaou
Parser/ @pablogsal @lysnikolaou
Tools/peg_generator/ @pablogsal @lysnikolaou
# Runtime state/lifecycle
**/*gil* @ericsnowcurrently
**/*pylifecycle* @ericsnowcurrently @ZeroIntensity
**/*pystate* @ericsnowcurrently @ZeroIntensity
Include/internal/pycore_*_init.h @ericsnowcurrently
Include/internal/pycore_*_state.h @ericsnowcurrently
Include/internal/pycore_atexit.h @ericsnowcurrently
Include/internal/pycore_freelist.h @ericsnowcurrently
Include/internal/pycore_global_objects.h @ericsnowcurrently
Include/internal/pycore_interp.h @ericsnowcurrently
Include/internal/pycore_obmalloc.h @ericsnowcurrently
Include/internal/pycore_pymem.h @ericsnowcurrently
Include/internal/pycore_runtime.h @ericsnowcurrently
Include/internal/pycore_stackref.h @Fidget-Spinner
Include/internal/pycore_tstate.h @ericsnowcurrently
Tools/build/generate_global_objects.py @ericsnowcurrently
# Remote Debugging
Python/remote_debug.h @pablogsal
Python/remote_debugging.c @pablogsal
Modules/_remote_debugging_module.c @pablogsal @ambv @1st1
# Sub-Interpreters
**/*crossinterp* @ericsnowcurrently
**/*interpreteridobject.* @ericsnowcurrently
Doc/library/concurrent.interpreters.rst @ericsnowcurrently
Lib/concurrent/futures/interpreter.py @ericsnowcurrently
Lib/concurrent/interpreters/ @ericsnowcurrently
Lib/test/support/channels.py @ericsnowcurrently
Lib/test/test__interp*.py @ericsnowcurrently
Lib/test/test_interpreters/ @ericsnowcurrently
Modules/_interp*module.c @ericsnowcurrently
# Template string literals (t-strings)
Lib/test/test_tstring.py @lysnikolaou
Objects/interpolationobject.c @lysnikolaou
Objects/templateobject.c @lysnikolaou
# Tests
Lib/test/test_patma.py @brandtbucher
Lib/test/test_type_*.py @JelleZijlstra
Lib/test/test_capi/test_misc.py @markshannon
# ----------------------------------------------------------------------------
# Standard Library
# ----------------------------------------------------------------------------
# Annotationlib
Doc/library/annotationlib.rst @JelleZijlstra
Lib/annotationlib.py @JelleZijlstra
Lib/test/test_annotationlib.py @JelleZijlstra
# Argparse
Doc/**/argparse*.rst @savannahostrowski
Lib/argparse.py @savannahostrowski
Lib/test/test_argparse.py @savannahostrowski
# Asyncio
Doc/library/asyncio*.rst @1st1 @asvetlov @kumaraditya303 @willingc
InternalDocs/asyncio.md @1st1 @asvetlov @kumaraditya303 @willingc @AA-Turner
Lib/asyncio/ @1st1 @asvetlov @kumaraditya303 @willingc
Lib/test/test_asyncio/ @1st1 @asvetlov @kumaraditya303 @willingc
Modules/_asynciomodule.c @1st1 @asvetlov @kumaraditya303 @willingc
# Bisect
Doc/library/bisect.rst @rhettinger
Lib/bisect.py @rhettinger
Lib/test/test_bisect.py @rhettinger
Modules/_bisectmodule.c @rhettinger
# Calendar
Lib/calendar.py @AA-Turner
Lib/test/test_calendar.py @AA-Turner
# Cryptographic Primitives and Applications
**/*hashlib* @gpshead @picnixz
**/*hashopenssl* @gpshead @picnixz
**/*hmac* @gpshead @picnixz
**/*ssl* @gpshead @picnixz
Modules/_hacl/ @gpshead @picnixz
Modules/*blake* @gpshead @picnixz
Modules/*md5* @gpshead @picnixz
Modules/*sha* @gpshead @picnixz
# Codecs
Modules/cjkcodecs/ @corona10
Tools/unicode/gencjkcodecs.py @corona10
# Collections
Doc/library/collections.abc.rst @rhettinger
Doc/library/collections.rst @rhettinger
Lib/_collections_abc.py @rhettinger
Lib/collections/ @rhettinger
Lib/test/test_collections.py @rhettinger
Modules/_collectionsmodule.c @rhettinger
# Colorize
Lib/_colorize.py @hugovk
Lib/test/test__colorize.py @hugovk
# Config Parser
Lib/configparser.py @jaraco
Lib/test/test_configparser.py @jaraco
# Dataclasses
Doc/library/dataclasses.rst @ericvsmith
Lib/dataclasses.py @ericvsmith
Lib/test/test_dataclasses/ @ericvsmith
# Dates and times
**/*datetime* @pganssle @abalkin
**/*str*time* @pganssle @abalkin
Doc/library/time.rst @pganssle @abalkin
Lib/test/test_time.py @pganssle @abalkin
Modules/timemodule.c @pganssle @abalkin
Python/pytime.c @pganssle @abalkin
Include/internal/pycore_time.h @pganssle @abalkin
Doc/**/*time.rst @pganssle @abalkin
Doc/library/zoneinfo.rst @pganssle
Include/datetime.h @pganssle @abalkin
Include/internal/pycore_time.h @pganssle @abalkin
Lib/test/test_zoneinfo/ @pganssle
Lib/zoneinfo/ @pganssle
Lib/*time.py @pganssle @abalkin
Lib/test/datetimetester.py @pganssle @abalkin
Lib/test/test_*time.py @pganssle @abalkin
Modules/*zoneinfo* @pganssle
Modules/*time* @pganssle @abalkin
Python/pytime.c @pganssle @abalkin
# Dbm
Doc/library/dbm.rst @corona10 @erlend-aasland @serhiy-storchaka
Lib/dbm/ @corona10 @erlend-aasland @serhiy-storchaka
Lib/test/test_dbm*.py @corona10 @erlend-aasland @serhiy-storchaka
Modules/*dbm* @corona10 @erlend-aasland @serhiy-storchaka
# Email and related
**/*mail* @python/email-team
@ -168,161 +439,197 @@ Include/internal/pycore_time.h @pganssle @abalkin
**/*imap* @python/email-team
**/*poplib* @python/email-team
# Exclude .mailmap from being owned by @python/email-team
/.mailmap
# Ensurepip
Doc/library/ensurepip.rst @pfmoore @pradyunsg
Lib/ensurepip/ @pfmoore @pradyunsg
Lib/test/test_ensurepip.py @pfmoore @pradyunsg
# Enum
Doc/howto/enum.rst @ethanfurman
Doc/library/enum.rst @ethanfurman
Lib/enum.py @ethanfurman
Lib/test/test_enum.py @ethanfurman
Lib/test/test_json/test_enum.py @ethanfurman
# FTP
Doc/library/ftplib.rst @giampaolo
Lib/ftplib.py @giampaolo
Lib/test/test_ftplib.py @giampaolo
# Functools
Doc/library/functools.rst @rhettinger
Lib/functools.py @rhettinger
Lib/test/test_functools.py @rhettinger
Modules/_functoolsmodule.c @rhettinger
# Garbage collector
/Modules/gcmodule.c @pablogsal
/Doc/library/gc.rst @pablogsal
Modules/gcmodule.c @pablogsal
Doc/library/gc.rst @pablogsal
# Parser
/Parser/ @pablogsal @lysnikolaou
/Tools/peg_generator/ @pablogsal @lysnikolaou
/Lib/test/test_peg_generator/ @pablogsal @lysnikolaou
/Grammar/python.gram @pablogsal @lysnikolaou
/Lib/tokenize.py @pablogsal @lysnikolaou
/Lib/test/test_tokenize.py @pablogsal @lysnikolaou
# Gettext
Doc/library/gettext.rst @tomasr8
Lib/gettext.py @tomasr8
Lib/test/test_gettext.py @tomasr8
Tools/i18n/pygettext.py @tomasr8
# Code generator
/Tools/cases_generator/ @markshannon
# Heapq
Doc/library/heapq* @rhettinger
Lib/heapq.py @rhettinger
Lib/test/test_heapq.py @rhettinger
Modules/_heapqmodule.c @rhettinger
# AST
Python/ast.c @isidentical @JelleZijlstra @eclips4
Python/ast_preprocess.c @isidentical @eclips4
Parser/asdl.py @isidentical @JelleZijlstra @eclips4
Parser/asdl_c.py @isidentical @JelleZijlstra @eclips4
Lib/ast.py @isidentical @JelleZijlstra @eclips4
Lib/_ast_unparse.py @isidentical @JelleZijlstra @eclips4
Lib/test/test_ast/ @eclips4
# HTML
Doc/library/html* @ezio-melotti
Lib/html/ @ezio-melotti
Lib/_markupbase.py @ezio-melotti
Lib/test/test_html*.py @ezio-melotti
Tools/build/parse_html5_entities.py @ezio-melotti
# Mock
/Lib/unittest/mock.py @cjw296
/Lib/test/test_unittest/testmock/* @cjw296
# IDLE
Doc/library/idle.rst @terryjreedy
Lib/idlelib/ @terryjreedy
Lib/turtledemo/ @terryjreedy
# multiprocessing
**/*multiprocessing* @gpshead
# importlib.metadata
Doc/library/importlib.metadata.rst @jaraco @warsaw
Lib/importlib/metadata/ @jaraco @warsaw
Lib/test/test_importlib/metadata/ @jaraco @warsaw
# importlib.resources
Doc/library/importlib.resources.abc.rst @jaraco @warsaw
Doc/library/importlib.resources.rst @jaraco @warsaw
Lib/importlib/resources/ @jaraco @warsaw @FFY00
Lib/test/test_importlib/resources/ @jaraco @warsaw @FFY00
# Itertools
Doc/library/itertools.rst @rhettinger
Lib/test/test_itertools.py @rhettinger
Modules/itertoolsmodule.c @rhettinger
# Logging
Doc/**/logging* @vsajip
Lib/logging/ @vsajip
Lib/test/test_logging.py @vsajip
# Multiprocessing
Doc/library/multiprocessing*.rst @gpshead
Lib/multiprocessing/ @gpshead
Lib/test/*multiprocessing.py @gpshead
Lib/test/test_multiprocessing*/ @gpshead
Modules/_multiprocessing/ @gpshead
# Pathlib
Doc/library/pathlib.rst @barneygale
Lib/pathlib/ @barneygale
Lib/test/test_pathlib/ @barneygale
# Pdb & Bdb
Doc/library/bdb.rst @gaogaotiantian
Doc/library/pdb.rst @gaogaotiantian
Lib/bdb.py @gaogaotiantian
Lib/pdb.py @gaogaotiantian
Lib/test/test_bdb.py @gaogaotiantian
Lib/test/test_pdb.py @gaogaotiantian
Lib/test/test_remote_pdb.py @gaogaotiantian
# Pydoc
Lib/pydoc.py @AA-Turner
Lib/pydoc_data/ @AA-Turner
Lib/test/test_pydoc/ @AA-Turner
# PyREPL
Lib/_pyrepl/ @pablogsal @lysnikolaou @ambv
Lib/test/test_pyrepl/ @pablogsal @lysnikolaou @ambv
# Random
Doc/library/random.rst @rhettinger
Lib/random.py @rhettinger
Lib/test/test_random.py @rhettinger
Modules/_randommodule.c @rhettinger
# Shutil
Doc/library/shutil.rst @giampaolo
Lib/shutil.py @giampaolo
Lib/test/test_shutil.py @giampaolo
# Site
Lib/site.py @FFY00
Lib/test/test_site.py @FFY00
Doc/library/site.rst @FFY00
# string.templatelib
Doc/library/string.templatelib.rst @lysnikolaou @AA-Turner
Lib/string/templatelib.py @lysnikolaou @AA-Turner
Lib/test/test_string/test_templatelib.py @lysnikolaou @AA-Turner
# Sysconfig
**/*sysconfig* @FFY00
# SQLite 3
**/*sqlite* @berkerpeksag @erlend-aasland
Doc/library/sqlite3.rst @berkerpeksag @erlend-aasland
Lib/sqlite3/ @berkerpeksag @erlend-aasland
Lib/test/test_sqlite3/ @berkerpeksag @erlend-aasland
Modules/_sqlite/ @berkerpeksag @erlend-aasland
# subprocess
/Lib/subprocess.py @gpshead
/Lib/test/test_subprocess.py @gpshead
/Modules/*subprocess* @gpshead
# Subprocess
Lib/subprocess.py @gpshead
Lib/test/test_subprocess.py @gpshead
Modules/*subprocess* @gpshead
# debugger
**/*pdb* @gaogaotiantian
**/*bdb* @gaogaotiantian
# Tarfile
Doc/library/tarfile.rst @ethanfurman
Lib/tarfile.py @ethanfurman
Lib/test/test_tarfile.py @ethanfurman
# Limited C API & stable ABI
Tools/build/stable_abi.py @encukou
Misc/stable_abi.toml @encukou
Doc/data/*.abi @encukou
Doc/c-api/stable.rst @encukou
# TOML
Doc/library/tomllib.rst @encukou @hauntsaninja
Lib/test/test_tomllib/ @encukou @hauntsaninja
Lib/tomllib/ @encukou @hauntsaninja
# Windows
/PC/ @python/windows-team
/PCbuild/ @python/windows-team
# Typing
Doc/library/typing.rst @JelleZijlstra @AlexWaygood
Lib/test/test_typing.py @JelleZijlstra @AlexWaygood
Lib/test/typinganndata/ @JelleZijlstra @AlexWaygood
Lib/typing.py @JelleZijlstra @AlexWaygood
Modules/_typingmodule.c @JelleZijlstra @AlexWaygood
# Types
Lib/test/test_types.py @AA-Turner
Lib/types.py @AA-Turner
Modules/_typesmodule.c @AA-Turner
# Unittest
Lib/unittest/mock.py @cjw296
Lib/test/test_unittest/testmock/ @cjw296
# Urllib
**/*robotparser* @berkerpeksag
# Windows installer packages
/Tools/msi/ @python/windows-team
/Tools/nuget/ @python/windows-team
# Misc
**/*itertools* @rhettinger
**/*collections* @rhettinger
**/*random* @rhettinger
**/*bisect* @rhettinger
**/*heapq* @rhettinger
**/*functools* @rhettinger
**/*dataclasses* @ericvsmith
**/*ensurepip* @pfmoore @pradyunsg
/Doc/library/idle.rst @terryjreedy
**/*idlelib* @terryjreedy
**/*turtledemo* @terryjreedy
**/*annotationlib* @JelleZijlstra
**/*typing* @JelleZijlstra @AlexWaygood
**/*ftplib @giampaolo
**/*shutil @giampaolo
**/*enum* @ethanfurman
**/*cgi* @ethanfurman
**/*tarfile* @ethanfurman
**/*tomllib* @encukou @hauntsaninja
**/*sysconfig* @FFY00
**/*cjkcodecs* @corona10
# macOS
/Mac/ @python/macos-team
**/*osx_support* @python/macos-team
# pathlib
**/*pathlib* @barneygale
# zipfile.Path
**/*zipfile/_path/* @jaraco
# Argument Clinic
/Tools/clinic/** @erlend-aasland
/Lib/test/test_clinic.py @erlend-aasland
Doc/howto/clinic.rst @erlend-aasland
# Subinterpreters
**/*interpreteridobject.* @ericsnowcurrently
**/*crossinterp* @ericsnowcurrently
Lib/test/support/interpreters/ @ericsnowcurrently
Modules/_interp*module.c @ericsnowcurrently
Lib/test/test_interpreters/ @ericsnowcurrently
# Android
**/*Android* @mhsmith @freakboy3742
**/*android* @mhsmith @freakboy3742
# iOS (but not termios)
**/iOS* @freakboy3742
**/ios* @freakboy3742
**/*_iOS* @freakboy3742
**/*_ios* @freakboy3742
**/*-iOS* @freakboy3742
**/*-ios* @freakboy3742
# WebAssembly
/Tools/wasm/ @brettcannon @freakboy3742
# SBOM
/Misc/externals.spdx.json @sethmlarson
/Misc/sbom.spdx.json @sethmlarson
/Tools/build/generate_sbom.py @sethmlarson
# Config Parser
Lib/configparser.py @jaraco
Lib/test/test_configparser.py @jaraco
# Doc sections
Doc/reference/ @willingc @AA-Turner
# Venv
**/*venv* @vsajip @FFY00
# Weakref
**/*weakref* @kumaraditya303
# Colorize
Lib/_colorize.py @hugovk
Lib/test/test__colorize.py @hugovk
# Zipfile.Path
Lib/test/test_zipfile/_path/ @jaraco
Lib/zipfile/_path/ @jaraco
# Fuzzing
Modules/_xxtestfuzz/ @ammaraskar
# Zstandard
Lib/compression/zstd/ @AA-Turner @emmatyping
Lib/test/test_zstd.py @AA-Turner @emmatyping
Modules/_zstd/ @AA-Turner @emmatyping
# t-strings
**/*interpolationobject* @lysnikolaou
**/*templateobject* @lysnikolaou
**/*templatelib* @lysnikolaou
**/*tstring* @lysnikolaou
# ----------------------------------------------------------------------------
# Exclusions from .github/CODEOWNERS should go at the very end
# because the final matching pattern will take precedence.
# Exclude .mailmap from being owned by @python/email-team
.mailmap
# Exclude Argument Clinic directories
Modules/**/clinic/
Objects/**/clinic/
PC/**/clinic/
Python/**/clinic/

View file

@ -4,7 +4,7 @@ Contributing to Python
Build Status
------------
- `Buildbot status overview <https://buildbot.python.org/all/#/release_status>`_
- `Buildbot status overview <https://buildbot.python.org/#/release_status>`_
- `GitHub Actions status <https://github.com/python/cpython/actions/workflows/build.yml>`_
@ -28,23 +28,23 @@ Please be aware that our workflow does deviate slightly from the typical GitHub
project. Details on how to properly submit a pull request are covered in
`Lifecycle of a Pull Request <https://devguide.python.org/getting-started/pull-request-lifecycle.html>`_.
We utilize various bots and status checks to help with this, so do follow the
comments they leave and their "Details" links, respectively. The key points of
our workflow that are not covered by a bot or status check are:
comments they leave and their "Details" links, respectively.
- All discussions that are not directly related to the code in the pull request
should happen on `GitHub Issues <https://github.com/python/cpython/issues>`_.
- Upon your first non-trivial pull request (which includes documentation changes),
feel free to add yourself to ``Misc/ACKS``
The final key part of our workflow is that all discussions that are not
directly related to the code in the pull request should happen on
`GitHub Issues <https://github.com/python/cpython/issues>`__, generally in the
pull request's parent issue.
Setting Expectations
--------------------
Due to the fact that this project is entirely volunteer-run (i.e. no one is paid
to work on Python full-time), we unfortunately can make no guarantees as to if
Due to the fact that this project is run by volunteers,
unfortunately we cannot make any guarantees as to if
or when a core developer will get around to reviewing your pull request.
If no core developer has done a review or responded to changes made because of a
"changes requested" review, please feel free to email python-dev to ask if
someone could take a look at your pull request.
"changes requested" review within a month, you can ask for someone to
review your pull request via a post in the `Core Development Discourse
category <https://discuss.python.org/c/core-dev/23>`__.
Code of Conduct

View file

@ -40,6 +40,7 @@ body:
- "3.12"
- "3.13"
- "3.14"
- "3.15"
- "CPython main branch"
validations:
required: true

View file

@ -5,3 +5,6 @@ contact_links:
- name: "Proposing new features"
about: "Submit major feature proposal (e.g. syntax changes) to an ideas forum first."
url: "https://discuss.python.org/c/ideas/6"
- name: "Python Install Manager issues"
about: "Report issues with the Python Install Manager (for Windows)"
url: "https://github.com/python/pymanager/issues"

View file

@ -33,6 +33,7 @@ body:
- "3.12"
- "3.13"
- "3.14"
- "3.15"
- "CPython main branch"
validations:
required: true

View file

@ -1,6 +1,7 @@
self-hosted-runner:
# Pending https://github.com/rhysd/actionlint/issues/533
labels: ["windows-11-arm"]
# and https://github.com/rhysd/actionlint/issues/571
labels: ["windows-11-arm", "macos-15-intel"]
config-variables: null

View file

@ -12,6 +12,11 @@ updates:
update-types:
- "version-update:semver-minor"
- "version-update:semver-patch"
cooldown:
# https://blog.yossarian.net/2025/11/21/We-should-all-be-using-dependency-cooldowns
# Cooldowns protect against supply chain attacks by avoiding the
# highest-risk window immediately after new releases.
default-days: 14
- package-ecosystem: "pip"
directory: "/Tools/"
schedule:
@ -19,3 +24,5 @@ updates:
labels:
- "skip issue"
- "skip news"
cooldown:
default-days: 14

View file

@ -15,7 +15,13 @@ permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}-reusable
# https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#concurrency
# 'group' must be a key uniquely representing a PR or push event.
# github.workflow is the workflow name
# github.actor is the user invoking the workflow
# github.head_ref is the source branch of the PR or otherwise blank
# github.run_id is a unique number for the current run
group: ${{ github.workflow }}-${{ github.actor }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
env:
@ -103,20 +109,10 @@ jobs:
python-version: '3.x'
- name: Runner image version
run: echo "IMAGE_OS_VERSION=${ImageOS}-${ImageVersion}" >> "$GITHUB_ENV"
- name: Restore config.cache
uses: actions/cache@v4
with:
path: config.cache
# Include env.pythonLocation in key to avoid changes in environment when setup-python updates Python
key: ${{ github.job }}-${{ env.IMAGE_OS_VERSION }}-${{ needs.build-context.outputs.config-hash }}-${{ env.pythonLocation }}
- name: Install dependencies
run: sudo ./.github/workflows/posix-deps-apt.sh
- name: Add ccache to PATH
run: echo "PATH=/usr/lib/ccache:$PATH" >> "$GITHUB_ENV"
- name: Configure ccache action
uses: hendrikmuhs/ccache-action@v1.2
with:
save: false
- name: Configure CPython
run: |
# Build Python with the libpython dynamic library
@ -124,7 +120,7 @@ jobs:
- name: Build CPython
run: |
make -j4 regen-all
make regen-stdlib-module-names regen-sbom regen-unicodedata
make regen-stdlib-module-names regen-sbom
- name: Check for changes
run: |
git add -u
@ -146,6 +142,9 @@ jobs:
- name: Check for unsupported C global variables
if: github.event_name == 'pull_request' # $GITHUB_EVENT_NAME
run: make check-c-globals
- name: Check for undocumented C APIs
run: make check-c-api-docs
build-windows:
name: >-
@ -172,8 +171,8 @@ jobs:
free-threading: ${{ matrix.free-threading }}
build-windows-msi:
name: >- # ${{ '' } is a hack to nest jobs under the same sidebar category
Windows MSI${{ '' }}
# ${{ '' } is a hack to nest jobs under the same sidebar category.
name: Windows MSI${{ '' }} # zizmor: ignore[obfuscation]
needs: build-context
if: fromJSON(needs.build-context.outputs.run-windows-msi)
strategy:
@ -196,28 +195,19 @@ jobs:
strategy:
fail-fast: false
matrix:
# Cirrus and macos-14 are M1, macos-13 is default GHA Intel.
# macOS 13 only runs tests against the GIL-enabled CPython.
# Cirrus used for upstream, macos-14 for forks.
# macos-14 is M1, macos-15-intel is Intel.
# macos-15-intel only runs tests against the GIL-enabled CPython.
os:
- ghcr.io/cirruslabs/macos-runner:sonoma
- macos-14
- macos-13
is-fork: # only used for the exclusion trick
- ${{ github.repository_owner != 'python' }}
- macos-15-intel
free-threading:
- false
- true
exclude:
- os: ghcr.io/cirruslabs/macos-runner:sonoma
is-fork: true
- os: macos-14
is-fork: false
- os: macos-13
- os: macos-15-intel
free-threading: true
uses: ./.github/workflows/reusable-macos.yml
with:
config_hash: ${{ needs.build-context.outputs.config-hash }}
free-threading: ${{ matrix.free-threading }}
os: ${{ matrix.os }}
@ -249,12 +239,11 @@ jobs:
bolt: true
uses: ./.github/workflows/reusable-ubuntu.yml
with:
config_hash: ${{ needs.build-context.outputs.config-hash }}
bolt-optimizations: ${{ matrix.bolt }}
free-threading: ${{ matrix.free-threading }}
os: ${{ matrix.os }}
build-ubuntu-ssltests:
build-ubuntu-ssltests-openssl:
name: 'Ubuntu SSL tests with OpenSSL'
runs-on: ${{ matrix.os }}
timeout-minutes: 60
@ -264,7 +253,10 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-24.04]
openssl_ver: [3.0.16, 3.1.8, 3.2.4, 3.3.3, 3.4.1]
# Keep 1.1.1w in our list despite it being upstream EOL and otherwise
# unsupported as it most resembles other 1.1.1-work-a-like ssl APIs
# supported by important vendors such as AWS-LC.
openssl_ver: [1.1.1w, 3.0.18, 3.2.6, 3.3.5, 3.4.3, 3.5.4]
# See Tools/ssl/make_ssl_data.py for notes on adding a new version
env:
OPENSSL_VER: ${{ matrix.openssl_ver }}
@ -277,11 +269,6 @@ jobs:
persist-credentials: false
- name: Runner image version
run: echo "IMAGE_OS_VERSION=${ImageOS}-${ImageVersion}" >> "$GITHUB_ENV"
- name: Restore config.cache
uses: actions/cache@v4
with:
path: config.cache
key: ${{ github.job }}-${{ env.IMAGE_OS_VERSION }}-${{ needs.build-context.outputs.config-hash }}
- name: Register gcc problem matcher
run: echo "::add-matcher::.github/problem-matchers/gcc.json"
- name: Install dependencies
@ -303,10 +290,6 @@ jobs:
- name: Add ccache to PATH
run: |
echo "PATH=/usr/lib/ccache:$PATH" >> "$GITHUB_ENV"
- name: Configure ccache action
uses: hendrikmuhs/ccache-action@v1.2
with:
save: false
- name: Configure CPython
run: ./configure CFLAGS="-fdiagnostics-format=json" --config-cache --enable-slower-safety --with-pydebug --with-openssl="$OPENSSL_DIR"
- name: Build CPython
@ -316,13 +299,122 @@ jobs:
- name: SSL tests
run: ./python Lib/test/ssltests.py
build-ubuntu-ssltests-awslc:
name: 'Ubuntu SSL tests with AWS-LC'
runs-on: ${{ matrix.os }}
timeout-minutes: 60
needs: build-context
if: needs.build-context.outputs.run-tests == 'true'
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04]
awslc_ver: [1.55.0]
env:
AWSLC_VER: ${{ matrix.awslc_ver}}
MULTISSL_DIR: ${{ github.workspace }}/multissl
OPENSSL_DIR: ${{ github.workspace }}/multissl/aws-lc/${{ matrix.awslc_ver }}
LD_LIBRARY_PATH: ${{ github.workspace }}/multissl/aws-lc/${{ matrix.awslc_ver }}/lib
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Runner image version
run: echo "IMAGE_OS_VERSION=${ImageOS}-${ImageVersion}" >> "$GITHUB_ENV"
- name: Register gcc problem matcher
run: echo "::add-matcher::.github/problem-matchers/gcc.json"
- name: Install dependencies
run: sudo ./.github/workflows/posix-deps-apt.sh
- name: Configure SSL lib env vars
run: |
echo "MULTISSL_DIR=${GITHUB_WORKSPACE}/multissl" >> "$GITHUB_ENV"
echo "OPENSSL_DIR=${GITHUB_WORKSPACE}/multissl/aws-lc/${AWSLC_VER}" >> "$GITHUB_ENV"
echo "LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/multissl/aws-lc/${AWSLC_VER}/lib" >> "$GITHUB_ENV"
- name: 'Restore AWS-LC build'
id: cache-aws-lc
uses: actions/cache@v4
with:
path: ./multissl/aws-lc/${{ matrix.awslc_ver }}
key: ${{ matrix.os }}-multissl-aws-lc-${{ matrix.awslc_ver }}
- name: Install AWS-LC
if: steps.cache-aws-lc.outputs.cache-hit != 'true'
run: |
python3 Tools/ssl/multissltests.py \
--steps=library \
--base-directory "$MULTISSL_DIR" \
--awslc ${{ matrix.awslc_ver }} \
--system Linux
- name: Add ccache to PATH
run: |
echo "PATH=/usr/lib/ccache:$PATH" >> "$GITHUB_ENV"
- name: Configure CPython
run: |
./configure CFLAGS="-fdiagnostics-format=json" \
--config-cache \
--enable-slower-safety \
--with-pydebug \
--with-openssl="$OPENSSL_DIR" \
--with-builtin-hashlib-hashes=blake2 \
--with-ssl-default-suites=openssl
- name: Build CPython
run: make -j
- name: Display build info
run: make pythoninfo
- name: Verify python is linked to AWS-LC
run: ./python -c 'import ssl; print(ssl.OPENSSL_VERSION)' | grep AWS-LC
- name: SSL tests
run: ./python Lib/test/ssltests.py
build-android:
name: Android (${{ matrix.arch }})
needs: build-context
if: needs.build-context.outputs.run-tests == 'true'
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
include:
- arch: aarch64
runs-on: macos-14
- arch: x86_64
runs-on: ubuntu-24.04
runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Build and test
run: ./Android/android.py ci --fast-ci ${{ matrix.arch }}-linux-android
build-ios:
name: iOS
needs: build-context
if: needs.build-context.outputs.run-tests == 'true'
timeout-minutes: 60
runs-on: macos-15
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
# GitHub recommends explicitly selecting the desired Xcode version:
# https://github.com/actions/runner-images/issues/12541#issuecomment-3083850140
# This became a necessity as a result of
# https://github.com/actions/runner-images/issues/12541 and
# https://github.com/actions/runner-images/issues/12751.
- name: Select Xcode version
run: |
sudo xcode-select --switch /Applications/Xcode_16.4.app
- name: Build and test
run: python3 Apple ci iOS --fast-ci --simulator 'iPhone 16e,OS=18.5'
build-wasi:
name: 'WASI'
needs: build-context
if: needs.build-context.outputs.run-tests == 'true'
uses: ./.github/workflows/reusable-wasi.yml
with:
config_hash: ${{ needs.build-context.outputs.config-hash }}
test-hypothesis:
name: "Hypothesis tests on Ubuntu"
@ -331,7 +423,7 @@ jobs:
needs: build-context
if: needs.build-context.outputs.run-tests == 'true'
env:
OPENSSL_VER: 3.0.16
OPENSSL_VER: 3.0.18
PYTHONSTRICTEXTENSIONBUILD: 1
steps:
- uses: actions/checkout@v4
@ -358,10 +450,6 @@ jobs:
- name: Add ccache to PATH
run: |
echo "PATH=/usr/lib/ccache:$PATH" >> "$GITHUB_ENV"
- name: Configure ccache action
uses: hendrikmuhs/ccache-action@v1.2
with:
save: false
- name: Setup directory envs for out-of-tree builds
run: |
echo "CPYTHON_RO_SRCDIR=$(realpath -m "${GITHUB_WORKSPACE}"/../cpython-ro-srcdir)" >> "$GITHUB_ENV"
@ -372,11 +460,6 @@ jobs:
run: sudo mount --bind -o ro "$GITHUB_WORKSPACE" "$CPYTHON_RO_SRCDIR"
- name: Runner image version
run: echo "IMAGE_OS_VERSION=${ImageOS}-${ImageVersion}" >> "$GITHUB_ENV"
- name: Restore config.cache
uses: actions/cache@v4
with:
path: ${{ env.CPYTHON_BUILDDIR }}/config.cache
key: ${{ github.job }}-${{ env.IMAGE_OS_VERSION }}-${{ needs.build-context.outputs.config-hash }}
- name: Configure CPython out-of-tree
working-directory: ${{ env.CPYTHON_BUILDDIR }}
run: |
@ -451,7 +534,7 @@ jobs:
matrix:
os: [ubuntu-24.04]
env:
OPENSSL_VER: 3.0.16
OPENSSL_VER: 3.0.18
PYTHONSTRICTEXTENSIONBUILD: 1
ASAN_OPTIONS: detect_leaks=0:allocator_may_return_null=1:handle_segv=0
steps:
@ -460,11 +543,6 @@ jobs:
persist-credentials: false
- name: Runner image version
run: echo "IMAGE_OS_VERSION=${ImageOS}-${ImageVersion}" >> "$GITHUB_ENV"
- name: Restore config.cache
uses: actions/cache@v4
with:
path: config.cache
key: ${{ github.job }}-${{ env.IMAGE_OS_VERSION }}-${{ needs.build-context.outputs.config-hash }}
- name: Register gcc problem matcher
run: echo "::add-matcher::.github/problem-matchers/gcc.json"
- name: Install dependencies
@ -490,11 +568,6 @@ jobs:
- name: Add ccache to PATH
run: |
echo "PATH=/usr/lib/ccache:$PATH" >> "$GITHUB_ENV"
- name: Configure ccache action
uses: hendrikmuhs/ccache-action@v1.2
with:
save: ${{ github.event_name == 'push' }}
max-size: "200M"
- name: Configure CPython
run: ./configure --config-cache --with-address-sanitizer --without-pymalloc
- name: Build CPython
@ -504,21 +577,28 @@ jobs:
- name: Tests
run: xvfb-run make ci
build-tsan:
name: >-
Thread sanitizer
${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }}
build-san:
# ${{ '' } is a hack to nest jobs under the same sidebar category.
name: Sanitizers${{ '' }} # zizmor: ignore[obfuscation]
needs: build-context
if: needs.build-context.outputs.run-tests == 'true'
strategy:
fail-fast: false
matrix:
check-name:
- Thread
free-threading:
- false
- true
uses: ./.github/workflows/reusable-tsan.yml
sanitizer:
- TSan
include:
- check-name: Undefined behavior
sanitizer: UBSan
free-threading: false
uses: ./.github/workflows/reusable-san.yml
with:
config_hash: ${{ needs.build-context.outputs.config-hash }}
sanitizer: ${{ matrix.sanitizer }}
free-threading: ${{ matrix.free-threading }}
cross-build-linux:
@ -533,11 +613,6 @@ jobs:
persist-credentials: false
- name: Runner image version
run: echo "IMAGE_OS_VERSION=${ImageOS}-${ImageVersion}" >> "$GITHUB_ENV"
- name: Restore config.cache
uses: actions/cache@v4
with:
path: config.cache
key: ${{ github.job }}-${{ env.IMAGE_OS_VERSION }}-${{ needs.build-context.outputs.config-hash }}
- name: Register gcc problem matcher
run: echo "::add-matcher::.github/problem-matchers/gcc.json"
- name: Set build dir
@ -614,11 +689,14 @@ jobs:
- build-windows-msi
- build-macos
- build-ubuntu
- build-ubuntu-ssltests
- build-ubuntu-ssltests-awslc
- build-ubuntu-ssltests-openssl
- build-android
- build-ios
- build-wasi
- test-hypothesis
- build-asan
- build-tsan
- build-san
- cross-build-linux
- cifuzz
if: always()
@ -629,7 +707,8 @@ jobs:
with:
allowed-failures: >-
build-windows-msi,
build-ubuntu-ssltests,
build-ubuntu-ssltests-awslc,
build-ubuntu-ssltests-openssl,
test-hypothesis,
cifuzz,
allowed-skips: >-
@ -647,11 +726,14 @@ jobs:
check-generated-files,
build-macos,
build-ubuntu,
build-ubuntu-ssltests,
build-ubuntu-ssltests-awslc,
build-ubuntu-ssltests-openssl,
build-android,
build-ios,
build-wasi,
test-hypothesis,
build-asan,
build-tsan,
build-san,
cross-build-linux,
'
|| ''

View file

@ -5,6 +5,8 @@ on:
- '**jit**'
- 'Python/bytecodes.c'
- 'Python/optimizer*.c'
- 'Python/executor_cases.c.h'
- 'Python/optimizer_cases.c.h'
- '!Python/perf_jit_trampoline.c'
- '!**/*.md'
- '!**/*.ini'
@ -13,6 +15,8 @@ on:
- '**jit**'
- 'Python/bytecodes.c'
- 'Python/optimizer*.c'
- 'Python/executor_cases.c.h'
- 'Python/optimizer_cases.c.h'
- '!Python/perf_jit_trampoline.c'
- '!**/*.md'
- '!**/*.ini'
@ -64,20 +68,20 @@ jobs:
- true
- false
llvm:
- 19
- 21
include:
- target: i686-pc-windows-msvc/msvc
architecture: Win32
runner: windows-latest
runner: windows-2022
- target: x86_64-pc-windows-msvc/msvc
architecture: x64
runner: windows-latest
runner: windows-2022
- target: aarch64-pc-windows-msvc/msvc
architecture: ARM64
runner: windows-11-arm
- target: x86_64-apple-darwin/clang
architecture: x86_64
runner: macos-13
runner: macos-15-intel
- target: aarch64-apple-darwin/clang
architecture: aarch64
runner: macos-14
@ -102,17 +106,16 @@ jobs:
./PCbuild/build.bat --experimental-jit ${{ matrix.debug && '-d' || '' }} -p ${{ matrix.architecture }}
./PCbuild/rt.bat ${{ matrix.debug && '-d' || '' }} -p ${{ matrix.architecture }} -q --multiprocess 0 --timeout 4500 --verbose2 --verbose3
# The `find` line is required as a result of https://github.com/actions/runner-images/issues/9966.
# This is a bug in the macOS runner image where the pre-installed Python is installed in the same
# directory as the Homebrew Python, which causes the build to fail for macos-13. This line removes
# the symlink to the pre-installed Python so that the Homebrew Python is used instead.
- name: macOS
if: runner.os == 'macOS'
run: |
brew update
find /usr/local/bin -lname '*/Library/Frameworks/Python.framework/*' -delete
brew install llvm@${{ matrix.llvm }}
export SDKROOT="$(xcrun --show-sdk-path)"
# Set MACOSX_DEPLOYMENT_TARGET and -Werror=unguarded-availability to
# make sure we don't break downstream distributors (like uv):
export CFLAGS_JIT='-Werror=unguarded-availability'
export MACOSX_DEPLOYMENT_TARGET=10.15
./configure --enable-experimental-jit --enable-universalsdk --with-universal-archs=universal2 ${{ matrix.debug && '--with-pydebug' || '' }}
make all --jobs 4
./python.exe -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3
@ -126,30 +129,81 @@ jobs:
make all --jobs 4
./python -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3
# XXX: GH-133171
# jit-with-disabled-gil:
# name: Free-Threaded (Debug)
# needs: interpreter
# runs-on: ubuntu-24.04
# timeout-minutes: 90
# strategy:
# fail-fast: false
# matrix:
# llvm:
# - 19
# steps:
# - uses: actions/checkout@v4
# with:
# persist-credentials: false
# - uses: actions/setup-python@v5
# with:
# python-version: '3.11'
# - name: Build with JIT enabled and GIL disabled
# run: |
# sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" ./llvm.sh ${{ matrix.llvm }}
# export PATH="$(llvm-config-${{ matrix.llvm }} --bindir):$PATH"
# ./configure --enable-experimental-jit --with-pydebug --disable-gil
# make all --jobs 4
# - name: Run tests
# run: |
# ./python -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3
jit-with-disabled-gil:
name: Free-Threaded (Debug)
needs: interpreter
runs-on: ubuntu-24.04
timeout-minutes: 90
strategy:
fail-fast: false
matrix:
llvm:
- 21
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Build with JIT enabled and GIL disabled
run: |
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" ./llvm.sh ${{ matrix.llvm }}
export PATH="$(llvm-config-${{ matrix.llvm }} --bindir):$PATH"
./configure --enable-experimental-jit --with-pydebug --disable-gil
make all --jobs 4
- name: Run tests
run: |
./python -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3
continue-on-error: true
no-opt-jit:
name: JIT without optimizations (Debug)
needs: interpreter
runs-on: ubuntu-24.04
timeout-minutes: 90
strategy:
fail-fast: false
matrix:
llvm:
- 21
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Build with JIT
run: |
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" ./llvm.sh ${{ matrix.llvm }}
export PATH="$(llvm-config-${{ matrix.llvm }} --bindir):$PATH"
./configure --enable-experimental-jit --with-pydebug
make all --jobs 4
- name: Run tests without optimizations
run: |
PYTHON_UOPS_OPTIMIZE=0 ./python -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3
tail-call-jit:
name: JIT with tail calling interpreter
needs: interpreter
runs-on: ubuntu-24.04
timeout-minutes: 90
strategy:
fail-fast: false
matrix:
llvm:
- 21
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Build with JIT and tailcall
run: |
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" ./llvm.sh ${{ matrix.llvm }}
export PATH="$(llvm-config-${{ matrix.llvm }} --bindir):$PATH"
CC=clang-${{ matrix.llvm }} ./configure --enable-experimental-jit --with-tail-call-interp --with-pydebug
make all --jobs 4

View file

@ -13,13 +13,23 @@ on:
- "Lib/test/libregrtest/**"
- "Lib/tomllib/**"
- "Misc/mypy/**"
- "Tools/build/check_extension_modules.py"
- "Tools/build/check_warnings.py"
- "Tools/build/compute-changes.py"
- "Tools/build/consts_getter.py"
- "Tools/build/deepfreeze.py"
- "Tools/build/generate-build-details.py"
- "Tools/build/generate_sbom.py"
- "Tools/build/generate_stdlib_module_names.py"
- "Tools/build/mypy.ini"
- "Tools/build/umarshal.py"
- "Tools/build/update_file.py"
- "Tools/build/verify_ensurepip_wheels.py"
- "Tools/cases_generator/**"
- "Tools/clinic/**"
- "Tools/jit/**"
- "Tools/peg_generator/**"
- "Tools/requirements-dev.txt"
- "Tools/wasm/**"
workflow_dispatch:
permissions:
@ -51,7 +61,6 @@ jobs:
"Tools/clinic",
"Tools/jit",
"Tools/peg_generator",
"Tools/wasm",
]
steps:
- uses: actions/checkout@v4

View file

@ -5,6 +5,7 @@ apt-get -yq install \
build-essential \
pkg-config \
ccache \
cmake \
gdb \
lcov \
libb2-dev \
@ -17,6 +18,7 @@ apt-get -yq install \
libreadline6-dev \
libsqlite3-dev \
libssl-dev \
libzstd-dev \
lzma \
lzma-dev \
strace \
@ -24,3 +26,10 @@ apt-get -yq install \
uuid-dev \
xvfb \
zlib1g-dev
# Workaround missing libmpdec-dev on ubuntu 24.04:
# https://launchpad.net/~ondrej/+archive/ubuntu/php
# https://deb.sury.org/
sudo add-apt-repository ppa:ondrej/php
apt-get update
apt-get -yq install libmpdec-dev

View file

@ -1,31 +0,0 @@
name: Update GH projects
on:
issues:
types:
- opened
- labeled
permissions:
contents: read
jobs:
add-to-project:
name: Add issues to projects
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
include:
# if an issue has any of these labels, it will be added
# to the corresponding project
- { project: 2, label: "release-blocker, deferred-blocker" }
- { project: 32, label: sprint }
steps:
- uses: actions/add-to-project@v1.0.0
with:
project-url: https://github.com/orgs/python/projects/${{ matrix.project }}
github-token: ${{ secrets.ADD_TO_PROJECT_PAT }}
labeled: ${{ matrix.label }}

View file

@ -17,9 +17,6 @@ on: # yamllint disable-line rule:truthy
# || 'falsy-branch'
# }}
#
config-hash:
description: Config hash value for use in cache keys
value: ${{ jobs.compute-changes.outputs.config-hash }} # str
run-docs:
description: Whether to build the docs
value: ${{ jobs.compute-changes.outputs.run-docs }} # bool
@ -42,7 +39,6 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 10
outputs:
config-hash: ${{ steps.config-hash.outputs.hash }}
run-ci-fuzz: ${{ steps.changes.outputs.run-ci-fuzz }}
run-docs: ${{ steps.changes.outputs.run-docs }}
run-tests: ${{ steps.changes.outputs.run-tests }}
@ -97,10 +93,6 @@ jobs:
run: python Tools/build/compute-changes.py
env:
GITHUB_DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
GITHUB_EVENT_NAME: ${{ github.event_name }}
CCF_TARGET_REF: ${{ github.base_ref || github.event.repository.default_branch }}
CCF_HEAD_REF: ${{ github.event.pull_request.head.sha || github.sha }}
- name: Compute hash for config cache key
id: config-hash
run: |
echo "hash=${{ hashFiles('configure', 'configure.ac', '.github/workflows/build.yml') }}" >> "$GITHUB_OUTPUT"

View file

@ -66,7 +66,7 @@ jobs:
run: |
set -Eeuo pipefail
# Build docs with the nit-picky option; write warnings to file
make -C Doc/ PYTHON=../python SPHINXOPTS="--quiet --nitpicky --fail-on-warning --warning-file sphinx-warnings.txt" html
make -C Doc/ PYTHON=../python SPHINXOPTS="--quiet --nitpicky --warning-file sphinx-warnings.txt" html
- name: 'Check warnings'
if: github.event_name == 'pull_request'
run: |
@ -102,3 +102,30 @@ jobs:
# Use "xvfb-run" since some doctest tests open GUI windows
- name: 'Run documentation doctest'
run: xvfb-run make -C Doc/ PYTHON=../python SPHINXERRORHANDLING="--fail-on-warning" doctest
check-epub:
name: 'Check EPUB'
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: 'Set up Python'
uses: actions/setup-python@v5
with:
python-version: '3'
cache: 'pip'
cache-dependency-path: 'Doc/requirements.txt'
- name: 'Install build dependencies'
run: |
make -C Doc/ venv
python -m pip install epubcheck
- name: 'Build EPUB documentation'
run: make -C Doc/ PYTHON=../python epub
- name: 'Run epubcheck'
continue-on-error: true
run: epubcheck Doc/build/epub/Python.epub &> Doc/epubcheck.txt
- run: cat Doc/epubcheck.txt
- name: 'Check for fatal errors in EPUB'
run: python Doc/tools/check-epub.py

View file

@ -3,9 +3,6 @@ name: Reusable macOS
on:
workflow_call:
inputs:
config_hash:
required: true
type: string
free-threading:
required: false
type: boolean
@ -36,16 +33,11 @@ jobs:
persist-credentials: false
- name: Runner image version
run: echo "IMAGE_OS_VERSION=${ImageOS}-${ImageVersion}" >> "$GITHUB_ENV"
- name: Restore config.cache
uses: actions/cache@v4
with:
path: config.cache
key: ${{ github.job }}-${{ env.IMAGE_OS_VERSION }}-${{ inputs.config_hash }}
- name: Install Homebrew dependencies
run: |
brew install pkg-config openssl@3.0 xz gdbm tcl-tk@8 make
brew install pkg-config openssl@3.0 xz gdbm tcl-tk@9 make
# Because alternate versions are not symlinked into place by default:
brew link --overwrite tcl-tk@8
brew link --overwrite tcl-tk@9
- name: Configure CPython
run: |
MACOSX_DEPLOYMENT_TARGET=10.15 \
@ -60,15 +52,15 @@ jobs:
--prefix=/opt/python-dev \
--with-openssl="$(brew --prefix openssl@3.0)"
- name: Build CPython
if : ${{ inputs.free-threading || inputs.os != 'macos-13' }}
if : ${{ inputs.free-threading || inputs.os != 'macos-15-intel' }}
run: gmake -j8
- name: Build CPython for compiler warning check
if : ${{ !inputs.free-threading && inputs.os == 'macos-13' }}
if : ${{ !inputs.free-threading && inputs.os == 'macos-15-intel' }}
run: set -o pipefail; gmake -j8 --output-sync 2>&1 | tee compiler_output_macos.txt
- name: Display build info
run: make pythoninfo
- name: Check compiler warnings
if : ${{ !inputs.free-threading && inputs.os == 'macos-13' }}
if : ${{ !inputs.free-threading && inputs.os == 'macos-15-intel' }}
run: >-
python3 Tools/build/check_warnings.py
--compiler-output-file-path=compiler_output_macos.txt

111
.github/workflows/reusable-san.yml vendored Normal file
View file

@ -0,0 +1,111 @@
name: Reusable Sanitizer
on:
workflow_call:
inputs:
sanitizer:
required: true
type: string
free-threading:
description: Whether to use free-threaded mode
required: false
type: boolean
default: false
env:
FORCE_COLOR: 1
jobs:
build-san-reusable:
name: >-
${{ inputs.sanitizer }}${{
inputs.free-threading
&& ' (free-threading)'
|| ''
}}
runs-on: ubuntu-24.04
timeout-minutes: 60
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Runner image version
run: echo "IMAGE_OS_VERSION=${ImageOS}-${ImageVersion}" >> "$GITHUB_ENV"
- name: Install dependencies
run: |
sudo ./.github/workflows/posix-deps-apt.sh
# Install clang
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
if [ "${SANITIZER}" = "TSan" ]; then
sudo ./llvm.sh 17 # gh-121946: llvm-18 package is temporarily broken
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-17 100
sudo update-alternatives --set clang /usr/bin/clang-17
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-17 100
sudo update-alternatives --set clang++ /usr/bin/clang++-17
# Reduce ASLR to avoid TSan crashing
sudo sysctl -w vm.mmap_rnd_bits=28
else
sudo ./llvm.sh 20
fi
- name: Sanitizer option setup
run: |
if [ "${SANITIZER}" = "TSan" ]; then
echo "TSAN_OPTIONS=${SAN_LOG_OPTION} suppressions=${GITHUB_WORKSPACE}/Tools/tsan/suppressions${{
fromJSON(inputs.free-threading)
&& '_free_threading'
|| ''
}}.txt handle_segv=0" >> "$GITHUB_ENV"
else
echo "UBSAN_OPTIONS=${SAN_LOG_OPTION}" >> "$GITHUB_ENV"
fi
echo "CC=clang" >> "$GITHUB_ENV"
echo "CXX=clang++" >> "$GITHUB_ENV"
env:
SANITIZER: ${{ inputs.sanitizer }}
SAN_LOG_OPTION: log_path=${{ github.workspace }}/san_log
- name: Add ccache to PATH
run: |
echo "PATH=/usr/lib/ccache:$PATH" >> "$GITHUB_ENV"
- name: Configure CPython
run: >-
./configure
--config-cache
${{
inputs.sanitizer == 'TSan'
&& '--with-thread-sanitizer'
|| '--with-undefined-behavior-sanitizer'
}}
--with-pydebug
${{ fromJSON(inputs.free-threading) && '--disable-gil' || '' }}
- name: Build CPython
run: make -j4
- name: Display build info
run: make pythoninfo
- name: Tests
run: >-
./python -m test
${{ inputs.sanitizer == 'TSan' && '--tsan' || '' }}
-j4
- name: Parallel tests
if: >-
inputs.sanitizer == 'TSan'
&& fromJSON(inputs.free-threading)
run: ./python -m test --tsan-parallel --parallel-threads=4 -j4
- name: Display logs
if: always()
run: find "${GITHUB_WORKSPACE}" -name 'san_log.*' | xargs head -n 1000
- name: Archive logs
if: always()
uses: actions/upload-artifact@v4
with:
name: >-
${{ inputs.sanitizer }}-logs-${{
fromJSON(inputs.free-threading)
&& 'free-threading'
|| 'default'
}}
path: san_log.*
if-no-files-found: ignore

View file

@ -1,94 +0,0 @@
name: Reusable Thread Sanitizer
on:
workflow_call:
inputs:
config_hash:
required: true
type: string
free-threading:
description: Whether to use free-threaded mode
required: false
type: boolean
default: false
env:
FORCE_COLOR: 1
jobs:
build-tsan-reusable:
name: 'Thread sanitizer'
runs-on: ubuntu-24.04
timeout-minutes: 60
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Runner image version
run: echo "IMAGE_OS_VERSION=${ImageOS}-${ImageVersion}" >> "$GITHUB_ENV"
- name: Restore config.cache
uses: actions/cache@v4
with:
path: config.cache
key: ${{ github.job }}-${{ env.IMAGE_OS_VERSION }}-${{ inputs.config_hash }}
- name: Install dependencies
run: |
sudo ./.github/workflows/posix-deps-apt.sh
# Install clang-18
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 17 # gh-121946: llvm-18 package is temporarily broken
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-17 100
sudo update-alternatives --set clang /usr/bin/clang-17
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-17 100
sudo update-alternatives --set clang++ /usr/bin/clang++-17
# Reduce ASLR to avoid TSAN crashing
sudo sysctl -w vm.mmap_rnd_bits=28
- name: TSAN option setup
run: |
echo "TSAN_OPTIONS=log_path=${GITHUB_WORKSPACE}/tsan_log suppressions=${GITHUB_WORKSPACE}/Tools/tsan/suppressions${{
fromJSON(inputs.free-threading)
&& '_free_threading'
|| ''
}}.txt handle_segv=0" >> "$GITHUB_ENV"
echo "CC=clang" >> "$GITHUB_ENV"
echo "CXX=clang++" >> "$GITHUB_ENV"
- name: Add ccache to PATH
run: |
echo "PATH=/usr/lib/ccache:$PATH" >> "$GITHUB_ENV"
- name: Configure ccache action
uses: hendrikmuhs/ccache-action@v1.2
with:
save: ${{ github.event_name == 'push' }}
max-size: "200M"
- name: Configure CPython
run: >-
./configure
--config-cache
--with-thread-sanitizer
--with-pydebug
${{ fromJSON(inputs.free-threading) && '--disable-gil' || '' }}
- name: Build CPython
run: make -j4
- name: Display build info
run: make pythoninfo
- name: Tests
run: ./python -m test --tsan -j4
- name: Parallel tests
if: fromJSON(inputs.free-threading)
run: ./python -m test --tsan-parallel --parallel-threads=4 -j4
- name: Display TSAN logs
if: always()
run: find "${GITHUB_WORKSPACE}" -name 'tsan_log.*' | xargs head -n 1000
- name: Archive TSAN logs
if: always()
uses: actions/upload-artifact@v4
with:
name: >-
tsan-logs-${{
fromJSON(inputs.free-threading)
&& 'free-threading'
|| 'default'
}}
path: tsan_log.*
if-no-files-found: ignore

View file

@ -3,9 +3,6 @@ name: Reusable Ubuntu
on:
workflow_call:
inputs:
config_hash:
required: true
type: string
bolt-optimizations:
description: Whether to enable BOLT optimizations
required: false
@ -30,7 +27,7 @@ jobs:
runs-on: ${{ inputs.os }}
timeout-minutes: 60
env:
OPENSSL_VER: 3.0.15
OPENSSL_VER: 3.0.18
PYTHONSTRICTEXTENSIONBUILD: 1
TERM: linux
steps:
@ -64,11 +61,6 @@ jobs:
- name: Add ccache to PATH
run: |
echo "PATH=/usr/lib/ccache:$PATH" >> "$GITHUB_ENV"
- name: Configure ccache action
uses: hendrikmuhs/ccache-action@v1.2
with:
save: ${{ github.event_name == 'push' }}
max-size: "200M"
- name: Setup directory envs for out-of-tree builds
run: |
echo "CPYTHON_RO_SRCDIR=$(realpath -m "${GITHUB_WORKSPACE}"/../cpython-ro-srcdir)" >> "$GITHUB_ENV"
@ -79,11 +71,6 @@ jobs:
run: sudo mount --bind -o ro "$GITHUB_WORKSPACE" "$CPYTHON_RO_SRCDIR"
- name: Runner image version
run: echo "IMAGE_OS_VERSION=${ImageOS}-${ImageVersion}" >> "$GITHUB_ENV"
- name: Restore config.cache
uses: actions/cache@v4
with:
path: ${{ env.CPYTHON_BUILDDIR }}/config.cache
key: ${{ github.job }}-${{ env.IMAGE_OS_VERSION }}-${{ inputs.config_hash }}
- name: Configure CPython out-of-tree
working-directory: ${{ env.CPYTHON_BUILDDIR }}
# `test_unpickle_module_race` writes to the source directory, which is

View file

@ -2,10 +2,6 @@ name: Reusable WASI
on:
workflow_call:
inputs:
config_hash:
required: true
type: string
env:
FORCE_COLOR: 1
@ -13,11 +9,11 @@ env:
jobs:
build-wasi-reusable:
name: 'build and test'
runs-on: ubuntu-24.04
runs-on: ubuntu-24.04-arm
timeout-minutes: 60
env:
WASMTIME_VERSION: 22.0.0
WASI_SDK_VERSION: 24
WASMTIME_VERSION: 38.0.3
WASI_SDK_VERSION: 29
WASI_SDK_PATH: /opt/wasi-sdk
CROSS_BUILD_PYTHON: cross-build/build
CROSS_BUILD_WASI: cross-build/wasm32-wasip1
@ -40,13 +36,8 @@ jobs:
if: steps.cache-wasi-sdk.outputs.cache-hit != 'true'
run: |
mkdir "${WASI_SDK_PATH}" && \
curl -s -S --location "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_SDK_VERSION}/wasi-sdk-${WASI_SDK_VERSION}.0-x86_64-linux.tar.gz" | \
curl -s -S --location "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_SDK_VERSION}/wasi-sdk-${WASI_SDK_VERSION}.0-arm64-linux.tar.gz" | \
tar --strip-components 1 --directory "${WASI_SDK_PATH}" --extract --gunzip
- name: "Configure ccache action"
uses: hendrikmuhs/ccache-action@v1.2
with:
save: ${{ github.event_name == 'push' }}
max-size: "200M"
- name: "Add ccache to PATH"
run: echo "PATH=/usr/lib/ccache:$PATH" >> "$GITHUB_ENV"
- name: "Install Python"
@ -55,29 +46,15 @@ jobs:
python-version: '3.x'
- name: "Runner image version"
run: echo "IMAGE_OS_VERSION=${ImageOS}-${ImageVersion}" >> "$GITHUB_ENV"
- name: "Restore Python build config.cache"
uses: actions/cache@v4
with:
path: ${{ env.CROSS_BUILD_PYTHON }}/config.cache
# Include env.pythonLocation in key to avoid changes in environment when setup-python updates Python.
# Include the hash of `Tools/wasm/wasi.py` as it may change the environment variables.
# (Make sure to keep the key in sync with the other config.cache step below.)
key: ${{ github.job }}-${{ env.IMAGE_OS_VERSION }}-${{ env.WASI_SDK_VERSION }}-${{ env.WASMTIME_VERSION }}-${{ inputs.config_hash }}-${{ hashFiles('Tools/wasm/wasi.py') }}-${{ env.pythonLocation }}
- name: "Configure build Python"
run: python3 Tools/wasm/wasi.py configure-build-python -- --config-cache --with-pydebug
run: python3 Tools/wasm/wasi configure-build-python -- --config-cache --with-pydebug
- name: "Make build Python"
run: python3 Tools/wasm/wasi.py make-build-python
- name: "Restore host config.cache"
uses: actions/cache@v4
with:
path: ${{ env.CROSS_BUILD_WASI }}/config.cache
# Should be kept in sync with the other config.cache step above.
key: ${{ github.job }}-${{ env.IMAGE_OS_VERSION }}-${{ env.WASI_SDK_VERSION }}-${{ env.WASMTIME_VERSION }}-${{ inputs.config_hash }}-${{ hashFiles('Tools/wasm/wasi.py') }}-${{ env.pythonLocation }}
run: python3 Tools/wasm/wasi make-build-python
- name: "Configure host"
# `--with-pydebug` inferred from configure-build-python
run: python3 Tools/wasm/wasi.py configure-host -- --config-cache
run: python3 Tools/wasm/wasi configure-host -- --config-cache
- name: "Make host"
run: python3 Tools/wasm/wasi.py make-host
run: python3 Tools/wasm/wasi make-host
- name: "Display build info"
run: make --directory "${CROSS_BUILD_WASI}" pythoninfo
- name: "Test"

View file

@ -17,7 +17,7 @@ env:
jobs:
build:
name: installer for ${{ inputs.arch }}
runs-on: ${{ inputs.arch == 'arm64' && 'windows-11-arm' || 'windows-latest' }}
runs-on: ${{ inputs.arch == 'arm64' && 'windows-11-arm' || 'windows-2022' }}
timeout-minutes: 60
env:
ARCH: ${{ inputs.arch }}

View file

@ -21,7 +21,7 @@ env:
jobs:
build:
name: Build and test (${{ inputs.arch }})
runs-on: ${{ inputs.arch == 'arm64' && 'windows-11-arm' || 'windows-latest' }}
runs-on: ${{ inputs.arch == 'arm64' && 'windows-11-arm' || 'windows-2022' }}
timeout-minutes: 60
env:
ARCH: ${{ inputs.arch }}

View file

@ -49,16 +49,16 @@ jobs:
include:
# - target: i686-pc-windows-msvc/msvc
# architecture: Win32
# runner: windows-latest
# runner: windows-2022
- target: x86_64-pc-windows-msvc/msvc
architecture: x64
runner: windows-latest
runner: windows-2022
# - target: aarch64-pc-windows-msvc/msvc
# architecture: ARM64
# runner: windows-latest
# runner: windows-2022
- target: x86_64-apple-darwin/clang
architecture: x86_64
runner: macos-13
runner: macos-15-intel
- target: aarch64-apple-darwin/clang
architecture: aarch64
runner: macos-14
@ -101,21 +101,14 @@ jobs:
set LLVMInstallDir=C:\Program Files\LLVM
./PCbuild/build.bat --tail-call-interp -p ${{ matrix.architecture }}
# The `find` line is required as a result of https://github.com/actions/runner-images/issues/9966.
# This is a bug in the macOS runner image where the pre-installed Python is installed in the same
# directory as the Homebrew Python, which causes the build to fail for macos-13. This line removes
# the symlink to the pre-installed Python so that the Homebrew Python is used instead.
# Note: when a new LLVM is released, the homebrew installation directory changes, so the builds will fail.
# We either need to upgrade LLVM or change the directory being pointed to.
- name: Native macOS (release)
if: runner.os == 'macOS'
run: |
brew update
find /usr/local/bin -lname '*/Library/Frameworks/Python.framework/*' -delete
brew install llvm@${{ matrix.llvm }}
export SDKROOT="$(xcrun --show-sdk-path)"
export PATH="/usr/local/opt/llvm/bin:$PATH"
export PATH="/opt/homebrew/opt/llvm/bin:$PATH"
export PATH="/usr/local/opt/llvm@${{ matrix.llvm }}/bin:$PATH"
export PATH="/opt/homebrew/opt/llvm@${{ matrix.llvm }}/bin:$PATH"
CC=clang-20 ./configure --with-tail-call-interp
make all --jobs 4
./python.exe -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3
@ -137,4 +130,3 @@ jobs:
CC=clang-20 ./configure --with-tail-call-interp --disable-gil
make all --jobs 4
./python -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3

26
.gitignore vendored
View file

@ -71,16 +71,15 @@ Lib/test/data/*
/Makefile
/Makefile.pre
/iOSTestbed.*
iOS/Frameworks/
iOS/Resources/Info.plist
iOS/testbed/build
iOS/testbed/Python.xcframework/ios-*/bin
iOS/testbed/Python.xcframework/ios-*/include
iOS/testbed/Python.xcframework/ios-*/lib
iOS/testbed/Python.xcframework/ios-*/Python.framework
iOS/testbed/iOSTestbed.xcodeproj/project.xcworkspace
iOS/testbed/iOSTestbed.xcodeproj/xcuserdata
iOS/testbed/iOSTestbed.xcodeproj/xcshareddata
Apple/iOS/Frameworks/
Apple/iOS/Resources/Info.plist
Apple/testbed/build
Apple/testbed/Python.xcframework/*/bin
Apple/testbed/Python.xcframework/*/include
Apple/testbed/Python.xcframework/*/lib
Apple/testbed/Python.xcframework/*/Python.framework
Apple/testbed/*Testbed.xcodeproj/project.xcworkspace
Apple/testbed/*Testbed.xcodeproj/xcuserdata
Mac/Makefile
Mac/PythonLauncher/Info.plist
Mac/PythonLauncher/Makefile
@ -131,11 +130,11 @@ Tools/unicode/data/
/autom4te.cache
/build/
/builddir/
/compile_commands.json
/config.cache
/config.log
/config.status
/config.status.lineno
# hendrikmuhs/ccache-action@v1
/.ccache
/cross-build/
/jit_stencils*.h
@ -171,5 +170,10 @@ Python/frozen_modules/MANIFEST
/python
!/Python/
# People's custom https://docs.anthropic.com/en/docs/claude-code/memory configs.
/.claude/
CLAUDE.local.md
#### main branch only stuff below this line, things to backport go above. ####
# main branch only: ABI files are not checked/maintained.
Doc/data/python*.abi

View file

@ -1,23 +1,43 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.11.8
rev: v0.13.2
hooks:
- id: ruff
- id: ruff-check
name: Run Ruff (lint) on Apple/
args: [--exit-non-zero-on-fix, --config=Apple/.ruff.toml]
files: ^Apple/
- id: ruff-check
name: Run Ruff (lint) on Doc/
args: [--exit-non-zero-on-fix]
files: ^Doc/
- id: ruff
- id: ruff-check
name: Run Ruff (lint) on Lib/test/
args: [--exit-non-zero-on-fix]
files: ^Lib/test/
- id: ruff
- id: ruff-check
name: Run Ruff (lint) on Tools/build/
args: [--exit-non-zero-on-fix, --config=Tools/build/.ruff.toml]
files: ^Tools/build/
- id: ruff
- id: ruff-check
name: Run Ruff (lint) on Tools/i18n/
args: [--exit-non-zero-on-fix, --config=Tools/i18n/.ruff.toml]
files: ^Tools/i18n/
- id: ruff-check
name: Run Ruff (lint) on Argument Clinic
args: [--exit-non-zero-on-fix, --config=Tools/clinic/.ruff.toml]
files: ^Tools/clinic/|Lib/test/test_clinic.py
- id: ruff-check
name: Run Ruff (lint) on Tools/peg_generator/
args: [--exit-non-zero-on-fix, --config=Tools/peg_generator/.ruff.toml]
files: ^Tools/peg_generator/
- id: ruff-check
name: Run Ruff (lint) on Tools/wasm/
args: [--exit-non-zero-on-fix, --config=Tools/wasm/.ruff.toml]
files: ^Tools/wasm/
- id: ruff-format
name: Run Ruff (format) on Apple/
args: [--exit-non-zero-on-fix, --config=Apple/.ruff.toml]
files: ^Apple
- id: ruff-format
name: Run Ruff (format) on Doc/
args: [--check]
@ -26,16 +46,26 @@ repos:
name: Run Ruff (format) on Tools/build/check_warnings.py
args: [--check, --config=Tools/build/.ruff.toml]
files: ^Tools/build/check_warnings.py
- id: ruff-format
name: Run Ruff (format) on Tools/wasm/
args: [--check, --config=Tools/wasm/.ruff.toml]
files: ^Tools/wasm/
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 25.1.0
rev: 25.9.0
hooks:
- id: black
name: Run Black on Tools/jit/
files: ^Tools/jit/
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.5
hooks:
- id: remove-tabs
types: [python]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
rev: v6.0.0
hooks:
- id: check-case-conflict
- id: check-merge-conflict
@ -43,13 +73,17 @@ repos:
exclude: ^Lib/test/test_tomllib/
- id: check-yaml
- id: end-of-file-fixer
types: [python]
types_or: [python, yaml]
exclude: Lib/test/tokenizedata/coding20731.py
- id: end-of-file-fixer
files: '^\.github/CODEOWNERS$'
- id: trailing-whitespace
types_or: [c, inc, python, rst]
types_or: [c, inc, python, rst, yaml]
- id: trailing-whitespace
files: '^\.github/CODEOWNERS|\.(gram)$'
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.33.0
rev: 0.34.0
hooks:
- id: check-dependabot
- id: check-github-workflows
@ -61,7 +95,7 @@ repos:
- id: actionlint
- repo: https://github.com/woodruffw/zizmor-pre-commit
rev: v1.6.0
rev: v1.14.1
hooks:
- id: zizmor

View file

@ -32,4 +32,3 @@ build:
- make -C Doc venv html
- mkdir _readthedocs
- mv Doc/build/html _readthedocs/html

View file

@ -0,0 +1 @@
https://www.python.org/funding.json

View file

@ -96,10 +96,12 @@ ## Packaging
## Testing
The Python test suite can be run on Linux, macOS, or Windows:
The Python test suite can be run on Linux, macOS, or Windows.
* On Linux, the emulator needs access to the KVM virtualization interface, and
a DISPLAY environment variable pointing at an X server. Xvfb is acceptable.
On Linux, the emulator needs access to the KVM virtualization interface. This may
require adding your user to a group, or changing your udev rules. On GitHub
Actions, the test script will do this automatically using the commands shown
[here](https://github.blog/changelog/2024-04-02-github-actions-hardware-accelerated-android-virtualization-now-available/).
The test suite can usually be run on a device with 2 GB of RAM, but this is
borderline, so you may need to increase it to 4 GB. As of Android
@ -156,6 +158,10 @@ ## Testing
and architecture-specific files such as sysconfigdata, will not take effect
until you re-run `android.py make-host` or `build`.
The testbed app can also be used to test third-party packages. For more details,
run `android.py test --help`, paying attention to the options `--site-packages`,
`--cwd`, `-c` and `-m`.
## Using in your own app

View file

@ -3,7 +3,7 @@
: "${HOST:?}" # GNU target triplet
# You may also override the following:
: "${api_level:=24}" # Minimum Android API level the build will run on
: "${ANDROID_API_LEVEL:=24}" # Minimum Android API level the build will run on
: "${PREFIX:-}" # Path in which to find required libraries
@ -24,7 +24,7 @@ fail() {
# * https://android.googlesource.com/platform/ndk/+/ndk-rXX-release/docs/BuildSystemMaintainers.md
# where XX is the NDK version. Do a diff against the version you're upgrading from, e.g.:
# https://android.googlesource.com/platform/ndk/+/ndk-r25-release..ndk-r26-release/docs/BuildSystemMaintainers.md
ndk_version=27.1.12297006
ndk_version=27.3.13750724
ndk=$ANDROID_HOME/ndk/$ndk_version
if ! [ -e "$ndk" ]; then
@ -43,7 +43,7 @@ fi
toolchain=$(echo "$ndk"/toolchains/llvm/prebuilt/*)
export AR="$toolchain/bin/llvm-ar"
export AS="$toolchain/bin/llvm-as"
export CC="$toolchain/bin/${clang_triplet}${api_level}-clang"
export CC="$toolchain/bin/${clang_triplet}${ANDROID_API_LEVEL}-clang"
export CXX="${CC}++"
export LD="$toolchain/bin/ld"
export NM="$toolchain/bin/llvm-nm"

View file

@ -2,7 +2,9 @@
import asyncio
import argparse
import json
import os
import platform
import re
import shlex
import shutil
@ -14,7 +16,7 @@
from contextlib import asynccontextmanager
from datetime import datetime, timezone
from glob import glob
from os.path import basename, relpath
from os.path import abspath, basename, relpath
from pathlib import Path
from subprocess import CalledProcessError
from tempfile import TemporaryDirectory
@ -22,9 +24,14 @@
SCRIPT_NAME = Path(__file__).name
ANDROID_DIR = Path(__file__).resolve().parent
CHECKOUT = ANDROID_DIR.parent
PYTHON_DIR = ANDROID_DIR.parent
in_source_tree = (
ANDROID_DIR.name == "Android" and (PYTHON_DIR / "pyconfig.h.in").exists()
)
ENV_SCRIPT = ANDROID_DIR / "android-env.sh"
TESTBED_DIR = ANDROID_DIR / "testbed"
CROSS_BUILD_DIR = CHECKOUT / "cross-build"
CROSS_BUILD_DIR = PYTHON_DIR / "cross-build"
HOSTS = ["aarch64-linux-android", "x86_64-linux-android"]
APP_ID = "org.python.testbed"
@ -46,7 +53,19 @@
+ (".bat" if os.name == "nt" else "")
)
logcat_started = False
# Whether we've seen any output from Python yet.
python_started = False
# Buffer for verbose output which will be displayed only if a test fails and
# there has been no output from Python.
hidden_output = []
def log_verbose(context, line, stream=sys.stdout):
if context.verbose:
stream.write(line)
else:
hidden_output.append((stream, line))
def delete_glob(pattern):
@ -76,39 +95,67 @@ def run(command, *, host=None, env=None, log=True, **kwargs):
kwargs.setdefault("check", True)
if env is None:
env = os.environ.copy()
original_env = env.copy()
if host:
env_script = ANDROID_DIR / "android-env.sh"
env_output = subprocess.run(
f"set -eu; "
f"HOST={host}; "
f"PREFIX={subdir(host)}/prefix; "
f". {env_script}; "
f"export",
check=True, shell=True, text=True, stdout=subprocess.PIPE
).stdout
for line in env_output.splitlines():
# We don't require every line to match, as there may be some other
# output from installing the NDK.
if match := re.search(
"^(declare -x |export )?(\\w+)=['\"]?(.*?)['\"]?$", line
):
key, value = match[2], match[3]
if env.get(key) != value:
print(line)
env[key] = value
if env == original_env:
raise ValueError(f"Found no variables in {env_script.name} output:\n"
+ env_output)
host_env = android_env(host)
print_env(host_env)
env.update(host_env)
if log:
print(">", " ".join(map(str, command)))
print(">", join_command(command))
return subprocess.run(command, env=env, **kwargs)
# Format a command so it can be copied into a shell. Like shlex.join, but also
# accepts arguments which are Paths, or a single string/Path outside of a list.
def join_command(args):
if isinstance(args, (str, Path)):
return str(args)
else:
return shlex.join(map(str, args))
# Format the environment so it can be pasted into a shell.
def print_env(env):
for key, value in sorted(env.items()):
print(f"export {key}={shlex.quote(value)}")
def android_env(host):
if host:
prefix = subdir(host) / "prefix"
else:
prefix = ANDROID_DIR / "prefix"
sysconfig_files = prefix.glob("lib/python*/_sysconfigdata__android_*.py")
sysconfig_filename = next(sysconfig_files).name
host = re.fullmatch(r"_sysconfigdata__android_(.+).py", sysconfig_filename)[1]
env_output = subprocess.run(
f"set -eu; "
f"HOST={host}; "
f"PREFIX={prefix}; "
f". {ENV_SCRIPT}; "
f"export",
check=True, shell=True, capture_output=True, encoding='utf-8',
).stdout
env = {}
for line in env_output.splitlines():
# We don't require every line to match, as there may be some other
# output from installing the NDK.
if match := re.search(
"^(declare -x |export )?(\\w+)=['\"]?(.*?)['\"]?$", line
):
key, value = match[2], match[3]
if os.environ.get(key) != value:
env[key] = value
if not env:
raise ValueError(f"Found no variables in {ENV_SCRIPT.name} output:\n"
+ env_output)
return env
def build_python_path():
"""The path to the build Python binary."""
build_dir = subdir("build")
@ -127,7 +174,7 @@ def configure_build_python(context):
clean("build")
os.chdir(subdir("build", create=True))
command = [relpath(CHECKOUT / "configure")]
command = [relpath(PYTHON_DIR / "configure")]
if context.args:
command.extend(context.args)
run(command)
@ -138,13 +185,20 @@ def make_build_python(context):
run(["make", "-j", str(os.cpu_count())])
# To create new builds of these dependencies, usually all that's necessary is to
# push a tag to the cpython-android-source-deps repository, and GitHub Actions
# will do the rest.
#
# If you're a member of the Python core team, and you'd like to be able to push
# these tags yourself, please contact Malcolm Smith or Russell Keith-Magee.
def unpack_deps(host, prefix_dir):
os.chdir(prefix_dir)
deps_url = "https://github.com/beeware/cpython-android-source-deps/releases/download"
for name_ver in ["bzip2-1.0.8-2", "libffi-3.4.4-3", "openssl-3.0.15-4",
"sqlite-3.49.1-0", "xz-5.4.6-1"]:
for name_ver in ["bzip2-1.0.8-3", "libffi-3.4.4-3", "openssl-3.0.18-0",
"sqlite-3.50.4-0", "xz-5.4.6-1", "zstd-1.5.7-1"]:
filename = f"{name_ver}-{host}.tar.gz"
download(f"{deps_url}/{name_ver}/{filename}")
shutil.unpack_archive(filename, prefix_dir)
shutil.unpack_archive(filename)
os.remove(filename)
@ -167,7 +221,7 @@ def configure_host_python(context):
os.chdir(host_dir)
command = [
# Basic cross-compiling configuration
relpath(CHECKOUT / "configure"),
relpath(PYTHON_DIR / "configure"),
f"--host={context.host}",
f"--build={sysconfig.get_config_var('BUILD_GNU_TYPE')}",
f"--with-build-python={build_python_path()}",
@ -196,9 +250,18 @@ def make_host_python(context):
for pattern in ("include/python*", "lib/libpython*", "lib/python*"):
delete_glob(f"{prefix_dir}/{pattern}")
# The Android environment variables were already captured in the Makefile by
# `configure`, and passing them again when running `make` may cause some
# flags to be duplicated. So we don't use the `host` argument here.
os.chdir(host_dir)
run(["make", "-j", str(os.cpu_count())], host=context.host)
run(["make", "install", f"prefix={prefix_dir}"], host=context.host)
run(["make", "-j", str(os.cpu_count())])
# The `make install` output is very verbose and rarely useful, so
# suppress it by default.
run(
["make", "install", f"prefix={prefix_dir}"],
capture_output=not context.verbose,
)
def build_all(context):
@ -217,6 +280,33 @@ def clean_all(context):
clean(host)
def setup_ci():
if "GITHUB_ACTIONS" in os.environ:
# Enable emulator hardware acceleration
# (https://github.blog/changelog/2024-04-02-github-actions-hardware-accelerated-android-virtualization-now-available/).
if platform.system() == "Linux":
run(
["sudo", "tee", "/etc/udev/rules.d/99-kvm4all.rules"],
input='KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"\n',
text=True,
)
run(["sudo", "udevadm", "control", "--reload-rules"])
run(["sudo", "udevadm", "trigger", "--name-match=kvm"])
# Free up disk space by deleting unused versions of the NDK
# (https://github.com/freakboy3742/pyspamsum/pull/108).
for line in ENV_SCRIPT.read_text().splitlines():
if match := re.fullmatch(r"ndk_version=(.+)", line):
ndk_version = match[1]
break
else:
raise ValueError(f"Failed to find NDK version in {ENV_SCRIPT.name}")
for item in (android_home / "ndk").iterdir():
if item.name[0].isdigit() and item.name != ndk_version:
delete_glob(item)
def setup_sdk():
sdkmanager = android_home / (
"cmdline-tools/latest/bin/sdkmanager"
@ -228,7 +318,12 @@ def setup_sdk():
if not all((android_home / "licenses" / path).exists() for path in [
"android-sdk-arm-dbt-license", "android-sdk-license"
]):
run([sdkmanager, "--licenses"], text=True, input="y\n" * 100)
run(
[sdkmanager, "--licenses"],
text=True,
capture_output=True,
input="y\n" * 100,
)
# Gradle may install this automatically, but we can't rely on that because
# we need to run adb within the logcat task.
@ -411,17 +506,19 @@ async def logcat_task(context, initial_devices):
# `--pid` requires API level 24 or higher.
args = [adb, "-s", serial, "logcat", "--pid", pid, "--format", "tag"]
hidden_output = []
logcat_started = False
async with async_process(
*args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
) as process:
while line := (await process.stdout.readline()).decode(*DECODE_ARGS):
if match := re.fullmatch(r"([A-Z])/(.*)", line, re.DOTALL):
logcat_started = True
level, message = match.groups()
else:
# If the regex doesn't match, this is probably the second or
# subsequent line of a multi-line message. Python won't produce
# such messages, but other components might.
# If the regex doesn't match, this is either a logcat startup
# error, or the second or subsequent line of a multi-line
# message. Python won't produce multi-line messages, but other
# components might.
level, message = None, line
# Exclude high-volume messages which are rarely useful.
@ -441,25 +538,22 @@ async def logcat_task(context, initial_devices):
# tag indicators from Python's stdout and stderr.
for prefix in ["python.stdout: ", "python.stderr: "]:
if message.startswith(prefix):
global logcat_started
logcat_started = True
global python_started
python_started = True
stream.write(message.removeprefix(prefix))
break
else:
if context.verbose:
# Non-Python messages add a lot of noise, but they may
# sometimes help explain a failure.
stream.write(line)
else:
hidden_output.append(line)
# Non-Python messages add a lot of noise, but they may
# sometimes help explain a failure.
log_verbose(context, line, stream)
# If the device disconnects while logcat is running, which always
# happens in --managed mode, some versions of adb return non-zero.
# Distinguish this from a logcat startup error by checking whether we've
# received a message from Python yet.
# received any logcat messages yet.
status = await wait_for(process.wait(), timeout=1)
if status != 0 and not logcat_started:
raise CalledProcessError(status, args, "".join(hidden_output))
raise CalledProcessError(status, args)
def stop_app(serial):
@ -474,12 +568,38 @@ async def gradle_task(context):
task_prefix = "connected"
env["ANDROID_SERIAL"] = context.connected
if context.ci_mode:
context.args[0:0] = [
# See _add_ci_python_opts in libregrtest/main.py.
"-W", "error", "-bb", "-E",
# Randomization is disabled because order-dependent failures are
# much less likely to pass on a rerun in single-process mode.
"-m", "test",
f"--{context.ci_mode}-ci", "--single-process", "--no-randomize"
]
if not any(arg in context.args for arg in ["-c", "-m"]):
context.args[0:0] = ["-m", "test"]
args = [
gradlew, "--console", "plain", f"{task_prefix}DebugAndroidTest",
"-Pandroid.testInstrumentationRunnerArguments.pythonArgs="
+ shlex.join(context.args),
] + [
f"-P{name}={value}"
for name, value in [
("python.sitePackages", context.site_packages),
("python.cwd", context.cwd),
(
"android.testInstrumentationRunnerArguments.pythonArgs",
json.dumps(context.args),
),
]
if value
]
hidden_output = []
if context.verbose >= 2:
args.append("--info")
log_verbose(context, f"> {join_command(args)}\n")
try:
async with async_process(
*args, cwd=TESTBED_DIR, env=env,
@ -488,10 +608,10 @@ async def gradle_task(context):
while line := (await process.stdout.readline()).decode(*DECODE_ARGS):
# Gradle may take several minutes to install SDK packages, so
# it's worth showing those messages even in non-verbose mode.
if context.verbose or line.startswith('Preparing "Install'):
if line.startswith('Preparing "Install'):
sys.stdout.write(line)
else:
hidden_output.append(line)
log_verbose(context, line)
status = await wait_for(process.wait(), timeout=1)
if status == 0:
@ -499,17 +619,13 @@ async def gradle_task(context):
else:
raise CalledProcessError(status, args)
finally:
# If logcat never started, then something has gone badly wrong, so the
# user probably wants to see the Gradle output even in non-verbose mode.
if hidden_output and not logcat_started:
sys.stdout.write("".join(hidden_output))
# Gradle does not stop the tests when interrupted.
if context.connected:
stop_app(context.connected)
async def run_testbed(context):
setup_ci()
setup_sdk()
setup_testbed()
@ -533,6 +649,12 @@ async def run_testbed(context):
except* MySystemExit as e:
raise SystemExit(*e.exceptions[0].args) from None
except* CalledProcessError as e:
# If Python produced no output, then the user probably wants to see the
# verbose output to explain why the test failed.
if not python_started:
for stream, line in hidden_output:
stream.write(line)
# Extract it from the ExceptionGroup so it can be handled by `main`.
raise e.exceptions[0]
@ -597,11 +719,64 @@ def package(context):
else:
shutil.copy2(src, dst, follow_symlinks=False)
# Strip debug information.
if not context.debug:
so_files = glob(f"{temp_dir}/**/*.so", recursive=True)
run([android_env(context.host)["STRIP"], *so_files], log=False)
dist_dir = subdir(context.host, "dist", create=True)
package_path = shutil.make_archive(
f"{dist_dir}/python-{version}-{context.host}", "gztar", temp_dir
)
print(f"Wrote {package_path}")
return package_path
def ci(context):
for step in [
configure_build_python,
make_build_python,
configure_host_python,
make_host_python,
package,
]:
caption = (
step.__name__.replace("_", " ")
.capitalize()
.replace("python", "Python")
)
print(f"::group::{caption}")
result = step(context)
if step is package:
package_path = result
print("::endgroup::")
if (
"GITHUB_ACTIONS" in os.environ
and (platform.system(), platform.machine()) != ("Linux", "x86_64")
):
print(
"Skipping tests: GitHub Actions does not support the Android "
"emulator on this platform."
)
else:
with TemporaryDirectory(prefix=SCRIPT_NAME) as temp_dir:
print("::group::Tests")
# Prove the package is self-contained by using it to run the tests.
shutil.unpack_archive(package_path, temp_dir)
launcher_args = [
"--managed", "maxVersion", "-v", f"--{context.ci_mode}-ci"
]
run(
["./android.py", "test", *launcher_args],
cwd=temp_dir
)
print("::endgroup::")
def env(context):
print_env(android_env(getattr(context, "host", None)))
# Handle SIGTERM the same way as SIGINT. This ensures that if we're terminated
@ -615,45 +790,54 @@ def signal_handler(*args):
def parse_args():
parser = argparse.ArgumentParser()
subcommands = parser.add_subparsers(dest="subcommand")
subcommands = parser.add_subparsers(dest="subcommand", required=True)
def add_parser(*args, **kwargs):
parser = subcommands.add_parser(*args, **kwargs)
parser.add_argument(
"-v", "--verbose", action="count", default=0,
help="Show verbose output. Use twice to be even more verbose.")
return parser
# Subcommands
build = subcommands.add_parser("build", help="Build everything")
configure_build = subcommands.add_parser("configure-build",
help="Run `configure` for the "
"build Python")
make_build = subcommands.add_parser("make-build",
help="Run `make` for the build Python")
configure_host = subcommands.add_parser("configure-host",
help="Run `configure` for Android")
make_host = subcommands.add_parser("make-host",
help="Run `make` for Android")
subcommands.add_parser(
"clean", help="Delete all build and prefix directories")
subcommands.add_parser(
"build-testbed", help="Build the testbed app")
test = subcommands.add_parser(
"test", help="Run the test suite")
package = subcommands.add_parser("package", help="Make a release package")
build = add_parser(
"build", help="Run configure-build, make-build, configure-host and "
"make-host")
configure_build = add_parser(
"configure-build", help="Run `configure` for the build Python")
add_parser(
"make-build", help="Run `make` for the build Python")
configure_host = add_parser(
"configure-host", help="Run `configure` for Android")
make_host = add_parser(
"make-host", help="Run `make` for Android")
add_parser("clean", help="Delete all build directories")
add_parser("build-testbed", help="Build the testbed app")
test = add_parser("test", help="Run the testbed app")
package = add_parser("package", help="Make a release package")
ci = add_parser("ci", help="Run build, package and test")
env = add_parser("env", help="Print environment variables")
# Common arguments
for subcommand in build, configure_build, configure_host:
for subcommand in [build, configure_build, configure_host, ci]:
subcommand.add_argument(
"--clean", action="store_true", default=False, dest="clean",
help="Delete the relevant build and prefix directories first")
for subcommand in [build, configure_host, make_host, package]:
help="Delete the relevant build directories first")
host_commands = [build, configure_host, make_host, package, ci]
if in_source_tree:
host_commands.append(env)
for subcommand in host_commands:
subcommand.add_argument(
"host", metavar="HOST", choices=HOSTS,
help="Host triplet: choices=[%(choices)s]")
for subcommand in build, configure_build, configure_host:
for subcommand in [build, configure_build, configure_host, ci]:
subcommand.add_argument("args", nargs="*",
help="Extra arguments to pass to `configure`")
# Test arguments
test.add_argument(
"-v", "--verbose", action="count", default=0,
help="Show Gradle output, and non-Python logcat messages. "
"Use twice to include high-volume messages which are rarely useful.")
device_group = test.add_mutually_exclusive_group(required=True)
device_group.add_argument(
"--connected", metavar="SERIAL", help="Run on a connected device. "
@ -661,9 +845,34 @@ def parse_args():
device_group.add_argument(
"--managed", metavar="NAME", help="Run on a Gradle-managed device. "
"These are defined in `managedDevices` in testbed/app/build.gradle.kts.")
test.add_argument(
"args", nargs="*", help=f"Arguments for `python -m test`. "
f"Separate them from {SCRIPT_NAME}'s own arguments with `--`.")
"--site-packages", metavar="DIR", type=abspath,
help="Directory to copy as the app's site-packages.")
test.add_argument(
"--cwd", metavar="DIR", type=abspath,
help="Directory to copy as the app's working directory.")
test.add_argument(
"args", nargs="*", help=f"Python command-line arguments. "
f"Separate them from {SCRIPT_NAME}'s own arguments with `--`. "
f"If neither -c nor -m are included, `-m test` will be prepended, "
f"which will run Python's own test suite.")
# Package arguments.
for subcommand in [package, ci]:
subcommand.add_argument(
"-g", action="store_true", default=False, dest="debug",
help="Include debug information in package")
# CI arguments
for subcommand in [test, ci]:
group = subcommand.add_mutually_exclusive_group(required=subcommand is ci)
group.add_argument(
"--fast-ci", action="store_const", dest="ci_mode", const="fast",
help="Add test arguments for GitHub Actions")
group.add_argument(
"--slow-ci", action="store_const", dest="ci_mode", const="slow",
help="Add test arguments for buildbots")
return parser.parse_args()
@ -688,6 +897,8 @@ def main():
"build-testbed": build_testbed,
"test": run_testbed,
"package": package,
"ci": ci,
"env": env,
}
try:
@ -702,20 +913,17 @@ def main():
def print_called_process_error(e):
for stream_name in ["stdout", "stderr"]:
content = getattr(e, stream_name)
if isinstance(content, bytes):
content = content.decode(*DECODE_ARGS)
stream = getattr(sys, stream_name)
if content:
stream.write(content)
if not content.endswith("\n"):
stream.write("\n")
# Format the command so it can be copied into a shell. shlex uses single
# quotes, so we surround the whole command with double quotes.
args_joined = (
e.cmd if isinstance(e.cmd, str)
else " ".join(shlex.quote(str(arg)) for arg in e.cmd)
)
# shlex uses single quotes, so we surround the command with double quotes.
print(
f'Command "{args_joined}" returned exit status {e.returncode}'
f'Command "{join_command(e.cmd)}" returned exit status {e.returncode}'
)

View file

@ -47,7 +47,7 @@ for ((i, prefix) in prefixes.withIndex()) {
val libDir = file("$prefix/lib")
val version = run {
for (filename in libDir.list()!!) {
"""python(\d+\.\d+)""".toRegex().matchEntire(filename)?.let {
"""python(\d+\.\d+[a-z]*)""".toRegex().matchEntire(filename)?.let {
return@run it.groupValues[1]
}
}
@ -64,9 +64,10 @@ for ((i, prefix) in prefixes.withIndex()) {
val libPythonDir = file("$libDir/python$pythonVersion")
val triplet = run {
for (filename in libPythonDir.list()!!) {
"""_sysconfigdata__android_(.+).py""".toRegex().matchEntire(filename)?.let {
return@run it.groupValues[1]
}
"""_sysconfigdata_[a-z]*_android_(.+).py""".toRegex()
.matchEntire(filename)?.let {
return@run it.groupValues[1]
}
}
throw GradleException("Failed to find Python triplet in $libPythonDir")
}
@ -78,20 +79,20 @@ android {
val androidEnvFile = file("../../android-env.sh").absoluteFile
namespace = "org.python.testbed"
compileSdk = 34
compileSdk = 35
defaultConfig {
applicationId = "org.python.testbed"
minSdk = androidEnvFile.useLines {
for (line in it) {
"""api_level:=(\d+)""".toRegex().find(line)?.let {
"""ANDROID_API_LEVEL:=(\d+)""".toRegex().find(line)?.let {
return@useLines it.groupValues[1].toInt()
}
}
throw GradleException("Failed to find API level in $androidEnvFile")
}
targetSdk = 34
targetSdk = 35
versionCode = 1
versionName = "1.0"
@ -205,11 +206,29 @@ androidComponents.onVariants { variant ->
into("site-packages") {
from("$projectDir/src/main/python")
val sitePackages = findProperty("python.sitePackages") as String?
if (!sitePackages.isNullOrEmpty()) {
if (!file(sitePackages).exists()) {
throw GradleException("$sitePackages does not exist")
}
from(sitePackages)
}
}
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
exclude("**/__pycache__")
}
into("cwd") {
val cwd = findProperty("python.cwd") as String?
if (!cwd.isNullOrEmpty()) {
if (!file(cwd).exists()) {
throw GradleException("$cwd does not exist")
}
from(cwd)
}
}
}
}

View file

@ -17,11 +17,11 @@ class PythonSuite {
fun testPython() {
val start = System.currentTimeMillis()
try {
val context =
val status = PythonTestRunner(
InstrumentationRegistry.getInstrumentation().targetContext
val args =
InstrumentationRegistry.getArguments().getString("pythonArgs", "")
val status = PythonTestRunner(context).run(args)
).run(
InstrumentationRegistry.getArguments().getString("pythonArgs")!!,
)
assertEquals(0, status)
} finally {
// Make sure the process lives long enough for the test script to

View file

@ -3,6 +3,7 @@
#include <jni.h>
#include <pthread.h>
#include <Python.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
@ -15,6 +16,13 @@ static void throw_runtime_exception(JNIEnv *env, const char *message) {
message);
}
static void throw_errno(JNIEnv *env, const char *error_prefix) {
char error_message[1024];
snprintf(error_message, sizeof(error_message),
"%s: %s", error_prefix, strerror(errno));
throw_runtime_exception(env, error_message);
}
// --- Stdio redirection ------------------------------------------------------
@ -95,10 +103,7 @@ JNIEXPORT void JNICALL Java_org_python_testbed_PythonTestRunner_redirectStdioToL
for (StreamInfo *si = STREAMS; si->file; si++) {
char *error_prefix;
if ((error_prefix = redirect_stream(si))) {
char error_message[1024];
snprintf(error_message, sizeof(error_message),
"%s: %s", error_prefix, strerror(errno));
throw_runtime_exception(env, error_message);
throw_errno(env, error_prefix);
return;
}
}
@ -107,13 +112,38 @@ JNIEXPORT void JNICALL Java_org_python_testbed_PythonTestRunner_redirectStdioToL
// --- Python initialization ---------------------------------------------------
static PyStatus set_config_string(
JNIEnv *env, PyConfig *config, wchar_t **config_str, jstring value
) {
const char *value_utf8 = (*env)->GetStringUTFChars(env, value, NULL);
PyStatus status = PyConfig_SetBytesString(config, config_str, value_utf8);
(*env)->ReleaseStringUTFChars(env, value, value_utf8);
return status;
static char *init_signals() {
// Some tests use SIGUSR1, but that's blocked by default in an Android app in
// order to make it available to `sigwait` in the Signal Catcher thread.
// (https://cs.android.com/android/platform/superproject/+/android14-qpr3-release:art/runtime/signal_catcher.cc).
// That thread's functionality is only useful for debugging the JVM, so disabling
// it should not weaken the tests.
//
// There's no safe way of stopping the thread completely (#123982), but simply
// unblocking SIGUSR1 is enough to fix most tests.
//
// However, in tests that generate multiple different signals in quick
// succession, it's possible for SIGUSR1 to arrive while the main thread is busy
// running the C-level handler for a different signal. In that case, the SIGUSR1
// may be sent to the Signal Catcher thread instead, which will generate a log
// message containing the text "reacting to signal".
//
// Such tests may need to be changed in one of the following ways:
// * Use a signal other than SIGUSR1 (e.g. test_stress_delivery_simultaneous in
// test_signal.py).
// * Send the signal to a specific thread rather than the whole process (e.g.
// test_signals in test_threadsignals.py.
sigset_t set;
if (sigemptyset(&set)) {
return "sigemptyset";
}
if (sigaddset(&set, SIGUSR1)) {
return "sigaddset";
}
if ((errno = pthread_sigmask(SIG_UNBLOCK, &set, NULL))) {
return "pthread_sigmask";
}
return NULL;
}
static void throw_status(JNIEnv *env, PyStatus status) {
@ -121,27 +151,47 @@ static void throw_status(JNIEnv *env, PyStatus status) {
}
JNIEXPORT int JNICALL Java_org_python_testbed_PythonTestRunner_runPython(
JNIEnv *env, jobject obj, jstring home, jstring runModule
JNIEnv *env, jobject obj, jstring home, jarray args
) {
const char *home_utf8 = (*env)->GetStringUTFChars(env, home, NULL);
char cwd[PATH_MAX];
snprintf(cwd, sizeof(cwd), "%s/%s", home_utf8, "cwd");
if (chdir(cwd)) {
throw_errno(env, "chdir");
return 1;
}
char *error_prefix;
if ((error_prefix = init_signals())) {
throw_errno(env, error_prefix);
return 1;
}
PyConfig config;
PyStatus status;
PyConfig_InitIsolatedConfig(&config);
PyConfig_InitPythonConfig(&config);
status = set_config_string(env, &config, &config.home, home);
if (PyStatus_Exception(status)) {
jsize argc = (*env)->GetArrayLength(env, args);
const char *argv[argc + 1];
for (int i = 0; i < argc; i++) {
jobject arg = (*env)->GetObjectArrayElement(env, args, i);
argv[i] = (*env)->GetStringUTFChars(env, arg, NULL);
}
argv[argc] = NULL;
// PyConfig_SetBytesArgv "must be called before other methods, since the
// preinitialization configuration depends on command line arguments"
if (PyStatus_Exception(status = PyConfig_SetBytesArgv(&config, argc, (char**)argv))) {
throw_status(env, status);
return 1;
}
status = set_config_string(env, &config, &config.run_module, runModule);
status = PyConfig_SetBytesString(&config, &config.home, home_utf8);
if (PyStatus_Exception(status)) {
throw_status(env, status);
return 1;
}
// Some tests generate SIGPIPE and SIGXFSZ, which should be ignored.
config.install_signal_handlers = 1;
status = Py_InitializeFromConfig(&config);
if (PyStatus_Exception(status)) {
throw_status(env, status);

View file

@ -5,6 +5,7 @@ import android.os.*
import android.system.Os
import android.widget.TextView
import androidx.appcompat.app.*
import org.json.JSONArray
import java.io.*
@ -15,18 +16,25 @@ class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val status = PythonTestRunner(this).run("-W -uall")
val status = PythonTestRunner(this).run("""["-m", "test", "-W", "-uall"]""")
findViewById<TextView>(R.id.tvHello).text = "Exit status $status"
}
}
class PythonTestRunner(val context: Context) {
/** @param args Extra arguments for `python -m test`.
* @return The Python exit status: zero if the tests passed, nonzero if
* they failed. */
fun run(args: String = "") : Int {
Os.setenv("PYTHON_ARGS", args, true)
/** Run Python.
*
* @param args Python command-line, encoded as JSON.
* @return The Python exit status: zero on success, nonzero on failure. */
fun run(args: String) : Int {
// We leave argument 0 as an empty string, which is a placeholder for the
// executable name in embedded mode.
val argsJsonArray = JSONArray(args)
val argsStringArray = Array<String>(argsJsonArray.length() + 1) { it -> ""}
for (i in 0..<argsJsonArray.length()) {
argsStringArray[i + 1] = argsJsonArray.getString(i)
}
// Python needs this variable to help it find the temporary directory,
// but Android only sets it on API level 33 and later.
@ -35,9 +43,7 @@ class PythonTestRunner(val context: Context) {
val pythonHome = extractAssets()
System.loadLibrary("main_activity")
redirectStdioToLogcat()
// The main module is in src/main/python/main.py.
return runPython(pythonHome.toString(), "main")
return runPython(pythonHome.toString(), argsStringArray)
}
private fun extractAssets() : File {
@ -46,6 +52,13 @@ class PythonTestRunner(val context: Context) {
throw RuntimeException("Failed to delete $pythonHome")
}
extractAssetDir("python", context.filesDir)
// Empty directories are lost in the asset packing/unpacking process.
val cwd = File(pythonHome, "cwd")
if (!cwd.exists()) {
cwd.mkdir()
}
return pythonHome
}
@ -75,5 +88,5 @@ class PythonTestRunner(val context: Context) {
}
private external fun redirectStdioToLogcat()
private external fun runPython(home: String, runModule: String) : Int
private external fun runPython(home: String, args: Array<String>) : Int
}

View file

@ -1,32 +0,0 @@
import os
import runpy
import shlex
import signal
import sys
# Some tests use SIGUSR1, but that's blocked by default in an Android app in
# order to make it available to `sigwait` in the Signal Catcher thread.
# (https://cs.android.com/android/platform/superproject/+/android14-qpr3-release:art/runtime/signal_catcher.cc).
# That thread's functionality is only useful for debugging the JVM, so disabling
# it should not weaken the tests.
#
# There's no safe way of stopping the thread completely (#123982), but simply
# unblocking SIGUSR1 is enough to fix most tests.
#
# However, in tests that generate multiple different signals in quick
# succession, it's possible for SIGUSR1 to arrive while the main thread is busy
# running the C-level handler for a different signal. In that case, the SIGUSR1
# may be sent to the Signal Catcher thread instead, which will generate a log
# message containing the text "reacting to signal".
#
# Such tests may need to be changed in one of the following ways:
# * Use a signal other than SIGUSR1 (e.g. test_stress_delivery_simultaneous in
# test_signal.py).
# * Send the signal to a specific thread rather than the whole process (e.g.
# test_signals in test_threadsignals.py.
signal.pthread_sigmask(signal.SIG_UNBLOCK, [signal.SIGUSR1])
sys.argv[1:] = shlex.split(os.environ["PYTHON_ARGS"])
# The test module will call sys.exit to indicate whether the tests passed.
runpy.run_module("test")

View file

@ -1,5 +1,5 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id("com.android.application") version "8.6.1" apply false
id("com.android.application") version "8.10.0" apply false
id("org.jetbrains.kotlin.android") version "1.9.22" apply false
}

View file

@ -1,6 +1,6 @@
#Mon Feb 19 20:29:06 GMT 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

22
Apple/.ruff.toml Normal file
View file

@ -0,0 +1,22 @@
extend = "../.ruff.toml" # Inherit the project-wide settings
[format]
preview = true
docstring-code-format = true
[lint]
select = [
"C4", # flake8-comprehensions
"E", # pycodestyle
"F", # pyflakes
"I", # isort
"ISC", # flake8-implicit-str-concat
"LOG", # flake8-logging
"PGH", # pygrep-hooks
"PT", # flake8-pytest-style
"PYI", # flake8-pyi
"RUF100", # Ban unused `# noqa` comments
"UP", # pyupgrade
"W", # pycodestyle
"YTT", # flake8-2020
]

1065
Apple/__main__.py Normal file

File diff suppressed because it is too large Load diff

339
Apple/iOS/README.md Normal file
View file

@ -0,0 +1,339 @@
# Python on iOS README
**iOS support is [tier 3](https://peps.python.org/pep-0011/#tier-3).**
This document provides a quick overview of some iOS specific features in the
Python distribution.
These instructions are only needed if you're planning to compile Python for iOS
yourself. Most users should *not* need to do this. If you're looking to
experiment with writing an iOS app in Python, tools such as [BeeWare's
Briefcase](https://briefcase.readthedocs.io) and [Kivy's
Buildozer](https://buildozer.readthedocs.io) will provide a much more
approachable user experience.
## Compilers for building on iOS
Building for iOS requires the use of Apple's Xcode tooling. It is strongly
recommended that you use the most recent stable release of Xcode. This will
require the use of the most (or second-most) recently released macOS version,
as Apple does not maintain Xcode for older macOS versions. The Xcode Command
Line Tools are not sufficient for iOS development; you need a *full* Xcode
install.
If you want to run your code on the iOS simulator, you'll also need to install
an iOS Simulator Platform. You should be prompted to select an iOS Simulator
Platform when you first run Xcode. Alternatively, you can add an iOS Simulator
Platform by selecting an open the Platforms tab of the Xcode Settings panel.
## Building Python on iOS
### ABIs and Architectures
iOS apps can be deployed on physical devices, and on the iOS simulator. Although
the API used on these devices is identical, the ABI is different - you need to
link against different libraries for an iOS device build (`iphoneos`) or an
iOS simulator build (`iphonesimulator`).
Apple uses the `XCframework` format to allow specifying a single dependency
that supports multiple ABIs. An `XCframework` is a wrapper around multiple
ABI-specific frameworks that share a common API.
iOS can also support different CPU architectures within each ABI. At present,
there is only a single supported architecture on physical devices - ARM64.
However, the *simulator* supports 2 architectures - ARM64 (for running on Apple
Silicon machines), and x86_64 (for running on older Intel-based machines).
To support multiple CPU architectures on a single platform, Apple uses a "fat
binary" format - a single physical file that contains support for multiple
architectures. It is possible to compile and use a "thin" single architecture
version of a binary for testing purposes; however, the "thin" binary will not be
portable to machines using other architectures.
### Building a multi-architecture iOS XCframework
The `Apple` subfolder of the Python repository acts as a build script that
can be used to coordinate the compilation of a complete iOS XCframework. To use
it, run::
python Apple build iOS
This will:
* Configure and compile a version of Python to run on the build machine
* Download pre-compiled binary dependencies for each platform
* Configure and build a `Python.framework` for each required architecture and
iOS SDK
* Merge the multiple `Python.framework` folders into a single `Python.xcframework`
* Produce a `.tar.gz` archive in the `cross-build/dist` folder containing
the `Python.xcframework`, plus a copy of the Testbed app pre-configured to
use the XCframework.
The `Apple` build script has other entry points that will perform the
individual parts of the overall `build` target, plus targets to test the
build, clean the `cross-build` folder of iOS build products, and perform a
complete "build and test" CI run. The `--clean` flag can also be used on
individual commands to ensure that a stale build product are removed before
building.
### Building a single-architecture framework
If you're using the `Apple` build script, you won't need to build
individual frameworks. However, if you do need to manually configure an iOS
Python build for a single framework, the following options are available.
#### iOS specific arguments to configure
* `--enable-framework[=DIR]`
This argument specifies the location where the Python.framework will be
installed. If `DIR` is not specified, the framework will be installed into
a subdirectory of the `iOS/Frameworks` folder.
This argument *must* be provided when configuring iOS builds. iOS does not
support non-framework builds.
* `--with-framework-name=NAME`
Specify the name for the Python framework; defaults to `Python`.
> [!NOTE]
> Unless you know what you're doing, changing the name of the Python
> framework on iOS is not advised. If you use this option, you won't be able
> to run the `Apple` build script without making significant manual
> alterations, and you won't be able to use any binary packages unless you
> compile them yourself using your own framework name.
#### Building Python for iOS
The Python build system will create a `Python.framework` that supports a
*single* ABI with a *single* architecture. Unlike macOS, iOS does not allow a
framework to contain non-library content, so the iOS build will produce a
`bin` and `lib` folder in the same output folder as `Python.framework`.
The `lib` folder will be needed at runtime to support the Python library.
If you want to use Python in a real iOS project, you need to produce multiple
`Python.framework` builds, one for each ABI and architecture. iOS builds of
Python *must* be constructed as framework builds. To support this, you must
provide the `--enable-framework` flag when configuring the build. The build
also requires the use of cross-compilation. The minimal commands for building
Python for the ARM64 iOS simulator will look something like:
```
export PATH="$(pwd)/Apple/iOS/Resources/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin"
./configure \
--enable-framework \
--host=arm64-apple-ios-simulator \
--build=arm64-apple-darwin \
--with-build-python=/path/to/python.exe
make
make install
```
In this invocation:
* `Apple/iOS/Resources/bin` has been added to the path, providing some shims for the
compilers and linkers needed by the build. Xcode requires the use of `xcrun`
to invoke compiler tooling. However, if `xcrun` is pre-evaluated and the
result passed to `configure`, these results can embed user- and
version-specific paths into the sysconfig data, which limits the portability
of the compiled Python. Alternatively, if `xcrun` is used *as* the compiler,
it requires that compiler variables like `CC` include spaces, which can
cause significant problems with many C configuration systems which assume that
`CC` will be a single executable.
To work around this problem, the `Apple/iOS/Resources/bin` folder contains some
wrapper scripts that present as simple compilers and linkers, but wrap
underlying calls to `xcrun`. This allows configure to use a `CC`
definition without spaces, and without user- or version-specific paths, while
retaining the ability to adapt to the local Xcode install. These scripts are
included in the `bin` directory of an iOS install.
These scripts will, by default, use the currently active Xcode installation.
If you want to use a different Xcode installation, you can use
`xcode-select` to set a new default Xcode globally, or you can use the
`DEVELOPER_DIR` environment variable to specify an Xcode install. The
scripts will use the default `iphoneos`/`iphonesimulator` SDK version for
the select Xcode install; if you want to use a different SDK, you can set the
`IOS_SDK_VERSION` environment variable. (e.g, setting
`IOS_SDK_VERSION=17.1` would cause the scripts to use the `iphoneos17.1`
and `iphonesimulator17.1` SDKs, regardless of the Xcode default.)
The path has also been cleared of any user customizations. A common source of
bugs is for tools like Homebrew to accidentally leak macOS binaries into an iOS
build. Resetting the path to a known "bare bones" value is the easiest way to
avoid these problems.
* `--host` is the architecture and ABI that you want to build, in GNU compiler
triple format. This will be one of:
- `arm64-apple-ios` for ARM64 iOS devices.
- `arm64-apple-ios-simulator` for the iOS simulator running on Apple
Silicon devices.
- `x86_64-apple-ios-simulator` for the iOS simulator running on Intel
devices.
* `--build` is the GNU compiler triple for the machine that will be running
the compiler. This is one of:
- `arm64-apple-darwin` for Apple Silicon devices.
- `x86_64-apple-darwin` for Intel devices.
* `/path/to/python.exe` is the path to a Python binary on the machine that
will be running the compiler. This is needed because the Python compilation
process involves running some Python code. On a normal desktop build of
Python, you can compile a python interpreter and then use that interpreter to
run Python code. However, the binaries produced for iOS won't run on macOS, so
you need to provide an external Python interpreter. This interpreter must be
the same version as the Python that is being compiled. To be completely safe,
this should be the *exact* same commit hash. However, the longer a Python
release has been stable, the more likely it is that this constraint can be
relaxed - the same micro version will often be sufficient.
* The `install` target for iOS builds is slightly different to other
platforms. On most platforms, `make install` will install the build into
the final runtime location. This won't be the case for iOS, as the final
runtime location will be on a physical device.
However, you still need to run the `install` target for iOS builds, as it
performs some final framework assembly steps. The location specified with
`--enable-framework` will be the location where `make install` will
assemble the complete iOS framework. This completed framework can then
be copied and relocated as required.
For a full CPython build, you also need to specify the paths to iOS builds of
the binary libraries that CPython depends on (such as XZ, LibFFI and OpenSSL).
This can be done by defining library specific environment variables (such as
`LIBLZMA_CFLAGS`, `LIBLZMA_LIBS`), and the `--with-openssl` configure
option. Versions of these libraries pre-compiled for iOS can be found in [this
repository](https://github.com/beeware/cpython-apple-source-deps/releases).
LibFFI is especially important, as many parts of the standard library
(including the `platform`, `sysconfig` and `webbrowser` modules) require
the use of the `ctypes` module at runtime.
By default, Python will be compiled with an iOS deployment target (i.e., the
minimum supported iOS version) of 13.0. To specify a different deployment
target, provide the version number as part of the `--host` argument - for
example, `--host=arm64-apple-ios15.4-simulator` would compile an ARM64
simulator build with a deployment target of 15.4.
## Testing Python on iOS
### Testing a multi-architecture framework
Once you have a built an XCframework, you can test that framework by running:
$ python Apple test iOS
This test will attempt to find an "SE-class" simulator (i.e., an iPhone SE, or
iPhone 16e, or similar), and run the test suite on the most recent version of
iOS that is available. You can specify a simulator using the `--simulator`
command line argument, providing the name of the simulator (e.g., `--simulator
'iPhone 16 Pro'`). You can also use this argument to control the OS version used
for testing; `--simulator 'iPhone 16 Pro,OS=18.2'` would attempt to run the
tests on an iPhone 16 Pro running iOS 18.2.
If the test runner is executed on GitHub Actions, the `GITHUB_ACTIONS`
environment variable will be exposed to the iOS process at runtime.
### Testing a single-architecture framework
The `Apple/testbed` folder that contains an Xcode project that is able to run
the Python test suite on Apple platforms. This project converts the Python test
suite into a single test case in Xcode's XCTest framework. The single XCTest
passes if the test suite passes.
To run the test suite, configure a Python build for an iOS simulator (i.e.,
`--host=arm64-apple-ios-simulator` or `--host=x86_64-apple-ios-simulator`
), specifying a framework build (i.e. `--enable-framework`). Ensure that your
`PATH` has been configured to include the `Apple/iOS/Resources/bin` folder and
exclude any non-iOS tools, then run:
```
make all
make install
make testios
```
This will:
* Build an iOS framework for your chosen architecture;
* Finalize the single-platform framework;
* Make a clean copy of the testbed project;
* Install the Python iOS framework into the copy of the testbed project; and
* Run the test suite on an "entry-level device" simulator (i.e., an iPhone SE,
iPhone 16e, or a similar).
On success, the test suite will exit and report successful completion of the
test suite. On a 2022 M1 MacBook Pro, the test suite takes approximately 15
minutes to run; a couple of extra minutes is required to compile the testbed
project, and then boot and prepare the iOS simulator.
### Debugging test failures
Running `python Apple test iOS` generates a standalone version of the
`Apple/testbed` project, and runs the full test suite. It does this using
`Apple/testbed` itself - the folder is an executable module that can be used
to create and run a clone of the testbed project. The standalone version of the
testbed will be created in a directory named
`cross-build/iOS-testbed.<timestamp>`.
You can generate your own standalone testbed instance by running:
```
python cross-build/iOS/testbed clone my-testbed
```
In this invocation, `my-testbed` is the name of the folder for the new
testbed clone.
If you've built your own XCframework, or you only want to test a single architecture,
you can construct a standalone testbed instance by running:
```
python Apple/testbed clone --platform iOS --framework <path/to/framework> my-testbed
```
The framework path can be the path path to a `Python.xcframework`, or the
path to a folder that contains a single-platform `Python.framework`.
You can then use the `my-testbed` folder to run the Python test suite,
passing in any command line arguments you may require. For example, if you're
trying to diagnose a failure in the `os` module, you might run:
```
python my-testbed run -- test -W test_os
```
This is the equivalent of running `python -m test -W test_os` on a desktop
Python build. Any arguments after the `--` will be passed to testbed as if
they were arguments to `python -m` on a desktop machine.
### Testing in Xcode
You can also open the testbed project in Xcode by running:
```
open my-testbed/iOSTestbed.xcodeproj
```
This will allow you to use the full Xcode suite of tools for debugging.
The arguments used to run the test suite are defined as part of the test plan.
To modify the test plan, select the test plan node of the project tree (it
should be the first child of the root node), and select the "Configurations"
tab. Modify the "Arguments Passed On Launch" value to change the testing
arguments.
The test plan also disables parallel testing, and specifies the use of the
`Testbed.lldbinit` file for providing configuration of the debugger. The
default debugger configuration disables automatic breakpoints on the
`SIGINT`, `SIGUSR1`, `SIGUSR2`, and `SIGXFSZ` signals.
### Testing on an iOS device
To test on an iOS device, the app needs to be signed with known developer
credentials. To obtain these credentials, you must have an iOS Developer
account, and your Xcode install will need to be logged into your account (see
the Accounts tab of the Preferences dialog).
Once the project is open, and you're signed into your Apple Developer account,
select the root node of the project tree (labeled "iOSTestbed"), then the
"Signing & Capabilities" tab in the details page. Select a development team
(this will likely be your own name), and plug in a physical device to your
macOS machine with a USB cable. You should then be able to select your physical
device from the list of targets in the pulldown in the Xcode titlebar.

View file

@ -0,0 +1,2 @@
#!/bin/sh
xcrun --sdk iphoneos${IOS_SDK_VERSION} ar "$@"

View file

@ -0,0 +1,2 @@
#!/bin/sh
xcrun --sdk iphoneos${IOS_SDK_VERSION} clang -target arm64-apple-ios${IPHONEOS_DEPLOYMENT_TARGET} "$@"

View file

@ -0,0 +1,2 @@
#!/bin/sh
xcrun --sdk iphoneos${IOS_SDK_VERSION} clang++ -target arm64-apple-ios${IPHONEOS_DEPLOYMENT_TARGET} "$@"

View file

@ -0,0 +1,2 @@
#!/bin/sh
xcrun --sdk iphoneos${IOS_SDK_VERSION} clang -target arm64-apple-ios${IPHONEOS_DEPLOYMENT_TARGET} -E "$@"

View file

@ -0,0 +1,2 @@
#!/bin/sh
xcrun --sdk iphonesimulator${IOS_SDK_VERSION} ar "$@"

View file

@ -0,0 +1,2 @@
#!/bin/sh
xcrun --sdk iphonesimulator${IOS_SDK_VERSION} clang -target arm64-apple-ios${IPHONEOS_DEPLOYMENT_TARGET}-simulator "$@"

View file

@ -0,0 +1,2 @@
#!/bin/sh
xcrun --sdk iphonesimulator${IOS_SDK_VERSION} clang++ -target arm64-apple-ios${IPHONEOS_DEPLOYMENT_TARGET}-simulator "$@"

View file

@ -0,0 +1,2 @@
#!/bin/sh
xcrun --sdk iphonesimulator${IOS_SDK_VERSION} clang -target arm64-apple-ios${IPHONEOS_DEPLOYMENT_TARGET}-simulator -E "$@"

View file

@ -0,0 +1,2 @@
#!/bin/sh
xcrun --sdk iphonesimulator${IOS_SDK_VERSION} strip -arch arm64 "$@"

View file

@ -0,0 +1,2 @@
#!/bin/sh
xcrun --sdk iphoneos${IOS_SDK_VERSION} strip -arch arm64 "$@"

View file

@ -0,0 +1,2 @@
#!/bin/sh
xcrun --sdk iphonesimulator${IOS_SDK_VERSION} ar "$@"

View file

@ -0,0 +1,2 @@
#!/bin/sh
xcrun --sdk iphonesimulator${IOS_SDK_VERSION} clang -target x86_64-apple-ios${IPHONEOS_DEPLOYMENT_TARGET}-simulator "$@"

View file

@ -0,0 +1,2 @@
#!/bin/sh
xcrun --sdk iphonesimulator${IOS_SDK_VERSION} clang++ -target x86_64-apple-ios${IPHONEOS_DEPLOYMENT_TARGET}-simulator "$@"

View file

@ -0,0 +1,2 @@
#!/bin/sh
xcrun --sdk iphonesimulator${IOS_SDK_VERSION} clang -target x86_64-apple-ios${IPHONEOS_DEPLOYMENT_TARGET}-simulator -E "$@"

View file

@ -0,0 +1,2 @@
#!/bin/sh
xcrun --sdk iphonesimulator${IOS_SDK_VERSION} strip -arch x86_64 "$@"

View file

@ -19,7 +19,7 @@
<string>iPhoneOS</string>
</array>
<key>MinimumOSVersion</key>
<string>12.0</string>
<string>13.0</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>

View file

@ -0,0 +1,151 @@
# Utility methods for use in an Xcode project.
#
# An iOS XCframework cannot include any content other than the library binary
# and relevant metadata. However, Python requires a standard library at runtime.
# Therefore, it is necessary to add a build step to an Xcode app target that
# processes the standard library and puts the content into the final app.
#
# In general, these tools will be invoked after bundle resources have been
# copied into the app, but before framework embedding (and signing).
#
# The following is an example script, assuming that:
# * Python.xcframework is in the root of the project
# * There is an `app` folder that contains the app code
# * There is an `app_packages` folder that contains installed Python packages.
# -----
# set -e
# source $PROJECT_DIR/Python.xcframework/build/build_utils.sh
# install_python Python.xcframework app app_packages
# -----
# Copy the standard library from the XCframework into the app bundle.
#
# Accepts one argument:
# 1. The path, relative to the root of the Xcode project, where the Python
# XCframework can be found.
install_stdlib() {
PYTHON_XCFRAMEWORK_PATH=$1
mkdir -p "$CODESIGNING_FOLDER_PATH/python/lib"
if [ "$EFFECTIVE_PLATFORM_NAME" = "-iphonesimulator" ]; then
echo "Installing Python modules for iOS Simulator"
if [ -d "$PROJECT_DIR/$PYTHON_XCFRAMEWORK_PATH/ios-arm64-simulator" ]; then
SLICE_FOLDER="ios-arm64-simulator"
else
SLICE_FOLDER="ios-arm64_x86_64-simulator"
fi
else
echo "Installing Python modules for iOS Device"
SLICE_FOLDER="ios-arm64"
fi
# If the XCframework has a shared lib folder, then it's a full framework.
# Copy both the common and slice-specific part of the lib directory.
# Otherwise, it's a single-arch framework; use the "full" lib folder.
if [ -d "$PROJECT_DIR/$PYTHON_XCFRAMEWORK_PATH/lib" ]; then
rsync -au --delete "$PROJECT_DIR/$PYTHON_XCFRAMEWORK_PATH/lib/" "$CODESIGNING_FOLDER_PATH/python/lib/"
rsync -au "$PROJECT_DIR/$PYTHON_XCFRAMEWORK_PATH/$SLICE_FOLDER/lib-$ARCHS/" "$CODESIGNING_FOLDER_PATH/python/lib/"
else
# A single-arch framework will have a libpython symlink; that can't be included at runtime
rsync -au --delete "$PROJECT_DIR/$PYTHON_XCFRAMEWORK_PATH/$SLICE_FOLDER/lib/" "$CODESIGNING_FOLDER_PATH/python/lib/" --exclude 'libpython*.dylib'
fi
}
# Convert a single .so library into a framework that iOS can load.
#
# Accepts three arguments:
# 1. The path, relative to the root of the Xcode project, where the Python
# XCframework can be found.
# 2. The base path, relative to the installed location in the app bundle, that
# needs to be processed. Any .so file found in this path (or a subdirectory
# of it) will be processed.
# 2. The full path to a single .so file to process. This path should include
# the base path.
install_dylib () {
PYTHON_XCFRAMEWORK_PATH=$1
INSTALL_BASE=$2
FULL_EXT=$3
# The name of the extension file
EXT=$(basename "$FULL_EXT")
# The name and location of the module
MODULE_PATH=$(dirname "$FULL_EXT")
MODULE_NAME=$(echo $EXT | cut -d "." -f 1)
# The location of the extension file, relative to the bundle
RELATIVE_EXT=${FULL_EXT#$CODESIGNING_FOLDER_PATH/}
# The path to the extension file, relative to the install base
PYTHON_EXT=${RELATIVE_EXT/$INSTALL_BASE/}
# The full dotted name of the extension module, constructed from the file path.
FULL_MODULE_NAME=$(echo $PYTHON_EXT | cut -d "." -f 1 | tr "/" ".");
# A bundle identifier; not actually used, but required by Xcode framework packaging
FRAMEWORK_BUNDLE_ID=$(echo $PRODUCT_BUNDLE_IDENTIFIER.$FULL_MODULE_NAME | tr "_" "-")
# The name of the framework folder.
FRAMEWORK_FOLDER="Frameworks/$FULL_MODULE_NAME.framework"
# If the framework folder doesn't exist, create it.
if [ ! -d "$CODESIGNING_FOLDER_PATH/$FRAMEWORK_FOLDER" ]; then
echo "Creating framework for $RELATIVE_EXT"
mkdir -p "$CODESIGNING_FOLDER_PATH/$FRAMEWORK_FOLDER"
cp "$PROJECT_DIR/$PYTHON_XCFRAMEWORK_PATH/build/$PLATFORM_FAMILY_NAME-dylib-Info-template.plist" "$CODESIGNING_FOLDER_PATH/$FRAMEWORK_FOLDER/Info.plist"
plutil -replace CFBundleExecutable -string "$FULL_MODULE_NAME" "$CODESIGNING_FOLDER_PATH/$FRAMEWORK_FOLDER/Info.plist"
plutil -replace CFBundleIdentifier -string "$FRAMEWORK_BUNDLE_ID" "$CODESIGNING_FOLDER_PATH/$FRAMEWORK_FOLDER/Info.plist"
fi
echo "Installing binary for $FRAMEWORK_FOLDER/$FULL_MODULE_NAME"
mv "$FULL_EXT" "$CODESIGNING_FOLDER_PATH/$FRAMEWORK_FOLDER/$FULL_MODULE_NAME"
# Create a placeholder .fwork file where the .so was
echo "$FRAMEWORK_FOLDER/$FULL_MODULE_NAME" > ${FULL_EXT%.so}.fwork
# Create a back reference to the .so file location in the framework
echo "${RELATIVE_EXT%.so}.fwork" > "$CODESIGNING_FOLDER_PATH/$FRAMEWORK_FOLDER/$FULL_MODULE_NAME.origin"
# If the framework provides an xcprivacy file, install it.
if [ -e "$MODULE_PATH/$MODULE_NAME.xcprivacy" ]; then
echo "Installing XCPrivacy file for $FRAMEWORK_FOLDER/$FULL_MODULE_NAME"
XCPRIVACY_FILE="$CODESIGNING_FOLDER_PATH/$FRAMEWORK_FOLDER/PrivacyInfo.xcprivacy"
if [ -e "$XCPRIVACY_FILE" ]; then
rm -rf "$XCPRIVACY_FILE"
fi
mv "$MODULE_PATH/$MODULE_NAME.xcprivacy" "$XCPRIVACY_FILE"
fi
echo "Signing framework as $EXPANDED_CODE_SIGN_IDENTITY_NAME ($EXPANDED_CODE_SIGN_IDENTITY)..."
/usr/bin/codesign --force --sign "$EXPANDED_CODE_SIGN_IDENTITY" ${OTHER_CODE_SIGN_FLAGS:-} -o runtime --timestamp=none --preserve-metadata=identifier,entitlements,flags --generate-entitlement-der "$CODESIGNING_FOLDER_PATH/$FRAMEWORK_FOLDER"
}
# Process all the dynamic libraries in a path into Framework format.
#
# Accepts two arguments:
# 1. The path, relative to the root of the Xcode project, where the Python
# XCframework can be found.
# 2. The base path, relative to the installed location in the app bundle, that
# needs to be processed. Any .so file found in this path (or a subdirectory
# of it) will be processed.
process_dylibs () {
PYTHON_XCFRAMEWORK_PATH=$1
LIB_PATH=$2
find "$CODESIGNING_FOLDER_PATH/$LIB_PATH" -name "*.so" | while read FULL_EXT; do
install_dylib $PYTHON_XCFRAMEWORK_PATH "$LIB_PATH/" "$FULL_EXT"
done
}
# The entry point for post-processing a Python XCframework.
#
# Accepts 1 or more arguments:
# 1. The path, relative to the root of the Xcode project, where the Python
# XCframework can be found. If the XCframework is in the root of the project,
# 2+. The path of a package, relative to the root of the packaged app, that contains
# library content that should be processed for binary libraries.
install_python() {
PYTHON_XCFRAMEWORK_PATH=$1
shift
install_stdlib $PYTHON_XCFRAMEWORK_PATH
PYTHON_VER=$(ls -1 "$CODESIGNING_FOLDER_PATH/python/lib")
echo "Install Python $PYTHON_VER standard library extension modules..."
process_dylibs $PYTHON_XCFRAMEWORK_PATH python/lib/$PYTHON_VER/lib-dynload
for package_path in $@; do
echo "Installing $package_path extension modules ..."
process_dylibs $PYTHON_XCFRAMEWORK_PATH $package_path
done
}

View file

@ -0,0 +1,4 @@
process handle SIGINT -n true -p true -s false
process handle SIGUSR1 -n true -p true -s false
process handle SIGUSR2 -n true -p true -s false
process handle SIGXFSZ -n true -p true -s false

View file

@ -1,11 +1,11 @@
#import <XCTest/XCTest.h>
#import <Python/Python.h>
@interface iOSTestbedTests : XCTestCase
@interface TestbedTests : XCTestCase
@end
@implementation iOSTestbedTests
@implementation TestbedTests
- (void)testPython {
@ -15,6 +15,11 @@
PyStatus status;
PyPreConfig preconfig;
PyConfig config;
PyObject *app_packages_path;
PyObject *method_args;
PyObject *result;
PyObject *site_module;
PyObject *site_addsitedir_attr;
PyObject *sys_module;
PyObject *sys_path_attr;
NSArray *test_args;
@ -30,19 +35,26 @@
setenv("NO_COLOR", "1", true);
setenv("PYTHON_COLORS", "0", true);
if (getenv("GITHUB_ACTIONS")) {
NSLog(@"Running in a GitHub Actions environment");
}
// Arguments to pass into the test suite runner.
// argv[0] must identify the process; any subsequent arg
// will be handled as if it were an argument to `python -m test`
test_args = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"TestArgs"];
// The processInfo arguments contain the binary that is running,
// followed by the arguments defined in the test plan. This means:
// run_module = test_args[1]
// argv = ["Testbed"] + test_args[2:]
test_args = [[NSProcessInfo processInfo] arguments];
if (test_args == NULL) {
NSLog(@"Unable to identify test arguments.");
}
argv = malloc(sizeof(char *) * ([test_args count] + 1));
argv[0] = "iOSTestbed";
for (int i = 1; i < [test_args count]; i++) {
argv[i] = [[test_args objectAtIndex:i] UTF8String];
NSLog(@"Test arguments: %@", test_args);
argv = malloc(sizeof(char *) * ([test_args count] - 1));
argv[0] = "Testbed";
for (int i = 1; i < [test_args count] - 1; i++) {
argv[i] = [[test_args objectAtIndex:i+1] UTF8String];
}
NSLog(@"Test command: %@", test_args);
// Generate an isolated Python configuration.
NSLog(@"Configuring isolated Python...");
@ -63,7 +75,7 @@
// Ensure that signal handlers are installed
config.install_signal_handlers = 1;
// Run the test module.
config.run_module = Py_DecodeLocale([[test_args objectAtIndex:0] UTF8String], NULL);
config.run_module = Py_DecodeLocale([[test_args objectAtIndex:1] UTF8String], NULL);
// For debugging - enable verbose mode.
// config.verbose = 1;
@ -96,7 +108,7 @@
}
NSLog(@"Configure argc/argv...");
status = PyConfig_SetBytesArgv(&config, [test_args count], (char**) argv);
status = PyConfig_SetBytesArgv(&config, [test_args count] - 1, (char**) argv);
if (PyStatus_Exception(status)) {
XCTFail(@"Unable to configure argc/argv: %s", status.err_msg);
PyConfig_Clear(&config);
@ -111,6 +123,43 @@
return;
}
// Add app_packages as a site directory. This both adds to sys.path,
// and ensures that any .pth files in that directory will be executed.
site_module = PyImport_ImportModule("site");
if (site_module == NULL) {
XCTFail(@"Could not import site module");
return;
}
site_addsitedir_attr = PyObject_GetAttrString(site_module, "addsitedir");
if (site_addsitedir_attr == NULL || !PyCallable_Check(site_addsitedir_attr)) {
XCTFail(@"Could not access site.addsitedir");
return;
}
path = [NSString stringWithFormat:@"%@/app_packages", resourcePath, nil];
NSLog(@"App packages path: %@", path);
wtmp_str = Py_DecodeLocale([path UTF8String], NULL);
app_packages_path = PyUnicode_FromWideChar(wtmp_str, wcslen(wtmp_str));
if (app_packages_path == NULL) {
XCTFail(@"Could not convert app_packages path to unicode");
return;
}
PyMem_RawFree(wtmp_str);
method_args = Py_BuildValue("(O)", app_packages_path);
if (method_args == NULL) {
XCTFail(@"Could not create arguments for site.addsitedir");
return;
}
result = PyObject_CallObject(site_addsitedir_attr, method_args);
if (result == NULL) {
XCTFail(@"Could not add app_packages directory using site.addsitedir");
return;
}
// Add test code to sys.path
sys_module = PyImport_ImportModule("sys");
if (sys_module == NULL) {
XCTFail(@"Could not import sys module");
@ -123,17 +172,6 @@
return;
}
// Add the app packages path
path = [NSString stringWithFormat:@"%@/app_packages", resourcePath, nil];
NSLog(@"App packages path: %@", path);
wtmp_str = Py_DecodeLocale([path UTF8String], NULL);
failed = PyList_Insert(sys_path_attr, 0, PyUnicode_FromString([path UTF8String]));
if (failed) {
XCTFail(@"Unable to add app packages to sys.path");
return;
}
PyMem_RawFree(wtmp_str);
path = [NSString stringWithFormat:@"%@/app", resourcePath, nil];
NSLog(@"App path: %@", path);
wtmp_str = Py_DecodeLocale([path UTF8String], NULL);

435
Apple/testbed/__main__.py Normal file
View file

@ -0,0 +1,435 @@
import argparse
import json
import os
import re
import shlex
import shutil
import subprocess
import sys
from pathlib import Path
TEST_SLICES = {
"iOS": "ios-arm64_x86_64-simulator",
}
DECODE_ARGS = ("UTF-8", "backslashreplace")
# The system log prefixes each line:
# 2025-01-17 16:14:29.093742+0800 iOSTestbed[23987:1fd393b4] ...
# 2025-01-17 16:14:29.093742+0800 iOSTestbed[23987:1fd393b4] ...
LOG_PREFIX_REGEX = re.compile(
r"^\d{4}-\d{2}-\d{2}" # YYYY-MM-DD
r"\s+\d+:\d{2}:\d{2}\.\d+\+\d{4}" # HH:MM:SS.ssssss+ZZZZ
r"\s+iOSTestbed\[\d+:\w+\]" # Process/thread ID
)
# Select a simulator device to use.
def select_simulator_device(platform):
# List the testing simulators, in JSON format
raw_json = subprocess.check_output(["xcrun", "simctl", "list", "-j"])
json_data = json.loads(raw_json)
if platform == "iOS":
# Any iOS device will do; we'll look for "SE" devices - but the name
# isn't consistent over time. Older Xcode versions will use "iPhone SE
# (Nth generation)"; As of 2025, they've started using "iPhone 16e".
#
# When Xcode is updated after a new release, new devices will be
# available and old ones will be dropped from the set available on the
# latest iOS version. Select the one with the highest minimum runtime
# version - this is an indicator of the "newest" released device, which
# should always be supported on the "most recent" iOS version.
se_simulators = sorted(
(devicetype["minRuntimeVersion"], devicetype["name"])
for devicetype in json_data["devicetypes"]
if devicetype["productFamily"] == "iPhone"
and (
(
"iPhone " in devicetype["name"]
and devicetype["name"].endswith("e")
)
or "iPhone SE " in devicetype["name"]
)
)
simulator = se_simulators[-1][1]
else:
raise ValueError(f"Unknown platform {platform}")
return simulator
def xcode_test(location: Path, platform: str, simulator: str, verbose: bool):
# Build and run the test suite on the named simulator.
args = [
"-project",
str(location / f"{platform}Testbed.xcodeproj"),
"-scheme",
f"{platform}Testbed",
"-destination",
f"platform={platform} Simulator,name={simulator}",
"-derivedDataPath",
str(location / "DerivedData"),
]
verbosity_args = [] if verbose else ["-quiet"]
print("Building test project...")
subprocess.run(
["xcodebuild", "build-for-testing"] + args + verbosity_args,
check=True,
)
# Any environment variable prefixed with TEST_RUNNER_ is exposed into the
# test runner environment. There are some variables (like those identifying
# CI platforms) that can be useful to have access to.
test_env = os.environ.copy()
if "GITHUB_ACTIONS" in os.environ:
test_env["TEST_RUNNER_GITHUB_ACTIONS"] = os.environ["GITHUB_ACTIONS"]
print("Running test project...")
# Test execution *can't* be run -quiet; verbose mode
# is how we see the output of the test output.
process = subprocess.Popen(
["xcodebuild", "test-without-building"] + args,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
env=test_env,
)
while line := (process.stdout.readline()).decode(*DECODE_ARGS):
# Strip the timestamp/process prefix from each log line
line = LOG_PREFIX_REGEX.sub("", line)
sys.stdout.write(line)
sys.stdout.flush()
status = process.wait(timeout=5)
exit(status)
def copy(src, tgt):
"""An all-purpose copy.
If src is a file, it is copied. If src is a symlink, it is copied *as a
symlink*. If src is a directory, the full tree is duplicated, with symlinks
being preserved.
"""
if src.is_file() or src.is_symlink():
shutil.copyfile(src, tgt, follow_symlinks=False)
else:
shutil.copytree(src, tgt, symlinks=True)
def clone_testbed(
source: Path,
target: Path,
framework: Path,
platform: str,
apps: list[Path],
) -> None:
if target.exists():
print(f"{target} already exists; aborting without creating project.")
sys.exit(10)
if framework is None:
if not (
source / "Python.xcframework" / TEST_SLICES[platform] / "bin"
).is_dir():
print(
f"The testbed being cloned ({source}) does not contain "
"a framework with slices. Re-run with --framework"
)
sys.exit(11)
else:
if not framework.is_dir():
print(f"{framework} does not exist.")
sys.exit(12)
elif not (
framework.suffix == ".xcframework"
or (framework / "Python.framework").is_dir()
):
print(
f"{framework} is not an XCframework, "
f"or a simulator slice of a framework build."
)
sys.exit(13)
print("Cloning testbed project:")
print(f" Cloning {source}...", end="")
# Only copy the files for the platform being cloned plus the files common
# to all platforms. The XCframework will be copied later, if needed.
target.mkdir(parents=True)
for name in [
"__main__.py",
"TestbedTests",
"Testbed.lldbinit",
f"{platform}Testbed",
f"{platform}Testbed.xcodeproj",
f"{platform}Testbed.xctestplan",
]:
copy(source / name, target / name)
print(" done")
orig_xc_framework_path = source / "Python.xcframework"
xc_framework_path = target / "Python.xcframework"
test_framework_path = xc_framework_path / TEST_SLICES[platform]
if framework is not None:
if framework.suffix == ".xcframework":
print(" Installing XCFramework...", end="")
xc_framework_path.symlink_to(
framework.relative_to(xc_framework_path.parent, walk_up=True)
)
print(" done")
else:
print(" Installing simulator framework...", end="")
# We're only installing a slice of a framework; we need
# to do a full tree copy to make sure we don't damage
# symlinked content.
shutil.copytree(orig_xc_framework_path, xc_framework_path)
if test_framework_path.is_dir():
shutil.rmtree(test_framework_path)
else:
test_framework_path.unlink(missing_ok=True)
test_framework_path.symlink_to(
framework.relative_to(test_framework_path.parent, walk_up=True)
)
print(" done")
else:
copy(orig_xc_framework_path, xc_framework_path)
if (
xc_framework_path.is_symlink()
and not xc_framework_path.readlink().is_absolute()
):
# XCFramework is a relative symlink. Rewrite the symlink relative
# to the new location.
print(" Rewriting symlink to XCframework...", end="")
resolved_xc_framework_path = (
source / xc_framework_path.readlink()
).resolve()
xc_framework_path.unlink()
xc_framework_path.symlink_to(
resolved_xc_framework_path.relative_to(
xc_framework_path.parent, walk_up=True
)
)
print(" done")
elif (
test_framework_path.is_symlink()
and not test_framework_path.readlink().is_absolute()
):
print(" Rewriting symlink to simulator framework...", end="")
# Simulator framework is a relative symlink. Rewrite the symlink
# relative to the new location.
orig_test_framework_path = (
source / "Python.XCframework" / test_framework_path.readlink()
).resolve()
test_framework_path.unlink()
test_framework_path.symlink_to(
orig_test_framework_path.relative_to(
test_framework_path.parent, walk_up=True
)
)
print(" done")
else:
print(" Using pre-existing Python framework.")
for app_src in apps:
print(f" Installing app {app_src.name!r}...", end="")
app_target = target / f"Testbed/app/{app_src.name}"
if app_target.is_dir():
shutil.rmtree(app_target)
shutil.copytree(app_src, app_target)
print(" done")
print(f"Successfully cloned testbed: {target.resolve()}")
def update_test_plan(testbed_path, platform, args):
# Modify the test plan to use the requested test arguments.
test_plan_path = testbed_path / f"{platform}Testbed.xctestplan"
with test_plan_path.open("r", encoding="utf-8") as f:
test_plan = json.load(f)
test_plan["defaultOptions"]["commandLineArgumentEntries"] = [
{"argument": shlex.quote(arg)} for arg in args
]
with test_plan_path.open("w", encoding="utf-8") as f:
json.dump(test_plan, f, indent=2)
def run_testbed(
platform: str,
simulator: str | None,
args: list[str],
verbose: bool = False,
):
location = Path(__file__).parent
print("Updating test plan...", end="")
update_test_plan(location, platform, args)
print(" done.")
if simulator is None:
simulator = select_simulator_device(platform)
print(f"Running test on {simulator}")
xcode_test(
location,
platform=platform,
simulator=simulator,
verbose=verbose,
)
def main():
# Look for directories like `iOSTestbed` as an indicator of the platforms
# that the testbed folder supports. The original source testbed can support
# many platforms, but when cloned, only one platform is preserved.
available_platforms = [
platform
for platform in ["iOS"]
if (Path(__file__).parent / f"{platform}Testbed").is_dir()
]
parser = argparse.ArgumentParser(
description=(
"Manages the process of testing an Apple Python project "
"through Xcode."
),
)
subcommands = parser.add_subparsers(dest="subcommand")
clone = subcommands.add_parser(
"clone",
description=(
"Clone the testbed project, copying in a Python framework and"
"any specified application code."
),
help="Clone a testbed project to a new location.",
)
clone.add_argument(
"--framework",
help=(
"The location of the XCFramework (or simulator-only slice of an "
"XCFramework) to use when running the testbed"
),
)
clone.add_argument(
"--platform",
dest="platform",
choices=available_platforms,
default=available_platforms[0],
help=f"The platform to target (default: {available_platforms[0]})",
)
clone.add_argument(
"--app",
dest="apps",
action="append",
default=[],
help="The location of any code to include in the testbed project",
)
clone.add_argument(
"location",
help="The path where the testbed will be cloned.",
)
run = subcommands.add_parser(
"run",
usage=(
"%(prog)s [-h] [--simulator SIMULATOR] -- "
"<test arg> [<test arg> ...]"
),
description=(
"Run a testbed project. The arguments provided after `--` will be "
"passed to the running iOS process as if they were arguments to "
"`python -m`."
),
help="Run a testbed project",
)
run.add_argument(
"--platform",
dest="platform",
choices=available_platforms,
default=available_platforms[0],
help=f"The platform to target (default: {available_platforms[0]})",
)
run.add_argument(
"--simulator",
help=(
"The name of the simulator to use (eg: 'iPhone 16e'). Defaults to "
"the most recently released 'entry level' iPhone device. Device "
"architecture and OS version can also be specified; e.g., "
"`--simulator 'iPhone 16 Pro,arch=arm64,OS=26.0'` would run on "
"an ARM64 iPhone 16 Pro simulator running iOS 26.0."
),
)
run.add_argument(
"-v",
"--verbose",
action="store_true",
help="Enable verbose output",
)
try:
pos = sys.argv.index("--")
testbed_args = sys.argv[1:pos]
test_args = sys.argv[pos + 1 :]
except ValueError:
testbed_args = sys.argv[1:]
test_args = []
context = parser.parse_args(testbed_args)
if context.subcommand == "clone":
clone_testbed(
source=Path(__file__).parent.resolve(),
target=Path(context.location).resolve(),
framework=Path(context.framework).resolve()
if context.framework
else None,
platform=context.platform,
apps=[Path(app) for app in context.apps],
)
elif context.subcommand == "run":
if test_args:
if not (
Path(__file__).parent
/ "Python.xcframework"
/ TEST_SLICES[context.platform]
/ "bin"
).is_dir():
print(
"Testbed does not contain a compiled Python framework. "
f"Use `python {sys.argv[0]} clone ...` to create a "
"runnable clone of this testbed."
)
sys.exit(20)
run_testbed(
platform=context.platform,
simulator=context.simulator,
verbose=context.verbose,
args=test_args,
)
else:
print(
"Must specify test arguments "
f"(e.g., {sys.argv[0]} run -- test)"
)
print()
parser.print_help(sys.stderr)
sys.exit(21)
else:
parser.print_help(sys.stderr)
sys.exit(1)
if __name__ == "__main__":
# Under the buildbot, stdout is not a TTY, but we must still flush after
# every line to make sure our output appears in the correct order relative
# to the output of our subprocesses.
for stream in [sys.stdout, sys.stderr]:
stream.reconfigure(line_buffering=True)
main()

View file

@ -11,12 +11,11 @@
607A66222B0EFA390010BFC8 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 607A66212B0EFA390010BFC8 /* Assets.xcassets */; };
607A66252B0EFA390010BFC8 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 607A66232B0EFA390010BFC8 /* LaunchScreen.storyboard */; };
607A66282B0EFA390010BFC8 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 607A66272B0EFA390010BFC8 /* main.m */; };
607A66322B0EFA3A0010BFC8 /* iOSTestbedTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 607A66312B0EFA3A0010BFC8 /* iOSTestbedTests.m */; };
607A66322B0EFA3A0010BFC8 /* TestbedTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 607A66312B0EFA3A0010BFC8 /* TestbedTests.m */; };
607A664C2B0EFC080010BFC8 /* Python.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 607A664A2B0EFB310010BFC8 /* Python.xcframework */; };
607A664D2B0EFC080010BFC8 /* Python.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 607A664A2B0EFB310010BFC8 /* Python.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
607A66502B0EFFE00010BFC8 /* Python.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 607A664A2B0EFB310010BFC8 /* Python.xcframework */; };
607A66512B0EFFE00010BFC8 /* Python.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 607A664A2B0EFB310010BFC8 /* Python.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
607A66582B0F079F0010BFC8 /* dylib-Info-template.plist in Resources */ = {isa = PBXBuildFile; fileRef = 607A66572B0F079F0010BFC8 /* dylib-Info-template.plist */; };
608619542CB77BA900F46182 /* app_packages in Resources */ = {isa = PBXBuildFile; fileRef = 608619532CB77BA900F46182 /* app_packages */; };
608619562CB7819B00F46182 /* app in Resources */ = {isa = PBXBuildFile; fileRef = 608619552CB7819B00F46182 /* app */; };
/* End PBXBuildFile section */
@ -64,12 +63,12 @@
607A66242B0EFA390010BFC8 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
607A66272B0EFA390010BFC8 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
607A662D2B0EFA3A0010BFC8 /* iOSTestbedTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = iOSTestbedTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
607A66312B0EFA3A0010BFC8 /* iOSTestbedTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = iOSTestbedTests.m; sourceTree = "<group>"; };
607A66312B0EFA3A0010BFC8 /* TestbedTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TestbedTests.m; sourceTree = "<group>"; };
607A664A2B0EFB310010BFC8 /* Python.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; path = Python.xcframework; sourceTree = "<group>"; };
607A66572B0F079F0010BFC8 /* dylib-Info-template.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "dylib-Info-template.plist"; sourceTree = "<group>"; };
607A66592B0F08600010BFC8 /* iOSTestbed-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "iOSTestbed-Info.plist"; sourceTree = "<group>"; };
608619532CB77BA900F46182 /* app_packages */ = {isa = PBXFileReference; lastKnownFileType = folder; path = app_packages; sourceTree = "<group>"; };
608619552CB7819B00F46182 /* app */ = {isa = PBXFileReference; lastKnownFileType = folder; path = app; sourceTree = "<group>"; };
60FE0EFB2E56BB6D00524F87 /* iOSTestbed.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = iOSTestbed.xctestplan; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -95,9 +94,10 @@
607A66092B0EFA380010BFC8 = {
isa = PBXGroup;
children = (
60FE0EFB2E56BB6D00524F87 /* iOSTestbed.xctestplan */,
607A664A2B0EFB310010BFC8 /* Python.xcframework */,
607A66142B0EFA380010BFC8 /* iOSTestbed */,
607A66302B0EFA3A0010BFC8 /* iOSTestbedTests */,
607A66302B0EFA3A0010BFC8 /* TestbedTests */,
607A66132B0EFA380010BFC8 /* Products */,
607A664F2B0EFFE00010BFC8 /* Frameworks */,
);
@ -118,7 +118,6 @@
608619552CB7819B00F46182 /* app */,
608619532CB77BA900F46182 /* app_packages */,
607A66592B0F08600010BFC8 /* iOSTestbed-Info.plist */,
607A66572B0F079F0010BFC8 /* dylib-Info-template.plist */,
607A66152B0EFA380010BFC8 /* AppDelegate.h */,
607A66162B0EFA380010BFC8 /* AppDelegate.m */,
607A66212B0EFA390010BFC8 /* Assets.xcassets */,
@ -128,12 +127,12 @@
path = iOSTestbed;
sourceTree = "<group>";
};
607A66302B0EFA3A0010BFC8 /* iOSTestbedTests */ = {
607A66302B0EFA3A0010BFC8 /* TestbedTests */ = {
isa = PBXGroup;
children = (
607A66312B0EFA3A0010BFC8 /* iOSTestbedTests.m */,
607A66312B0EFA3A0010BFC8 /* TestbedTests.m */,
);
path = iOSTestbedTests;
path = TestbedTests;
sourceTree = "<group>";
};
607A664F2B0EFFE00010BFC8 /* Frameworks */ = {
@ -153,8 +152,7 @@
607A660E2B0EFA380010BFC8 /* Sources */,
607A660F2B0EFA380010BFC8 /* Frameworks */,
607A66102B0EFA380010BFC8 /* Resources */,
607A66552B0F061D0010BFC8 /* Install Target Specific Python Standard Library */,
607A66562B0F06200010BFC8 /* Prepare Python Binary Modules */,
607A66552B0F061D0010BFC8 /* Process Python libraries */,
607A664E2B0EFC080010BFC8 /* Embed Frameworks */,
);
buildRules = (
@ -228,7 +226,6 @@
buildActionMask = 2147483647;
files = (
607A66252B0EFA390010BFC8 /* LaunchScreen.storyboard in Resources */,
607A66582B0F079F0010BFC8 /* dylib-Info-template.plist in Resources */,
608619562CB7819B00F46182 /* app in Resources */,
607A66222B0EFA390010BFC8 /* Assets.xcassets in Resources */,
608619542CB77BA900F46182 /* app_packages in Resources */,
@ -245,7 +242,7 @@
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
607A66552B0F061D0010BFC8 /* Install Target Specific Python Standard Library */ = {
607A66552B0F061D0010BFC8 /* Process Python libraries */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
@ -255,34 +252,14 @@
);
inputPaths = (
);
name = "Install Target Specific Python Standard Library";
name = "Process Python libraries";
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "set -e\n\nmkdir -p \"$CODESIGNING_FOLDER_PATH/python/lib\"\nif [ \"$EFFECTIVE_PLATFORM_NAME\" = \"-iphonesimulator\" ]; then\n echo \"Installing Python modules for iOS Simulator\"\n rsync -au --delete \"$PROJECT_DIR/Python.xcframework/ios-arm64_x86_64-simulator/lib/\" \"$CODESIGNING_FOLDER_PATH/python/lib/\" \nelse\n echo \"Installing Python modules for iOS Device\"\n rsync -au --delete \"$PROJECT_DIR/Python.xcframework/ios-arm64/lib/\" \"$CODESIGNING_FOLDER_PATH/python/lib/\" \nfi\n";
showEnvVarsInLog = 0;
};
607A66562B0F06200010BFC8 /* Prepare Python Binary Modules */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
name = "Prepare Python Binary Modules";
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "set -e\n\ninstall_dylib () {\n INSTALL_BASE=$1\n FULL_EXT=$2\n\n # The name of the extension file\n EXT=$(basename \"$FULL_EXT\")\n # The location of the extension file, relative to the bundle\n RELATIVE_EXT=${FULL_EXT#$CODESIGNING_FOLDER_PATH/} \n # The path to the extension file, relative to the install base\n PYTHON_EXT=${RELATIVE_EXT/$INSTALL_BASE/}\n # The full dotted name of the extension module, constructed from the file path.\n FULL_MODULE_NAME=$(echo $PYTHON_EXT | cut -d \".\" -f 1 | tr \"/\" \".\"); \n # A bundle identifier; not actually used, but required by Xcode framework packaging\n FRAMEWORK_BUNDLE_ID=$(echo $PRODUCT_BUNDLE_IDENTIFIER.$FULL_MODULE_NAME | tr \"_\" \"-\")\n # The name of the framework folder.\n FRAMEWORK_FOLDER=\"Frameworks/$FULL_MODULE_NAME.framework\"\n\n # If the framework folder doesn't exist, create it.\n if [ ! -d \"$CODESIGNING_FOLDER_PATH/$FRAMEWORK_FOLDER\" ]; then\n echo \"Creating framework for $RELATIVE_EXT\" \n mkdir -p \"$CODESIGNING_FOLDER_PATH/$FRAMEWORK_FOLDER\"\n cp \"$CODESIGNING_FOLDER_PATH/dylib-Info-template.plist\" \"$CODESIGNING_FOLDER_PATH/$FRAMEWORK_FOLDER/Info.plist\"\n plutil -replace CFBundleExecutable -string \"$FULL_MODULE_NAME\" \"$CODESIGNING_FOLDER_PATH/$FRAMEWORK_FOLDER/Info.plist\"\n plutil -replace CFBundleIdentifier -string \"$FRAMEWORK_BUNDLE_ID\" \"$CODESIGNING_FOLDER_PATH/$FRAMEWORK_FOLDER/Info.plist\"\n fi\n \n echo \"Installing binary for $FRAMEWORK_FOLDER/$FULL_MODULE_NAME\" \n mv \"$FULL_EXT\" \"$CODESIGNING_FOLDER_PATH/$FRAMEWORK_FOLDER/$FULL_MODULE_NAME\"\n # Create a placeholder .fwork file where the .so was\n echo \"$FRAMEWORK_FOLDER/$FULL_MODULE_NAME\" > ${FULL_EXT%.so}.fwork\n # Create a back reference to the .so file location in the framework\n echo \"${RELATIVE_EXT%.so}.fwork\" > \"$CODESIGNING_FOLDER_PATH/$FRAMEWORK_FOLDER/$FULL_MODULE_NAME.origin\" \n}\n\nPYTHON_VER=$(ls -1 \"$CODESIGNING_FOLDER_PATH/python/lib\")\necho \"Install Python $PYTHON_VER standard library extension modules...\"\nfind \"$CODESIGNING_FOLDER_PATH/python/lib/$PYTHON_VER/lib-dynload\" -name \"*.so\" | while read FULL_EXT; do\n install_dylib python/lib/$PYTHON_VER/lib-dynload/ \"$FULL_EXT\"\ndone\necho \"Install app package extension modules...\"\nfind \"$CODESIGNING_FOLDER_PATH/app_packages\" -name \"*.so\" | while read FULL_EXT; do\n install_dylib app_packages/ \"$FULL_EXT\"\ndone\necho \"Install app extension modules...\"\nfind \"$CODESIGNING_FOLDER_PATH/app\" -name \"*.so\" | while read FULL_EXT; do\n install_dylib app/ \"$FULL_EXT\"\ndone\n\n# Clean up dylib template \nrm -f \"$CODESIGNING_FOLDER_PATH/dylib-Info-template.plist\"\necho \"Signing frameworks as $EXPANDED_CODE_SIGN_IDENTITY_NAME ($EXPANDED_CODE_SIGN_IDENTITY)...\"\nfind \"$CODESIGNING_FOLDER_PATH/Frameworks\" -name \"*.framework\" -exec /usr/bin/codesign --force --sign \"$EXPANDED_CODE_SIGN_IDENTITY\" ${OTHER_CODE_SIGN_FLAGS:-} -o runtime --timestamp=none --preserve-metadata=identifier,entitlements,flags --generate-entitlement-der \"{}\" \\; \n";
shellScript = "set -e\nsource $PROJECT_DIR/Python.xcframework/build/utils.sh\ninstall_python Python.xcframework app app_packages\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
@ -301,7 +278,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
607A66322B0EFA3A0010BFC8 /* iOSTestbedTests.m in Sources */,
607A66322B0EFA3A0010BFC8 /* TestbedTests.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -379,7 +356,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
@ -434,7 +411,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
@ -460,7 +437,7 @@
INFOPLIST_KEY_UIMainStoryboardFile = Main;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
@ -491,7 +468,7 @@
INFOPLIST_KEY_UIMainStoryboardFile = Main;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
@ -514,7 +491,7 @@
DEVELOPMENT_TEAM = 3HEZE76D99;
GENERATE_INFOPLIST_FILE = YES;
HEADER_SEARCH_PATHS = "\"$(BUILT_PRODUCTS_DIR)/Python.framework/Headers\"";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = org.python.iOSTestbedTests;
PRODUCT_NAME = "$(TARGET_NAME)";
@ -534,7 +511,7 @@
DEVELOPMENT_TEAM = 3HEZE76D99;
GENERATE_INFOPLIST_FILE = YES;
HEADER_SEARCH_PATHS = "\"$(BUILT_PRODUCTS_DIR)/Python.framework/Headers\"";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = org.python.iOSTestbedTests;
PRODUCT_NAME = "$(TARGET_NAME)";

View file

@ -0,0 +1,97 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1640"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES"
buildArchitectures = "Automatic">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "607A66112B0EFA380010BFC8"
BuildableName = "iOSTestbed.app"
BlueprintName = "iOSTestbed"
ReferencedContainer = "container:iOSTestbed.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
customLLDBInitFile = "$(SOURCE_ROOT)/Testbed.lldbinit"
shouldUseLaunchSchemeArgsEnv = "YES">
<TestPlans>
<TestPlanReference
reference = "container:iOSTestbed.xctestplan"
default = "YES">
</TestPlanReference>
</TestPlans>
<Testables>
<TestableReference
skipped = "NO"
parallelizable = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "607A662C2B0EFA3A0010BFC8"
BuildableName = "iOSTestbedTests.xctest"
BlueprintName = "iOSTestbedTests"
ReferencedContainer = "container:iOSTestbed.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "607A66112B0EFA380010BFC8"
BuildableName = "iOSTestbed.app"
BlueprintName = "iOSTestbed"
ReferencedContainer = "container:iOSTestbed.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "607A66112B0EFA380010BFC8"
BuildableName = "iOSTestbed.app"
BlueprintName = "iOSTestbed"
ReferencedContainer = "container:iOSTestbed.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View file

@ -0,0 +1,46 @@
{
"configurations" : [
{
"id" : "F5A95CE4-1ADE-4A6E-A0E1-CDBAE26DF0C5",
"name" : "Test Scheme Action",
"options" : {
}
}
],
"defaultOptions" : {
"commandLineArgumentEntries" : [
{
"argument" : "test"
},
{
"argument" : "-uall"
},
{
"argument" : "--single-process"
},
{
"argument" : "--rerun"
},
{
"argument" : "-W"
}
],
"targetForVariableExpansion" : {
"containerPath" : "container:iOSTestbed.xcodeproj",
"identifier" : "607A66112B0EFA380010BFC8",
"name" : "iOSTestbed"
}
},
"testTargets" : [
{
"parallelizable" : false,
"target" : {
"containerPath" : "container:iOSTestbed.xcodeproj",
"identifier" : "607A662C2B0EFA3A0010BFC8",
"name" : "iOSTestbedTests"
}
}
],
"version" : 1
}

View file

@ -1,7 +1,7 @@
This folder can contain any Python application code.
During the build, any binary modules found in this folder will be processed into
iOS Framework form.
Framework form.
When the test suite runs, this folder will be on the PYTHONPATH, and will be the
working directory for the test suite.

View file

@ -2,6 +2,6 @@ This folder can be a target for installing any Python dependencies needed by the
test suite.
During the build, any binary modules found in this folder will be processed into
iOS Framework form.
Framework form.
When the test suite runs, this folder will be on the PYTHONPATH.

View file

@ -41,18 +41,6 @@
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>TestArgs</key>
<array>
<string>test</string> <!-- Invoke "python -m test" -->
<string>-uall</string> <!-- Enable all resources -->
<string>--single-process</string> <!-- always run all tests sequentially in a single process -->
<string>--rerun</string> <!-- Re-run failed tests in verbose mode -->
<string>-W</string> <!-- Display test output on failure -->
<!-- To run a subset of tests, add the test names below; e.g.,
<string>test_os</string>
<string>test_sys</string>
-->
</array>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>

View file

@ -170,6 +170,7 @@ venv:
echo "venv already exists."; \
echo "To recreate it, remove it first with \`make clean-venv'."; \
else \
set -e; \
echo "Creating venv in $(VENVDIR)"; \
if $(UV) --version >/dev/null 2>&1; then \
$(UV) venv --python=$(PYTHON) $(VENVDIR); \
@ -183,7 +184,7 @@ venv:
fi
.PHONY: dist-no-html
dist-no-html: dist-text dist-pdf dist-epub dist-texinfo
dist-no-html: dist-text dist-epub dist-texinfo
.PHONY: dist
dist:
@ -240,7 +241,8 @@ dist-pdf:
# as otherwise the full latexmk process is run twice.
# ($$ is needed to escape the $; https://www.gnu.org/software/make/manual/make.html#Basics-of-Variable-References)
-sed -i 's/: all-$$(FMT)/:/' build/latex/Makefile
(cd build/latex; $(MAKE) clean && $(MAKE) --jobs=$$((`nproc`+1)) --output-sync LATEXMKOPTS='-quiet' all-pdf && $(MAKE) FMT=pdf zip bz2)
if [ -n "$(filter output-sync,$(value .FEATURES))" ]; then OUTPUTSYNC=--output-sync; else OUTPUTSYNC=; fi && \
(cd build/latex; $(MAKE) clean && $(MAKE) --jobs=$$((`getconf _NPROCESSORS_ONLN`+1)) $$OUTPUTSYNC LATEXMKOPTS='-quiet' all-pdf && $(MAKE) FMT=pdf zip bz2)
cp build/latex/docs-pdf.zip dist/python-$(DISTVERSION)-docs-pdf-a4.zip
cp build/latex/docs-pdf.tar.bz2 dist/python-$(DISTVERSION)-docs-pdf-a4.tar.bz2
@echo "Build finished and archived!"

View file

@ -32,8 +32,9 @@ Contributors to the Python documentation
----------------------------------------
Many people have contributed to the Python language, the Python standard
library, and the Python documentation. See :source:`Misc/ACKS` in the Python
source distribution for a partial list of contributors.
library, and the Python documentation. See the `CPython
GitHub repository <https://github.com/python/cpython/graphs/contributors>`__
for a partial list of contributors.
It is only with the input and contributions of the Python community
that Python has such wonderful documentation -- Thank You!

View file

@ -19,6 +19,12 @@ If you find a bug in this documentation or would like to propose an improvement,
please submit a bug report on the :ref:`issue tracker <using-the-tracker>`. If you
have a suggestion on how to fix it, include that as well.
.. only:: translation
If the bug or suggested improvement concerns the translation of this
documentation, submit the report to the
`translations repository <TRANSLATION_REPO_>`_ instead.
You can also open a discussion item on our
`Documentation Discourse forum <https://discuss.python.org/c/documentation/26>`_.
@ -37,8 +43,8 @@ tracker <https://github.com/python/python-docs-theme>`_.
`Helping with Documentation <https://devguide.python.org/docquality/#helping-with-documentation>`_
Comprehensive guide for individuals that are interested in contributing to Python documentation.
`Documentation Translations <https://devguide.python.org/documentation/translating/>`_
A list of GitHub pages for documentation translation and their primary contacts.
`Documentation Translations <https://devguide.python.org/documentation/translations/translating/#translation-coordinators>`_
A list of GitHub pages for documentation translation and their coordination teams.
.. _using-the-tracker:

View file

@ -16,7 +16,20 @@ Allocating Objects on the Heap
Initialize a newly allocated object *op* with its type and initial
reference. Returns the initialized object. Other fields of the object are
not affected.
not initialized. Despite its name, this function is unrelated to the
object's :meth:`~object.__init__` method (:c:member:`~PyTypeObject.tp_init`
slot). Specifically, this function does **not** call the object's
:meth:`!__init__` method.
In general, consider this function to be a low-level routine. Use
:c:member:`~PyTypeObject.tp_alloc` where possible.
For implementing :c:member:`!tp_alloc` for your type, prefer
:c:func:`PyType_GenericAlloc` or :c:func:`PyObject_New`.
.. note::
This function only initializes the object's memory corresponding to the
initial :c:type:`PyObject` structure. It does not zero the rest.
.. c:function:: PyVarObject* PyObject_InitVar(PyVarObject *op, PyTypeObject *type, Py_ssize_t size)
@ -24,43 +37,108 @@ Allocating Objects on the Heap
This does everything :c:func:`PyObject_Init` does, and also initializes the
length information for a variable-size object.
.. note::
This function only initializes some of the object's memory. It does not
zero the rest.
.. c:macro:: PyObject_New(TYPE, typeobj)
Allocate a new Python object using the C structure type *TYPE*
and the Python type object *typeobj* (``PyTypeObject*``).
Fields not defined by the Python object header are not initialized.
The caller will own the only reference to the object
(i.e. its reference count will be one).
The size of the memory allocation is determined from the
:c:member:`~PyTypeObject.tp_basicsize` field of the type object.
Allocates a new Python object using the C structure type *TYPE* and the
Python type object *typeobj* (``PyTypeObject*``) by calling
:c:func:`PyObject_Malloc` to allocate memory and initializing it like
:c:func:`PyObject_Init`. The caller will own the only reference to the
object (i.e. its reference count will be one).
Note that this function is unsuitable if *typeobj* has
:c:macro:`Py_TPFLAGS_HAVE_GC` set. For such objects,
use :c:func:`PyObject_GC_New` instead.
Avoid calling this directly to allocate memory for an object; call the type's
:c:member:`~PyTypeObject.tp_alloc` slot instead.
When populating a type's :c:member:`~PyTypeObject.tp_alloc` slot,
:c:func:`PyType_GenericAlloc` is preferred over a custom function that
simply calls this macro.
This macro does not call :c:member:`~PyTypeObject.tp_alloc`,
:c:member:`~PyTypeObject.tp_new` (:meth:`~object.__new__`), or
:c:member:`~PyTypeObject.tp_init` (:meth:`~object.__init__`).
This cannot be used for objects with :c:macro:`Py_TPFLAGS_HAVE_GC` set in
:c:member:`~PyTypeObject.tp_flags`; use :c:macro:`PyObject_GC_New` instead.
Memory allocated by this macro must be freed with :c:func:`PyObject_Free`
(usually called via the object's :c:member:`~PyTypeObject.tp_free` slot).
.. note::
The returned memory is not guaranteed to have been completely zeroed
before it was initialized.
.. note::
This macro does not construct a fully initialized object of the given
type; it merely allocates memory and prepares it for further
initialization by :c:member:`~PyTypeObject.tp_init`. To construct a
fully initialized object, call *typeobj* instead. For example::
PyObject *foo = PyObject_CallNoArgs((PyObject *)&PyFoo_Type);
.. seealso::
* :c:func:`PyObject_Free`
* :c:macro:`PyObject_GC_New`
* :c:func:`PyType_GenericAlloc`
* :c:member:`~PyTypeObject.tp_alloc`
.. c:macro:: PyObject_NewVar(TYPE, typeobj, size)
Allocate a new Python object using the C structure type *TYPE* and the
Python type object *typeobj* (``PyTypeObject*``).
Fields not defined by the Python object header
are not initialized. The allocated memory allows for the *TYPE* structure
plus *size* (``Py_ssize_t``) fields of the size
given by the :c:member:`~PyTypeObject.tp_itemsize` field of
*typeobj*. This is useful for implementing objects like tuples, which are
able to determine their size at construction time. Embedding the array of
fields into the same allocation decreases the number of allocations,
improving the memory management efficiency.
Like :c:macro:`PyObject_New` except:
Note that this function is unsuitable if *typeobj* has
:c:macro:`Py_TPFLAGS_HAVE_GC` set. For such objects,
use :c:func:`PyObject_GC_NewVar` instead.
* It allocates enough memory for the *TYPE* structure plus *size*
(``Py_ssize_t``) fields of the size given by the
:c:member:`~PyTypeObject.tp_itemsize` field of *typeobj*.
* The memory is initialized like :c:func:`PyObject_InitVar`.
This is useful for implementing objects like tuples, which are able to
determine their size at construction time. Embedding the array of fields
into the same allocation decreases the number of allocations, improving the
memory management efficiency.
.. c:function:: void PyObject_Del(void *op)
Avoid calling this directly to allocate memory for an object; call the type's
:c:member:`~PyTypeObject.tp_alloc` slot instead.
When populating a type's :c:member:`~PyTypeObject.tp_alloc` slot,
:c:func:`PyType_GenericAlloc` is preferred over a custom function that
simply calls this macro.
This cannot be used for objects with :c:macro:`Py_TPFLAGS_HAVE_GC` set in
:c:member:`~PyTypeObject.tp_flags`; use :c:macro:`PyObject_GC_NewVar`
instead.
Memory allocated by this function must be freed with :c:func:`PyObject_Free`
(usually called via the object's :c:member:`~PyTypeObject.tp_free` slot).
.. note::
The returned memory is not guaranteed to have been completely zeroed
before it was initialized.
.. note::
This macro does not construct a fully initialized object of the given
type; it merely allocates memory and prepares it for further
initialization by :c:member:`~PyTypeObject.tp_init`. To construct a
fully initialized object, call *typeobj* instead. For example::
PyObject *list_instance = PyObject_CallNoArgs((PyObject *)&PyList_Type);
.. seealso::
* :c:func:`PyObject_Free`
* :c:macro:`PyObject_GC_NewVar`
* :c:func:`PyType_GenericAlloc`
* :c:member:`~PyTypeObject.tp_alloc`
Same as :c:func:`PyObject_Free`.
.. c:var:: PyObject _Py_NoneStruct
@ -71,6 +149,38 @@ Allocating Objects on the Heap
.. seealso::
:c:func:`PyModule_Create`
:ref:`moduleobjects`
To allocate and create extension modules.
Deprecated aliases
^^^^^^^^^^^^^^^^^^
These are :term:`soft deprecated` aliases to existing functions and macros.
They exist solely for backwards compatibility.
.. list-table::
:widths: auto
:header-rows: 1
* * Deprecated alias
* Function
* * .. c:macro:: PyObject_NEW(type, typeobj)
* :c:macro:`PyObject_New`
* * .. c:macro:: PyObject_NEW_VAR(type, typeobj, n)
* :c:macro:`PyObject_NewVar`
* * .. c:macro:: PyObject_INIT(op, typeobj)
* :c:func:`PyObject_Init`
* * .. c:macro:: PyObject_INIT_VAR(op, typeobj, n)
* :c:func:`PyObject_InitVar`
* * .. c:macro:: PyObject_MALLOC(n)
* :c:func:`PyObject_Malloc`
* * .. c:macro:: PyObject_REALLOC(p, n)
* :c:func:`PyObject_Realloc`
* * .. c:macro:: PyObject_FREE(p)
* :c:func:`PyObject_Free`
* * .. c:macro:: PyObject_DEL(p)
* :c:func:`PyObject_Free`
* * .. c:macro:: PyObject_Del(p)
* :c:func:`PyObject_Free`

View file

@ -113,18 +113,14 @@ There are three ways strings and buffers can be converted to C:
``z`` (:class:`str` or ``None``) [const char \*]
Like ``s``, but the Python object may also be ``None``, in which case the C
pointer is set to ``NULL``.
It is the same as ``s?`` with the C pointer was initialized to ``NULL``.
``z*`` (:class:`str`, :term:`bytes-like object` or ``None``) [Py_buffer]
Like ``s*``, but the Python object may also be ``None``, in which case the
``buf`` member of the :c:type:`Py_buffer` structure is set to ``NULL``.
It is the same as ``s*?`` with the ``buf`` member of the :c:type:`Py_buffer`
structure was initialized to ``NULL``.
``z#`` (:class:`str`, read-only :term:`bytes-like object` or ``None``) [const char \*, :c:type:`Py_ssize_t`]
Like ``s#``, but the Python object may also be ``None``, in which case the C
pointer is set to ``NULL``.
It is the same as ``s#?`` with the C pointer was initialized to ``NULL``.
``y`` (read-only :term:`bytes-like object`) [const char \*]
This format converts a bytes-like object to a C pointer to a
@ -164,7 +160,7 @@ There are three ways strings and buffers can be converted to C:
``w*`` (read-write :term:`bytes-like object`) [Py_buffer]
This format accepts any object which implements the read-write buffer
interface. It fills a :c:type:`Py_buffer` structure provided by the caller.
The buffer may contain embedded null bytes. The caller have to call
The buffer may contain embedded null bytes. The caller has to call
:c:func:`PyBuffer_Release` when it is done with the buffer.
``es`` (:class:`str`) [const char \*encoding, char \*\*buffer]
@ -241,9 +237,11 @@ the Python object to the required type.
For signed integer formats, :exc:`OverflowError` is raised if the value
is out of range for the C type.
For unsigned integer formats, no range checking is done --- the
For unsigned integer formats, the
most significant bits are silently truncated when the receiving field is too
small to receive the value.
small to receive the value, and :exc:`DeprecationWarning` is emitted when
the value is larger than the maximal value for the C type or less than
the minimal value for the corresponding signed integer type of the same size.
``b`` (:class:`int`) [unsigned char]
Convert a nonnegative Python integer to an unsigned tiny integer, stored in a C
@ -252,27 +250,25 @@ small to receive the value.
``B`` (:class:`int`) [unsigned char]
Convert a Python integer to a tiny integer without overflow checking, stored in a C
:c:expr:`unsigned char`.
Convert a Python integer to a C :c:expr:`unsigned char`.
``h`` (:class:`int`) [short int]
Convert a Python integer to a C :c:expr:`short int`.
``H`` (:class:`int`) [unsigned short int]
Convert a Python integer to a C :c:expr:`unsigned short int`, without overflow
checking.
Convert a Python integer to a C :c:expr:`unsigned short int`.
``i`` (:class:`int`) [int]
Convert a Python integer to a plain C :c:expr:`int`.
``I`` (:class:`int`) [unsigned int]
Convert a Python integer to a C :c:expr:`unsigned int`, without overflow
checking.
Convert a Python integer to a C :c:expr:`unsigned int`.
``l`` (:class:`int`) [long int]
Convert a Python integer to a C :c:expr:`long int`.
``k`` (:class:`int`) [unsigned long]
Convert a Python integer to a C :c:expr:`unsigned long` without
overflow checking.
Convert a Python integer to a C :c:expr:`unsigned long`.
.. versionchanged:: 3.14
Use :meth:`~object.__index__` if available.
@ -281,8 +277,7 @@ small to receive the value.
Convert a Python integer to a C :c:expr:`long long`.
``K`` (:class:`int`) [unsigned long long]
Convert a Python integer to a C :c:expr:`unsigned long long`
without overflow checking.
Convert a Python integer to a C :c:expr:`unsigned long long`.
.. versionchanged:: 3.14
Use :meth:`~object.__index__` if available.
@ -310,6 +305,14 @@ small to receive the value.
``D`` (:class:`complex`) [Py_complex]
Convert a Python complex number to a C :c:type:`Py_complex` structure.
.. deprecated:: 3.15
For unsigned integer formats ``B``, ``H``, ``I``, ``k`` and ``K``,
:exc:`DeprecationWarning` is emitted when the value is larger than
the maximal value for the C type or less than the minimal value for
the corresponding signed integer type of the same size.
Other objects
-------------
@ -387,17 +390,6 @@ Other objects
Non-tuple sequences are deprecated if *items* contains format units
which store a borrowed buffer or a borrowed reference.
``unit?`` (anything or ``None``) [*matching-variable(s)*]
``?`` modifies the behavior of the preceding format unit.
The C variable(s) corresponding to that parameter should be initialized
to their default value --- when the argument is ``None``,
:c:func:`PyArg_ParseTuple` does not touch the contents of the corresponding
C variable(s).
If the argument is not ``None``, it is parsed according to the specified
format unit.
.. versionadded:: 3.14
A few other characters have a meaning in a format string. These may not occur
inside nested parentheses. They are:
@ -685,6 +677,13 @@ Building values
``p`` (:class:`bool`) [int]
Convert a C :c:expr:`int` to a Python :class:`bool` object.
Be aware that this format requires an ``int`` argument.
Unlike most other contexts in C, variadic arguments are not coerced to
a suitable type automatically.
You can convert another type (for example, a pointer or a float) to a
suitable ``int`` value using ``(x) ? 1 : 0`` or ``!!x``.
.. versionadded:: 3.14
``c`` (:class:`bytes` of length 1) [char]

View file

@ -261,6 +261,10 @@ readonly, format
MUST be consistent for all consumers. For example, :c:expr:`PyBUF_SIMPLE | PyBUF_WRITABLE`
can be used to request a simple writable buffer.
.. c:macro:: PyBUF_WRITEABLE
This is a :term:`soft deprecated` alias to :c:macro:`PyBUF_WRITABLE`.
.. c:macro:: PyBUF_FORMAT
Controls the :c:member:`~Py_buffer.format` field. If set, this field MUST

View file

@ -47,6 +47,10 @@ called with a non-bytes parameter.
*len* on success, and ``NULL`` on failure. If *v* is ``NULL``, the contents of
the bytes object are uninitialized.
.. deprecated:: 3.15
``PyBytes_FromStringAndSize(NULL, len)`` is :term:`soft deprecated`,
use the :c:type:`PyBytesWriter` API instead.
.. c:function:: PyObject* PyBytes_FromFormat(const char *format, ...)
@ -219,3 +223,209 @@ called with a non-bytes parameter.
reallocation fails, the original bytes object at *\*bytes* is deallocated,
*\*bytes* is set to ``NULL``, :exc:`MemoryError` is set, and ``-1`` is
returned.
.. deprecated:: 3.15
The function is :term:`soft deprecated`,
use the :c:type:`PyBytesWriter` API instead.
.. c:function:: PyObject *PyBytes_Repr(PyObject *bytes, int smartquotes)
Get the string representation of *bytes*. This function is currently used to
implement :meth:`!bytes.__repr__` in Python.
This function does not do type checking; it is undefined behavior to pass
*bytes* as a non-bytes object or ``NULL``.
If *smartquotes* is true, the representation will use a double-quoted string
instead of single-quoted string when single-quotes are present in *bytes*.
For example, the byte string ``'Python'`` would be represented as
``b"'Python'"`` when *smartquotes* is true, or ``b'\'Python\''`` when it is
false.
On success, this function returns a :term:`strong reference` to a
:class:`str` object containing the representation. On failure, this
returns ``NULL`` with an exception set.
.. c:function:: PyObject *PyBytes_DecodeEscape(const char *s, Py_ssize_t len, const char *errors, Py_ssize_t unicode, const char *recode_encoding)
Unescape a backslash-escaped string *s*. *s* must not be ``NULL``.
*len* must be the size of *s*.
*errors* must be one of ``"strict"``, ``"replace"``, or ``"ignore"``. If
*errors* is ``NULL``, then ``"strict"`` is used by default.
On success, this function returns a :term:`strong reference` to a Python
:class:`bytes` object containing the unescaped string. On failure, this
function returns ``NULL`` with an exception set.
.. versionchanged:: 3.9
*unicode* and *recode_encoding* are now unused.
.. _pybyteswriter:
PyBytesWriter
-------------
The :c:type:`PyBytesWriter` API can be used to create a Python :class:`bytes`
object.
.. versionadded:: 3.15
.. c:type:: PyBytesWriter
A bytes writer instance.
The API is **not thread safe**: a writer should only be used by a single
thread at the same time.
The instance must be destroyed by :c:func:`PyBytesWriter_Finish` on
success, or :c:func:`PyBytesWriter_Discard` on error.
Create, Finish, Discard
^^^^^^^^^^^^^^^^^^^^^^^
.. c:function:: PyBytesWriter* PyBytesWriter_Create(Py_ssize_t size)
Create a :c:type:`PyBytesWriter` to write *size* bytes.
If *size* is greater than zero, allocate *size* bytes, and set the
writer size to *size*. The caller is responsible to write *size*
bytes using :c:func:`PyBytesWriter_GetData`.
This function does not overallocate.
On error, set an exception and return ``NULL``.
*size* must be positive or zero.
.. c:function:: PyObject* PyBytesWriter_Finish(PyBytesWriter *writer)
Finish a :c:type:`PyBytesWriter` created by
:c:func:`PyBytesWriter_Create`.
On success, return a Python :class:`bytes` object.
On error, set an exception and return ``NULL``.
The writer instance is invalid after the call in any case.
No API can be called on the writer after :c:func:`PyBytesWriter_Finish`.
.. c:function:: PyObject* PyBytesWriter_FinishWithSize(PyBytesWriter *writer, Py_ssize_t size)
Similar to :c:func:`PyBytesWriter_Finish`, but resize the writer
to *size* bytes before creating the :class:`bytes` object.
.. c:function:: PyObject* PyBytesWriter_FinishWithPointer(PyBytesWriter *writer, void *buf)
Similar to :c:func:`PyBytesWriter_Finish`, but resize the writer
using *buf* pointer before creating the :class:`bytes` object.
Set an exception and return ``NULL`` if *buf* pointer is outside the
internal buffer bounds.
Function pseudo-code::
Py_ssize_t size = (char*)buf - (char*)PyBytesWriter_GetData(writer);
return PyBytesWriter_FinishWithSize(writer, size);
.. c:function:: void PyBytesWriter_Discard(PyBytesWriter *writer)
Discard a :c:type:`PyBytesWriter` created by :c:func:`PyBytesWriter_Create`.
Do nothing if *writer* is ``NULL``.
The writer instance is invalid after the call.
No API can be called on the writer after :c:func:`PyBytesWriter_Discard`.
High-level API
^^^^^^^^^^^^^^
.. c:function:: int PyBytesWriter_WriteBytes(PyBytesWriter *writer, const void *bytes, Py_ssize_t size)
Grow the *writer* internal buffer by *size* bytes,
write *size* bytes of *bytes* at the *writer* end,
and add *size* to the *writer* size.
If *size* is equal to ``-1``, call ``strlen(bytes)`` to get the
string length.
On success, return ``0``.
On error, set an exception and return ``-1``.
.. c:function:: int PyBytesWriter_Format(PyBytesWriter *writer, const char *format, ...)
Similar to :c:func:`PyBytes_FromFormat`, but write the output directly at
the writer end. Grow the writer internal buffer on demand. Then add the
written size to the writer size.
On success, return ``0``.
On error, set an exception and return ``-1``.
Getters
^^^^^^^
.. c:function:: Py_ssize_t PyBytesWriter_GetSize(PyBytesWriter *writer)
Get the writer size.
.. c:function:: void* PyBytesWriter_GetData(PyBytesWriter *writer)
Get the writer data: start of the internal buffer.
The pointer is valid until :c:func:`PyBytesWriter_Finish` or
:c:func:`PyBytesWriter_Discard` is called on *writer*.
Low-level API
^^^^^^^^^^^^^
.. c:function:: int PyBytesWriter_Resize(PyBytesWriter *writer, Py_ssize_t size)
Resize the writer to *size* bytes. It can be used to enlarge or to
shrink the writer.
This function typically overallocates to achieve amortized performance when
resizing multiple times.
Newly allocated bytes are left uninitialized.
On success, return ``0``.
On error, set an exception and return ``-1``.
*size* must be positive or zero.
.. c:function:: int PyBytesWriter_Grow(PyBytesWriter *writer, Py_ssize_t grow)
Resize the writer by adding *grow* bytes to the current writer size.
This function typically overallocates to achieve amortized performance when
resizing multiple times.
Newly allocated bytes are left uninitialized.
On success, return ``0``.
On error, set an exception and return ``-1``.
*size* can be negative to shrink the writer.
.. c:function:: void* PyBytesWriter_GrowAndUpdatePointer(PyBytesWriter *writer, Py_ssize_t size, void *buf)
Similar to :c:func:`PyBytesWriter_Grow`, but update also the *buf*
pointer.
The *buf* pointer is moved if the internal buffer is moved in memory.
The *buf* relative position within the internal buffer is left
unchanged.
On error, set an exception and return ``NULL``.
*buf* must not be ``NULL``.
Function pseudo-code::
Py_ssize_t pos = (char*)buf - (char*)PyBytesWriter_GetData(writer);
if (PyBytesWriter_Grow(writer, size) < 0) {
return NULL;
}
return (char*)PyBytesWriter_GetData(writer) + pos;

View file

@ -15,13 +15,19 @@ Refer to :ref:`using-capsules` for more information on using these objects.
.. c:type:: PyCapsule
This subtype of :c:type:`PyObject` represents an opaque value, useful for C
extension modules who need to pass an opaque value (as a :c:expr:`void*`
extension modules which need to pass an opaque value (as a :c:expr:`void*`
pointer) through Python code to other C code. It is often used to make a C
function pointer defined in one module available to other modules, so the
regular import mechanism can be used to access C APIs defined in dynamically
loaded modules.
.. c:var:: PyTypeObject PyCapsule_Type
The type object corresponding to capsule objects. This is the same object
as :class:`types.CapsuleType` in the Python layer.
.. c:type:: PyCapsule_Destructor
The type of a destructor callback for a capsule. Defined as::
@ -105,9 +111,19 @@ Refer to :ref:`using-capsules` for more information on using these objects.
``module.attribute``. The *name* stored in the capsule must match this
string exactly.
This function splits *name* on the ``.`` character, and imports the first
element. It then processes further elements using attribute lookups.
Return the capsule's internal *pointer* on success. On failure, set an
exception and return ``NULL``.
.. note::
If *name* points to an attribute of some submodule or subpackage, this
submodule or subpackage must be previously imported using other means
(for example, by using :c:func:`PyImport_ImportModule`) for the
attribute lookups to succeed.
.. versionchanged:: 3.3
*no_block* has no effect anymore.

View file

@ -7,7 +7,7 @@ Cell Objects
"Cell" objects are used to implement variables referenced by multiple scopes.
For each such variable, a cell object is created to store the value; the local
variables of each stack frame that references the value contains a reference to
variables of each stack frame that references the value contain a reference to
the cells from outer scopes which also use that variable. When the value is
accessed, the value contained in the cell is used instead of the cell object
itself. This de-referencing of the cell object requires support from the

View file

@ -182,7 +182,7 @@ bound into a function.
Type of a code object watcher callback function.
If *event* is ``PY_CODE_EVENT_CREATE``, then the callback is invoked
after `co` has been fully initialized. Otherwise, the callback is invoked
after *co* has been fully initialized. Otherwise, the callback is invoked
before the destruction of *co* takes place, so the prior state of *co*
can be inspected.
@ -211,6 +211,82 @@ bound into a function.
.. versionadded:: 3.12
.. c:function:: PyObject *PyCode_Optimize(PyObject *code, PyObject *consts, PyObject *names, PyObject *lnotab_obj)
This is a :term:`soft deprecated` function that does nothing.
Prior to Python 3.10, this function would perform basic optimizations to a
code object.
.. versionchanged:: 3.10
This function now does nothing.
.. _c_codeobject_flags:
Code Object Flags
-----------------
Code objects contain a bit-field of flags, which can be retrieved as the
:attr:`~codeobject.co_flags` Python attribute (for example using
:c:func:`PyObject_GetAttrString`), and set using a *flags* argument to
:c:func:`PyUnstable_Code_New` and similar functions.
Flags whose names start with ``CO_FUTURE_`` correspond to features normally
selectable by :ref:`future statements <future>`. These flags can be used in
:c:member:`PyCompilerFlags.cf_flags`.
Note that many ``CO_FUTURE_`` flags are mandatory in current versions of
Python, and setting them has no effect.
The following flags are available.
For their meaning, see the linked documentation of their Python equivalents.
.. list-table::
:widths: auto
:header-rows: 1
* * Flag
* Meaning
* * .. c:macro:: CO_OPTIMIZED
* :py:data:`inspect.CO_OPTIMIZED`
* * .. c:macro:: CO_NEWLOCALS
* :py:data:`inspect.CO_NEWLOCALS`
* * .. c:macro:: CO_VARARGS
* :py:data:`inspect.CO_VARARGS`
* * .. c:macro:: CO_VARKEYWORDS
* :py:data:`inspect.CO_VARKEYWORDS`
* * .. c:macro:: CO_NESTED
* :py:data:`inspect.CO_NESTED`
* * .. c:macro:: CO_GENERATOR
* :py:data:`inspect.CO_GENERATOR`
* * .. c:macro:: CO_COROUTINE
* :py:data:`inspect.CO_COROUTINE`
* * .. c:macro:: CO_ITERABLE_COROUTINE
* :py:data:`inspect.CO_ITERABLE_COROUTINE`
* * .. c:macro:: CO_ASYNC_GENERATOR
* :py:data:`inspect.CO_ASYNC_GENERATOR`
* * .. c:macro:: CO_HAS_DOCSTRING
* :py:data:`inspect.CO_HAS_DOCSTRING`
* * .. c:macro:: CO_METHOD
* :py:data:`inspect.CO_METHOD`
* * .. c:macro:: CO_FUTURE_DIVISION
* no effect (:py:data:`__future__.division`)
* * .. c:macro:: CO_FUTURE_ABSOLUTE_IMPORT
* no effect (:py:data:`__future__.absolute_import`)
* * .. c:macro:: CO_FUTURE_WITH_STATEMENT
* no effect (:py:data:`__future__.with_statement`)
* * .. c:macro:: CO_FUTURE_PRINT_FUNCTION
* no effect (:py:data:`__future__.print_function`)
* * .. c:macro:: CO_FUTURE_UNICODE_LITERALS
* no effect (:py:data:`__future__.unicode_literals`)
* * .. c:macro:: CO_FUTURE_GENERATOR_STOP
* no effect (:py:data:`__future__.generator_stop`)
* * .. c:macro:: CO_FUTURE_ANNOTATIONS
* :py:data:`__future__.annotations`
Extra information
-----------------
@ -224,7 +300,7 @@ may change without deprecation warnings.
.. c:function:: Py_ssize_t PyUnstable_Eval_RequestCodeExtraIndex(freefunc free)
Return a new an opaque index value used to adding data to code objects.
Return a new opaque index value used to adding data to code objects.
You generally call this function once (per interpreter) and use the result
with ``PyCode_GetExtra`` and ``PyCode_SetExtra`` to manipulate

View file

@ -7,7 +7,7 @@ Codec registry and support functions
Register a new codec search function.
As side effect, this tries to load the :mod:`!encodings` package, if not yet
As a side effect, this tries to load the :mod:`!encodings` package, if not yet
done, to make sure that it is always first in the list of search functions.
.. c:function:: int PyCodec_Unregister(PyObject *search_function)
@ -39,7 +39,7 @@ Codec registry and support functions
*object* is passed through the decoder function found for the given
*encoding* using the error handling method defined by *errors*. *errors* may
be ``NULL`` to use the default method defined for the codec. Raises a
:exc:`LookupError` if no encoder can be found.
:exc:`LookupError` if no decoder can be found.
Codec lookup API
@ -129,3 +129,13 @@ Registry API for Unicode encoding error handlers
Replace the unicode encode error with ``\N{...}`` escapes.
.. versionadded:: 3.5
Codec utility variables
-----------------------
.. c:var:: const char *Py_hexdigits
A string constant containing the lowercase hexadecimal digits: ``"0123456789abcdef"``.
.. versionadded:: 3.3

View file

@ -3,93 +3,25 @@
.. _complexobjects:
Complex Number Objects
----------------------
======================
.. index:: pair: object; complex number
Python's complex number objects are implemented as two distinct types when
viewed from the C API: one is the Python object exposed to Python programs, and
the other is a C structure which represents the actual complex number value.
The API provides functions for working with both.
Complex Numbers as C Structures
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Note that the functions which accept these structures as parameters and return
them as results do so *by value* rather than dereferencing them through
pointers. This is consistent throughout the API.
.. c:type:: Py_complex
The C structure which corresponds to the value portion of a Python complex
number object. Most of the functions for dealing with complex number objects
use structures of this type as input or output values, as appropriate.
.. c:member:: double real
double imag
The structure is defined as::
typedef struct {
double real;
double imag;
} Py_complex;
.. c:function:: Py_complex _Py_c_sum(Py_complex left, Py_complex right)
Return the sum of two complex numbers, using the C :c:type:`Py_complex`
representation.
.. c:function:: Py_complex _Py_c_diff(Py_complex left, Py_complex right)
Return the difference between two complex numbers, using the C
:c:type:`Py_complex` representation.
.. c:function:: Py_complex _Py_c_neg(Py_complex num)
Return the negation of the complex number *num*, using the C
:c:type:`Py_complex` representation.
.. c:function:: Py_complex _Py_c_prod(Py_complex left, Py_complex right)
Return the product of two complex numbers, using the C :c:type:`Py_complex`
representation.
.. c:function:: Py_complex _Py_c_quot(Py_complex dividend, Py_complex divisor)
Return the quotient of two complex numbers, using the C :c:type:`Py_complex`
representation.
If *divisor* is null, this method returns zero and sets
:c:data:`errno` to :c:macro:`!EDOM`.
.. c:function:: Py_complex _Py_c_pow(Py_complex num, Py_complex exp)
Return the exponentiation of *num* by *exp*, using the C :c:type:`Py_complex`
representation.
If *num* is null and *exp* is not a positive real number,
this method returns zero and sets :c:data:`errno` to :c:macro:`!EDOM`.
Set :c:data:`errno` to :c:macro:`!ERANGE` on overflows.
Complex Numbers as Python Objects
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. c:type:: PyComplexObject
This subtype of :c:type:`PyObject` represents a Python complex number object.
.. c:member:: Py_complex cval
The complex number value, using the C :c:type:`Py_complex` representation.
.. deprecated-removed:: 3.15 3.20
Use :c:func:`PyComplex_AsCComplex` and
:c:func:`PyComplex_FromCComplex` to convert a
Python complex number to/from the C :c:type:`Py_complex`
representation.
.. c:var:: PyTypeObject PyComplex_Type
@ -109,12 +41,6 @@ Complex Numbers as Python Objects
:c:type:`PyComplexObject`. This function always succeeds.
.. c:function:: PyObject* PyComplex_FromCComplex(Py_complex v)
Create a new Python complex number object from a C :c:type:`Py_complex` value.
Return ``NULL`` with an exception set on error.
.. c:function:: PyObject* PyComplex_FromDoubles(double real, double imag)
Return a new :c:type:`PyComplexObject` object from *real* and *imag*.
@ -153,6 +79,29 @@ Complex Numbers as Python Objects
.. versionchanged:: 3.13
Use :meth:`~object.__complex__` if available.
.. c:type:: Py_complex
This C structure defines an export format for a Python complex
number object.
.. c:member:: double real
double imag
The structure is defined as::
typedef struct {
double real;
double imag;
} Py_complex;
.. c:function:: PyObject* PyComplex_FromCComplex(Py_complex v)
Create a new Python complex number object from a C :c:type:`Py_complex` value.
Return ``NULL`` with an exception set on error.
.. c:function:: Py_complex PyComplex_AsCComplex(PyObject *op)
Return the :c:type:`Py_complex` value of the complex number *op*.
@ -169,3 +118,82 @@ Complex Numbers as Python Objects
.. versionchanged:: 3.8
Use :meth:`~object.__index__` if available.
Complex Numbers as C Structures
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The API also provides functions for working with complex numbers, using the
:c:type:`Py_complex` representation. Note that the functions which accept
these structures as parameters and return them as results do so *by value*
rather than dereferencing them through pointers.
Please note, that these functions are :term:`soft deprecated` since Python
3.15. Avoid using this API in a new code to do complex arithmetic: either use
the `Number Protocol <number>`_ API or use native complex types, like
:c:expr:`double complex`.
.. c:function:: Py_complex _Py_c_sum(Py_complex left, Py_complex right)
Return the sum of two complex numbers, using the C :c:type:`Py_complex`
representation.
.. deprecated:: 3.15
.. c:function:: Py_complex _Py_c_diff(Py_complex left, Py_complex right)
Return the difference between two complex numbers, using the C
:c:type:`Py_complex` representation.
.. deprecated:: 3.15
.. c:function:: Py_complex _Py_c_neg(Py_complex num)
Return the negation of the complex number *num*, using the C
:c:type:`Py_complex` representation.
.. deprecated:: 3.15
.. c:function:: Py_complex _Py_c_prod(Py_complex left, Py_complex right)
Return the product of two complex numbers, using the C :c:type:`Py_complex`
representation.
.. deprecated:: 3.15
.. c:function:: Py_complex _Py_c_quot(Py_complex dividend, Py_complex divisor)
Return the quotient of two complex numbers, using the C :c:type:`Py_complex`
representation.
If *divisor* is null, this method returns zero and sets
:c:data:`errno` to :c:macro:`!EDOM`.
.. deprecated:: 3.15
.. c:function:: Py_complex _Py_c_pow(Py_complex num, Py_complex exp)
Return the exponentiation of *num* by *exp*, using the C :c:type:`Py_complex`
representation.
If *num* is null and *exp* is not a positive real number,
this method returns zero and sets :c:data:`errno` to :c:macro:`!EDOM`.
Set :c:data:`errno` to :c:macro:`!ERANGE` on overflows.
.. deprecated:: 3.15
.. c:function:: double _Py_c_abs(Py_complex num)
Return the absolute value of the complex number *num*.
Set :c:data:`errno` to :c:macro:`!ERANGE` on overflows.
.. deprecated:: 3.15

View file

@ -109,11 +109,20 @@ Other Objects
descriptor.rst
slice.rst
memoryview.rst
picklebuffer.rst
weakref.rst
capsule.rst
frame.rst
gen.rst
coro.rst
contextvars.rst
datetime.rst
typehints.rst
C API for extension modules
===========================
.. toctree::
curses.rst
datetime.rst

View file

@ -41,7 +41,7 @@ The return value (*rv*) for these functions should be interpreted as follows:
``rv + 1`` bytes would have been needed to succeed. ``str[size-1]`` is ``'\0'``
in this case.
* When ``rv < 0``, "something bad happened." ``str[size-1]`` is ``'\0'`` in
* When ``rv < 0``, the output conversion failed and ``str[size-1]`` is ``'\0'`` in
this case too, but the rest of *str* is undefined. The exact cause of the error
depends on the underlying platform.
@ -105,7 +105,7 @@ The following functions provide locale-independent string to number conversions.
If ``s`` represents a value that is too large to store in a float
(for example, ``"1e500"`` is such a string on many platforms) then
if ``overflow_exception`` is ``NULL`` return ``Py_INFINITY`` (with
if ``overflow_exception`` is ``NULL`` return :c:macro:`!INFINITY` (with
an appropriate sign) and don't set any exception. Otherwise,
``overflow_exception`` must point to a Python exception object;
raise that exception and return ``-1.0``. In both cases, set
@ -128,18 +128,28 @@ The following functions provide locale-independent string to number conversions.
must be 0 and is ignored. The ``'r'`` format code specifies the
standard :func:`repr` format.
*flags* can be zero or more of the values ``Py_DTSF_SIGN``,
``Py_DTSF_ADD_DOT_0``, or ``Py_DTSF_ALT``, or-ed together:
*flags* can be zero or more of the following values or-ed together:
* ``Py_DTSF_SIGN`` means to always precede the returned string with a sign
character, even if *val* is non-negative.
.. c:macro:: Py_DTSF_SIGN
* ``Py_DTSF_ADD_DOT_0`` means to ensure that the returned string will not look
like an integer.
Always precede the returned string with a sign
character, even if *val* is non-negative.
* ``Py_DTSF_ALT`` means to apply "alternate" formatting rules. See the
documentation for the :c:func:`PyOS_snprintf` ``'#'`` specifier for
details.
.. c:macro:: Py_DTSF_ADD_DOT_0
Ensure that the returned string will not look like an integer.
.. c:macro:: Py_DTSF_ALT
Apply "alternate" formatting rules.
See the documentation for the :c:func:`PyOS_snprintf` ``'#'`` specifier for
details.
.. c:macro:: Py_DTSF_NO_NEG_0
Negative zero is converted to positive zero.
.. versionadded:: 3.11
If *ptype* is non-``NULL``, then the value it points to will be set to one of
``Py_DTST_FINITE``, ``Py_DTST_INFINITE``, or ``Py_DTST_NAN``, signifying that
@ -152,13 +162,85 @@ The following functions provide locale-independent string to number conversions.
.. versionadded:: 3.1
.. c:function:: int PyOS_stricmp(const char *s1, const char *s2)
.. c:function:: int PyOS_mystricmp(const char *str1, const char *str2)
int PyOS_mystrnicmp(const char *str1, const char *str2, Py_ssize_t size)
Case insensitive comparison of strings. The function works almost
identically to :c:func:`!strcmp` except that it ignores the case.
Case insensitive comparison of strings. These functions work almost
identically to :c:func:`!strcmp` and :c:func:`!strncmp` (respectively),
except that they ignore the case of ASCII characters.
Return ``0`` if the strings are equal, a negative value if *str1* sorts
lexicographically before *str2*, or a positive value if it sorts after.
In the *str1* or *str2* arguments, a NUL byte marks the end of the string.
For :c:func:`!PyOS_mystrnicmp`, the *size* argument gives the maximum size
of the string, as if NUL was present at the index given by *size*.
These functions do not use the locale.
.. c:function:: int PyOS_strnicmp(const char *s1, const char *s2, Py_ssize_t size)
.. c:function:: int PyOS_stricmp(const char *str1, const char *str2)
int PyOS_strnicmp(const char *str1, const char *str2, Py_ssize_t size)
Case insensitive comparison of strings. The function works almost
identically to :c:func:`!strncmp` except that it ignores the case.
Case insensitive comparison of strings.
On Windows, these are aliases of :c:func:`!stricmp` and :c:func:`!strnicmp`,
respectively.
On other platforms, they are aliases of :c:func:`PyOS_mystricmp` and
:c:func:`PyOS_mystrnicmp`, respectively.
Character classification and conversion
=======================================
The following macros provide locale-independent (unlike the C standard library
``ctype.h``) character classification and conversion.
The argument must be a signed or unsigned :c:expr:`char`.
.. c:macro:: Py_ISALNUM(c)
Return true if the character *c* is an alphanumeric character.
.. c:macro:: Py_ISALPHA(c)
Return true if the character *c* is an alphabetic character (``a-z`` and ``A-Z``).
.. c:macro:: Py_ISDIGIT(c)
Return true if the character *c* is a decimal digit (``0-9``).
.. c:macro:: Py_ISLOWER(c)
Return true if the character *c* is a lowercase ASCII letter (``a-z``).
.. c:macro:: Py_ISUPPER(c)
Return true if the character *c* is an uppercase ASCII letter (``A-Z``).
.. c:macro:: Py_ISSPACE(c)
Return true if the character *c* is a whitespace character (space, tab,
carriage return, newline, vertical tab, or form feed).
.. c:macro:: Py_ISXDIGIT(c)
Return true if the character *c* is a hexadecimal digit (``0-9``, ``a-f``, and
``A-F``).
.. c:macro:: Py_TOLOWER(c)
Return the lowercase equivalent of the character *c*.
.. c:macro:: Py_TOUPPER(c)
Return the uppercase equivalent of the character *c*.

138
Doc/c-api/curses.rst Normal file
View file

@ -0,0 +1,138 @@
.. highlight:: c
Curses C API
------------
:mod:`curses` exposes a small C interface for extension modules.
Consumers must include the header file :file:`py_curses.h` (which is not
included by default by :file:`Python.h`) and :c:func:`import_curses` must
be invoked, usually as part of the module initialisation function, to populate
:c:var:`PyCurses_API`.
.. warning::
Neither the C API nor the pure Python :mod:`curses` module are compatible
with subinterpreters.
.. c:macro:: import_curses()
Import the curses C API. The macro does not need a semi-colon to be called.
On success, populate the :c:var:`PyCurses_API` pointer.
On failure, set :c:var:`PyCurses_API` to NULL and set an exception.
The caller must check if an error occurred via :c:func:`PyErr_Occurred`:
.. code-block::
import_curses(); // semi-colon is optional but recommended
if (PyErr_Occurred()) { /* cleanup */ }
.. c:var:: void **PyCurses_API
Dynamically allocated object containing the curses C API.
This variable is only available once :c:macro:`import_curses` succeeds.
``PyCurses_API[0]`` corresponds to :c:data:`PyCursesWindow_Type`.
``PyCurses_API[1]``, ``PyCurses_API[2]``, and ``PyCurses_API[3]``
are pointers to predicate functions of type ``int (*)(void)``.
When called, these predicates return whether :func:`curses.setupterm`,
:func:`curses.initscr`, and :func:`curses.start_color` have been called
respectively.
See also the convenience macros :c:macro:`PyCursesSetupTermCalled`,
:c:macro:`PyCursesInitialised`, and :c:macro:`PyCursesInitialisedColor`.
.. note::
The number of entries in this structure is subject to changes.
Consider using :c:macro:`PyCurses_API_pointers` to check if
new fields are available or not.
.. c:macro:: PyCurses_API_pointers
The number of accessible fields (``4``) in :c:var:`PyCurses_API`.
This number is incremented whenever new fields are added.
.. c:var:: PyTypeObject PyCursesWindow_Type
The :ref:`heap type <heap-types>` corresponding to :class:`curses.window`.
.. c:function:: int PyCursesWindow_Check(PyObject *op)
Return true if *op* is a :class:`curses.window` instance, false otherwise.
The following macros are convenience macros expanding into C statements.
In particular, they can only be used as ``macro;`` or ``macro``, but not
``macro()`` or ``macro();``.
.. c:macro:: PyCursesSetupTermCalled
Macro checking if :func:`curses.setupterm` has been called.
The macro expansion is roughly equivalent to:
.. code-block::
{
typedef int (*predicate_t)(void);
predicate_t was_setupterm_called = (predicate_t)PyCurses_API[1];
if (!was_setupterm_called()) {
return NULL;
}
}
.. c:macro:: PyCursesInitialised
Macro checking if :func:`curses.initscr` has been called.
The macro expansion is roughly equivalent to:
.. code-block::
{
typedef int (*predicate_t)(void);
predicate_t was_initscr_called = (predicate_t)PyCurses_API[2];
if (!was_initscr_called()) {
return NULL;
}
}
.. c:macro:: PyCursesInitialisedColor
Macro checking if :func:`curses.start_color` has been called.
The macro expansion is roughly equivalent to:
.. code-block::
{
typedef int (*predicate_t)(void);
predicate_t was_start_color_called = (predicate_t)PyCurses_API[3];
if (!was_start_color_called()) {
return NULL;
}
}
Internal data
-------------
The following objects are exposed by the C API but should be considered
internal-only.
.. c:macro:: PyCurses_CAPSULE_NAME
Name of the curses capsule to pass to :c:func:`PyCapsule_Import`.
Internal usage only. Use :c:macro:`import_curses` instead.

View file

@ -8,11 +8,42 @@ DateTime Objects
Various date and time objects are supplied by the :mod:`datetime` module.
Before using any of these functions, the header file :file:`datetime.h` must be
included in your source (note that this is not included by :file:`Python.h`),
and the macro :c:macro:`!PyDateTime_IMPORT` must be invoked, usually as part of
and the macro :c:macro:`PyDateTime_IMPORT` must be invoked, usually as part of
the module initialisation function. The macro puts a pointer to a C structure
into a static variable, :c:data:`!PyDateTimeAPI`, that is used by the following
into a static variable, :c:data:`PyDateTimeAPI`, that is used by the following
macros.
.. c:macro:: PyDateTime_IMPORT()
Import the datetime C API.
On success, populate the :c:var:`PyDateTimeAPI` pointer.
On failure, set :c:var:`PyDateTimeAPI` to ``NULL`` and set an exception.
The caller must check if an error occurred via :c:func:`PyErr_Occurred`:
.. code-block::
PyDateTime_IMPORT;
if (PyErr_Occurred()) { /* cleanup */ }
.. warning::
This is not compatible with subinterpreters.
.. c:type:: PyDateTime_CAPI
Structure containing the fields for the datetime C API.
The fields of this structure are private and subject to change.
Do not use this directly; prefer ``PyDateTime_*`` APIs instead.
.. c:var:: PyDateTime_CAPI *PyDateTimeAPI
Dynamically allocated object containing the datetime C API.
This variable is only available once :c:macro:`PyDateTime_IMPORT` succeeds.
.. c:type:: PyDateTime_Date
This subtype of :c:type:`PyObject` represents a Python date object.
@ -46,7 +77,7 @@ macros.
.. c:var:: PyTypeObject PyDateTime_DeltaType
This instance of :c:type:`PyTypeObject` represents Python type for
This instance of :c:type:`PyTypeObject` represents the Python type for
the difference between two datetime values;
it is the same object as :class:`datetime.timedelta` in the Python layer.
@ -325,3 +356,16 @@ Macros for the convenience of modules implementing the DB API:
Create and return a new :class:`datetime.date` object given an argument
tuple suitable for passing to :meth:`datetime.date.fromtimestamp`.
Internal data
-------------
The following symbols are exposed by the C API but should be considered
internal-only.
.. c:macro:: PyDateTime_CAPSULE_NAME
Name of the datetime capsule to pass to :c:func:`PyCapsule_Import`.
Internal usage only. Use :c:macro:`PyDateTime_IMPORT` instead.

View file

@ -21,20 +21,104 @@ found in the dictionary of type objects.
.. c:function:: PyObject* PyDescr_NewMember(PyTypeObject *type, struct PyMemberDef *meth)
.. c:var:: PyTypeObject PyMemberDescr_Type
The type object for member descriptor objects created from
:c:type:`PyMemberDef` structures. These descriptors expose fields of a
C struct as attributes on a type, and correspond
to :class:`types.MemberDescriptorType` objects in Python.
.. c:var:: PyTypeObject PyGetSetDescr_Type
The type object for get/set descriptor objects created from
:c:type:`PyGetSetDef` structures. These descriptors implement attributes
whose value is computed by C getter and setter functions, and are used
for many built-in type attributes.
.. c:function:: PyObject* PyDescr_NewMethod(PyTypeObject *type, struct PyMethodDef *meth)
.. c:var:: PyTypeObject PyMethodDescr_Type
The type object for method descriptor objects created from
:c:type:`PyMethodDef` structures. These descriptors expose C functions as
methods on a type, and correspond to :class:`types.MemberDescriptorType`
objects in Python.
.. c:function:: PyObject* PyDescr_NewWrapper(PyTypeObject *type, struct wrapperbase *wrapper, void *wrapped)
.. c:var:: PyTypeObject PyWrapperDescr_Type
The type object for wrapper descriptor objects created by
:c:func:`PyDescr_NewWrapper` and :c:func:`PyWrapper_New`. Wrapper
descriptors are used internally to expose special methods implemented
via wrapper structures, and appear in Python as
:class:`types.WrapperDescriptorType` objects.
.. c:function:: PyObject* PyDescr_NewClassMethod(PyTypeObject *type, PyMethodDef *method)
.. c:function:: int PyDescr_IsData(PyObject *descr)
Return non-zero if the descriptor objects *descr* describes a data attribute, or
Return non-zero if the descriptor object *descr* describes a data attribute, or
``0`` if it describes a method. *descr* must be a descriptor object; there is
no error checking.
.. c:function:: PyObject* PyWrapper_New(PyObject *, PyObject *)
Built-in descriptors
^^^^^^^^^^^^^^^^^^^^
.. c:var:: PyTypeObject PySuper_Type
The type object for super objects. This is the same object as
:class:`super` in the Python layer.
.. c:var:: PyTypeObject PyClassMethod_Type
The type of class method objects. This is the same object as
:class:`classmethod` in the Python layer.
.. c:var:: PyTypeObject PyClassMethodDescr_Type
The type object for C-level class method descriptor objects.
This is the type of the descriptors created for :func:`classmethod` defined in
C extension types, and is the same object as :class:`classmethod`
in Python.
.. c:function:: PyObject *PyClassMethod_New(PyObject *callable)
Create a new :class:`classmethod` object wrapping *callable*.
*callable* must be a callable object and must not be ``NULL``.
On success, this function returns a :term:`strong reference` to a new class
method descriptor. On failure, this function returns ``NULL`` with an
exception set.
.. c:var:: PyTypeObject PyStaticMethod_Type
The type of static method objects. This is the same object as
:class:`staticmethod` in the Python layer.
.. c:function:: PyObject *PyStaticMethod_New(PyObject *callable)
Create a new :class:`staticmethod` object wrapping *callable*.
*callable* must be a callable object and must not be ``NULL``.
On success, this function returns a :term:`strong reference` to a new static
method descriptor. On failure, this function returns ``NULL`` with an
exception set.

View file

@ -43,6 +43,17 @@ Dictionary Objects
prevent modification of the dictionary for non-dynamic class types.
.. c:var:: PyTypeObject PyDictProxy_Type
The type object for mapping proxy objects created by
:c:func:`PyDictProxy_New` and for the read-only ``__dict__`` attribute
of many built-in types. A :c:type:`PyDictProxy_Type` instance provides a
dynamic, read-only view of an underlying dictionary: changes to the
underlying dictionary are reflected in the proxy, but the proxy itself
does not support mutation operations. This corresponds to
:class:`types.MappingProxyType` in Python.
.. c:function:: void PyDict_Clear(PyObject *p)
Empty an existing dictionary of all key-value pairs.
@ -50,7 +61,7 @@ Dictionary Objects
.. c:function:: int PyDict_Contains(PyObject *p, PyObject *key)
Determine if dictionary *p* contains *key*. If an item in *p* is matches
Determine if dictionary *p* contains *key*. If an item in *p* matches
*key*, return ``1``, otherwise return ``0``. On error, return ``-1``.
This is equivalent to the Python expression ``key in p``.
@ -198,7 +209,7 @@ Dictionary Objects
.. c:function:: int PyDict_Pop(PyObject *p, PyObject *key, PyObject **result)
Remove *key* from dictionary *p* and optionally return the removed value.
Do not raise :exc:`KeyError` if the key missing.
Do not raise :exc:`KeyError` if the key is missing.
- If the key is present, set *\*result* to a new reference to the removed
value if *result* is not ``NULL``, and return ``1``.
@ -207,7 +218,7 @@ Dictionary Objects
- On error, raise an exception and return ``-1``.
Similar to :meth:`dict.pop`, but without the default value and
not raising :exc:`KeyError` if the key missing.
not raising :exc:`KeyError` if the key is missing.
.. versionadded:: 3.13
@ -245,6 +256,11 @@ Dictionary Objects
``len(p)`` on a dictionary.
.. c:function:: Py_ssize_t PyDict_GET_SIZE(PyObject *p)
Similar to :c:func:`PyDict_Size`, but without error checking.
.. c:function:: int PyDict_Next(PyObject *p, Py_ssize_t *ppos, PyObject **pkey, PyObject **pvalue)
Iterate over all key-value pairs in the dictionary *p*. The
@ -301,6 +317,15 @@ Dictionary Objects
}
Py_END_CRITICAL_SECTION();
.. note::
On the free-threaded build, this function can be used safely inside a
critical section. However, the references returned for *pkey* and *pvalue*
are :term:`borrowed <borrowed reference>` and are only valid while the
critical section is held. If you need to use these objects outside the
critical section or when the critical section can be suspended, create a
:term:`strong reference <strong reference>` (for example, using
:c:func:`Py_NewRef`).
.. c:function:: int PyDict_Merge(PyObject *a, PyObject *b, int override)
@ -417,3 +442,138 @@ Dictionary Objects
it before returning.
.. versionadded:: 3.12
Dictionary View Objects
^^^^^^^^^^^^^^^^^^^^^^^
.. c:function:: int PyDictViewSet_Check(PyObject *op)
Return true if *op* is a view of a set inside a dictionary. This is currently
equivalent to :c:expr:`PyDictKeys_Check(op) || PyDictItems_Check(op)`. This
function always succeeds.
.. c:var:: PyTypeObject PyDictKeys_Type
Type object for a view of dictionary keys. In Python, this is the type of
the object returned by :meth:`dict.keys`.
.. c:function:: int PyDictKeys_Check(PyObject *op)
Return true if *op* is an instance of a dictionary keys view. This function
always succeeds.
.. c:var:: PyTypeObject PyDictValues_Type
Type object for a view of dictionary values. In Python, this is the type of
the object returned by :meth:`dict.values`.
.. c:function:: int PyDictValues_Check(PyObject *op)
Return true if *op* is an instance of a dictionary values view. This function
always succeeds.
.. c:var:: PyTypeObject PyDictItems_Type
Type object for a view of dictionary items. In Python, this is the type of
the object returned by :meth:`dict.items`.
.. c:function:: int PyDictItems_Check(PyObject *op)
Return true if *op* is an instance of a dictionary items view. This function
always succeeds.
Ordered Dictionaries
^^^^^^^^^^^^^^^^^^^^
Python's C API provides interface for :class:`collections.OrderedDict` from C.
Since Python 3.7, dictionaries are ordered by default, so there is usually
little need for these functions; prefer ``PyDict*`` where possible.
.. c:var:: PyTypeObject PyODict_Type
Type object for ordered dictionaries. This is the same object as
:class:`collections.OrderedDict` in the Python layer.
.. c:function:: int PyODict_Check(PyObject *od)
Return true if *od* is an ordered dictionary object or an instance of a
subtype of the :class:`~collections.OrderedDict` type. This function
always succeeds.
.. c:function:: int PyODict_CheckExact(PyObject *od)
Return true if *od* is an ordered dictionary object, but not an instance of
a subtype of the :class:`~collections.OrderedDict` type.
This function always succeeds.
.. c:var:: PyTypeObject PyODictKeys_Type
Analogous to :c:type:`PyDictKeys_Type` for ordered dictionaries.
.. c:var:: PyTypeObject PyODictValues_Type
Analogous to :c:type:`PyDictValues_Type` for ordered dictionaries.
.. c:var:: PyTypeObject PyODictItems_Type
Analogous to :c:type:`PyDictItems_Type` for ordered dictionaries.
.. c:function:: PyObject *PyODict_New(void)
Return a new empty ordered dictionary, or ``NULL`` on failure.
This is analogous to :c:func:`PyDict_New`.
.. c:function:: int PyODict_SetItem(PyObject *od, PyObject *key, PyObject *value)
Insert *value* into the ordered dictionary *od* with a key of *key*.
Return ``0`` on success or ``-1`` with an exception set on failure.
This is analogous to :c:func:`PyDict_SetItem`.
.. c:function:: int PyODict_DelItem(PyObject *od, PyObject *key)
Remove the entry in the ordered dictionary *od* with key *key*.
Return ``0`` on success or ``-1`` with an exception set on failure.
This is analogous to :c:func:`PyDict_DelItem`.
These are :term:`soft deprecated` aliases to ``PyDict`` APIs:
.. list-table::
:widths: auto
:header-rows: 1
* * ``PyODict``
* ``PyDict``
* * .. c:macro:: PyODict_GetItem(od, key)
* :c:func:`PyDict_GetItem`
* * .. c:macro:: PyODict_GetItemWithError(od, key)
* :c:func:`PyDict_GetItemWithError`
* * .. c:macro:: PyODict_GetItemString(od, key)
* :c:func:`PyDict_GetItemString`
* * .. c:macro:: PyODict_Contains(od, key)
* :c:func:`PyDict_Contains`
* * .. c:macro:: PyODict_Size(od)
* :c:func:`PyDict_Size`
* * .. c:macro:: PyODict_SIZE(od)
* :c:func:`PyDict_GET_SIZE`

View file

@ -309,6 +309,14 @@ For convenience, some of these functions will always return a
.. versionadded:: 3.4
.. c:function:: void PyErr_RangedSyntaxLocationObject(PyObject *filename, int lineno, int col_offset, int end_lineno, int end_col_offset)
Similar to :c:func:`PyErr_SyntaxLocationObject`, but also sets the
*end_lineno* and *end_col_offset* information for the current exception.
.. versionadded:: 3.10
.. c:function:: void PyErr_SyntaxLocationEx(const char *filename, int lineno, int col_offset)
Like :c:func:`PyErr_SyntaxLocationObject`, but *filename* is a byte string
@ -331,6 +339,23 @@ For convenience, some of these functions will always return a
use.
.. c:function:: PyObject *PyErr_ProgramTextObject(PyObject *filename, int lineno)
Get the source line in *filename* at line *lineno*. *filename* should be a
Python :class:`str` object.
On success, this function returns a Python string object with the found line.
On failure, this function returns ``NULL`` without an exception set.
.. c:function:: PyObject *PyErr_ProgramText(const char *filename, int lineno)
Similar to :c:func:`PyErr_ProgramTextObject`, but *filename* is a
:c:expr:`const char *`, which is decoded with the
:term:`filesystem encoding and error handler`, instead of a
Python object reference.
Issuing warnings
================
@ -394,6 +419,15 @@ an error value).
.. versionadded:: 3.2
.. c:function:: int PyErr_WarnExplicitFormat(PyObject *category, const char *filename, int lineno, const char *module, PyObject *registry, const char *format, ...)
Similar to :c:func:`PyErr_WarnExplicit`, but uses
:c:func:`PyUnicode_FromFormat` to format the warning message. *format* is
an ASCII-encoded string.
.. versionadded:: 3.2
.. c:function:: int PyErr_ResourceWarning(PyObject *source, Py_ssize_t stack_level, const char *format, ...)
Function similar to :c:func:`PyErr_WarnFormat`, but *category* is
@ -749,9 +783,30 @@ Exception Classes
.. versionadded:: 3.2
.. c:function:: int PyExceptionClass_Check(PyObject *ob)
Return non-zero if *ob* is an exception class, zero otherwise. This function always succeeds.
.. c:function:: const char *PyExceptionClass_Name(PyObject *ob)
Return :c:member:`~PyTypeObject.tp_name` of the exception class *ob*.
Exception Objects
=================
.. c:function:: int PyExceptionInstance_Check(PyObject *op)
Return true if *op* is an instance of :class:`BaseException`, false
otherwise. This function always succeeds.
.. c:macro:: PyExceptionInstance_Class(op)
Equivalent to :c:func:`Py_TYPE(op) <Py_TYPE>`.
.. c:function:: PyObject* PyException_GetTraceback(PyObject *ex)
Return the traceback associated with the exception as a new reference, as
@ -929,6 +984,9 @@ because the :ref:`call protocol <call>` takes care of recursion handling.
be concatenated to the :exc:`RecursionError` message caused by the recursion
depth limit.
.. seealso::
The :c:func:`PyUnstable_ThreadState_SetStackProtection` function.
.. versionchanged:: 3.9
This function is now also available in the :ref:`limited API <limited-c-api>`.
@ -969,184 +1027,159 @@ these are the C equivalent to :func:`reprlib.recursive_repr`.
Ends a :c:func:`Py_ReprEnter`. Must be called once for each
invocation of :c:func:`Py_ReprEnter` that returns zero.
.. c:function:: int Py_GetRecursionLimit(void)
Get the recursion limit for the current interpreter. It can be set with
:c:func:`Py_SetRecursionLimit`. The recursion limit prevents the
Python interpreter stack from growing infinitely.
This function cannot fail, and the caller must hold an
:term:`attached thread state`.
.. seealso::
:py:func:`sys.getrecursionlimit`
.. c:function:: void Py_SetRecursionLimit(int new_limit)
Set the recursion limit for the current interpreter.
This function cannot fail, and the caller must hold an
:term:`attached thread state`.
.. seealso::
:py:func:`sys.setrecursionlimit`
.. _standardexceptions:
Standard Exceptions
===================
Exception and warning types
===========================
All standard Python exceptions are available as global variables whose names are
``PyExc_`` followed by the Python exception name. These have the type
:c:expr:`PyObject*`; they are all class objects. For completeness, here are all
the variables:
All standard Python exceptions and warning categories are available as global
variables whose names are ``PyExc_`` followed by the Python exception name.
These have the type :c:expr:`PyObject*`; they are all class objects.
.. index::
single: PyExc_BaseException (C var)
single: PyExc_Exception (C var)
single: PyExc_ArithmeticError (C var)
single: PyExc_AssertionError (C var)
single: PyExc_AttributeError (C var)
single: PyExc_BlockingIOError (C var)
single: PyExc_BrokenPipeError (C var)
single: PyExc_BufferError (C var)
single: PyExc_ChildProcessError (C var)
single: PyExc_ConnectionAbortedError (C var)
single: PyExc_ConnectionError (C var)
single: PyExc_ConnectionRefusedError (C var)
single: PyExc_ConnectionResetError (C var)
single: PyExc_EOFError (C var)
single: PyExc_FileExistsError (C var)
single: PyExc_FileNotFoundError (C var)
single: PyExc_FloatingPointError (C var)
single: PyExc_GeneratorExit (C var)
single: PyExc_ImportError (C var)
single: PyExc_IndentationError (C var)
single: PyExc_IndexError (C var)
single: PyExc_InterruptedError (C var)
single: PyExc_IsADirectoryError (C var)
single: PyExc_KeyError (C var)
single: PyExc_KeyboardInterrupt (C var)
single: PyExc_LookupError (C var)
single: PyExc_MemoryError (C var)
single: PyExc_ModuleNotFoundError (C var)
single: PyExc_NameError (C var)
single: PyExc_NotADirectoryError (C var)
single: PyExc_NotImplementedError (C var)
single: PyExc_OSError (C var)
single: PyExc_OverflowError (C var)
single: PyExc_PermissionError (C var)
single: PyExc_ProcessLookupError (C var)
single: PyExc_PythonFinalizationError (C var)
single: PyExc_RecursionError (C var)
single: PyExc_ReferenceError (C var)
single: PyExc_RuntimeError (C var)
single: PyExc_StopAsyncIteration (C var)
single: PyExc_StopIteration (C var)
single: PyExc_SyntaxError (C var)
single: PyExc_SystemError (C var)
single: PyExc_SystemExit (C var)
single: PyExc_TabError (C var)
single: PyExc_TimeoutError (C var)
single: PyExc_TypeError (C var)
single: PyExc_UnboundLocalError (C var)
single: PyExc_UnicodeDecodeError (C var)
single: PyExc_UnicodeEncodeError (C var)
single: PyExc_UnicodeError (C var)
single: PyExc_UnicodeTranslateError (C var)
single: PyExc_ValueError (C var)
single: PyExc_ZeroDivisionError (C var)
For completeness, here are all the variables:
+-----------------------------------------+---------------------------------+----------+
| C Name | Python Name | Notes |
+=========================================+=================================+==========+
| :c:data:`PyExc_BaseException` | :exc:`BaseException` | [1]_ |
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_Exception` | :exc:`Exception` | [1]_ |
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_ArithmeticError` | :exc:`ArithmeticError` | [1]_ |
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_AssertionError` | :exc:`AssertionError` | |
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_AttributeError` | :exc:`AttributeError` | |
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_BlockingIOError` | :exc:`BlockingIOError` | |
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_BrokenPipeError` | :exc:`BrokenPipeError` | |
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_BufferError` | :exc:`BufferError` | |
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_ChildProcessError` | :exc:`ChildProcessError` | |
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_ConnectionAbortedError` | :exc:`ConnectionAbortedError` | |
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_ConnectionError` | :exc:`ConnectionError` | |
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_ConnectionRefusedError` | :exc:`ConnectionRefusedError` | |
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_ConnectionResetError` | :exc:`ConnectionResetError` | |
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_EOFError` | :exc:`EOFError` | |
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_FileExistsError` | :exc:`FileExistsError` | |
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_FileNotFoundError` | :exc:`FileNotFoundError` | |
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_FloatingPointError` | :exc:`FloatingPointError` | |
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_GeneratorExit` | :exc:`GeneratorExit` | |
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_ImportError` | :exc:`ImportError` | |
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_IndentationError` | :exc:`IndentationError` | |
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_IndexError` | :exc:`IndexError` | |
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_InterruptedError` | :exc:`InterruptedError` | |
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_IsADirectoryError` | :exc:`IsADirectoryError` | |
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_KeyError` | :exc:`KeyError` | |
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_KeyboardInterrupt` | :exc:`KeyboardInterrupt` | |
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_LookupError` | :exc:`LookupError` | [1]_ |
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_MemoryError` | :exc:`MemoryError` | |
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_ModuleNotFoundError` | :exc:`ModuleNotFoundError` | |
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_NameError` | :exc:`NameError` | |
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_NotADirectoryError` | :exc:`NotADirectoryError` | |
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_NotImplementedError` | :exc:`NotImplementedError` | |
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_OSError` | :exc:`OSError` | [1]_ |
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_OverflowError` | :exc:`OverflowError` | |
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_PermissionError` | :exc:`PermissionError` | |
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_ProcessLookupError` | :exc:`ProcessLookupError` | |
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_PythonFinalizationError` | :exc:`PythonFinalizationError` | |
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_RecursionError` | :exc:`RecursionError` | |
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_ReferenceError` | :exc:`ReferenceError` | |
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_RuntimeError` | :exc:`RuntimeError` | |
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_StopAsyncIteration` | :exc:`StopAsyncIteration` | |
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_StopIteration` | :exc:`StopIteration` | |
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_SyntaxError` | :exc:`SyntaxError` | |
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_SystemError` | :exc:`SystemError` | |
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_SystemExit` | :exc:`SystemExit` | |
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_TabError` | :exc:`TabError` | |
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_TimeoutError` | :exc:`TimeoutError` | |
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_TypeError` | :exc:`TypeError` | |
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_UnboundLocalError` | :exc:`UnboundLocalError` | |
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_UnicodeDecodeError` | :exc:`UnicodeDecodeError` | |
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_UnicodeEncodeError` | :exc:`UnicodeEncodeError` | |
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_UnicodeError` | :exc:`UnicodeError` | |
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_UnicodeTranslateError` | :exc:`UnicodeTranslateError` | |
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_ValueError` | :exc:`ValueError` | |
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_ZeroDivisionError` | :exc:`ZeroDivisionError` | |
+-----------------------------------------+---------------------------------+----------+
Exception types
---------------
.. list-table::
:align: left
:widths: auto
:header-rows: 1
* * C name
* Python name
* * .. c:var:: PyObject *PyExc_BaseException
* :exc:`BaseException`
* * .. c:var:: PyObject *PyExc_BaseExceptionGroup
* :exc:`BaseExceptionGroup`
* * .. c:var:: PyObject *PyExc_Exception
* :exc:`Exception`
* * .. c:var:: PyObject *PyExc_ArithmeticError
* :exc:`ArithmeticError`
* * .. c:var:: PyObject *PyExc_AssertionError
* :exc:`AssertionError`
* * .. c:var:: PyObject *PyExc_AttributeError
* :exc:`AttributeError`
* * .. c:var:: PyObject *PyExc_BlockingIOError
* :exc:`BlockingIOError`
* * .. c:var:: PyObject *PyExc_BrokenPipeError
* :exc:`BrokenPipeError`
* * .. c:var:: PyObject *PyExc_BufferError
* :exc:`BufferError`
* * .. c:var:: PyObject *PyExc_ChildProcessError
* :exc:`ChildProcessError`
* * .. c:var:: PyObject *PyExc_ConnectionAbortedError
* :exc:`ConnectionAbortedError`
* * .. c:var:: PyObject *PyExc_ConnectionError
* :exc:`ConnectionError`
* * .. c:var:: PyObject *PyExc_ConnectionRefusedError
* :exc:`ConnectionRefusedError`
* * .. c:var:: PyObject *PyExc_ConnectionResetError
* :exc:`ConnectionResetError`
* * .. c:var:: PyObject *PyExc_EOFError
* :exc:`EOFError`
* * .. c:var:: PyObject *PyExc_FileExistsError
* :exc:`FileExistsError`
* * .. c:var:: PyObject *PyExc_FileNotFoundError
* :exc:`FileNotFoundError`
* * .. c:var:: PyObject *PyExc_FloatingPointError
* :exc:`FloatingPointError`
* * .. c:var:: PyObject *PyExc_GeneratorExit
* :exc:`GeneratorExit`
* * .. c:var:: PyObject *PyExc_ImportError
* :exc:`ImportError`
* * .. c:var:: PyObject *PyExc_IndentationError
* :exc:`IndentationError`
* * .. c:var:: PyObject *PyExc_IndexError
* :exc:`IndexError`
* * .. c:var:: PyObject *PyExc_InterruptedError
* :exc:`InterruptedError`
* * .. c:var:: PyObject *PyExc_IsADirectoryError
* :exc:`IsADirectoryError`
* * .. c:var:: PyObject *PyExc_KeyError
* :exc:`KeyError`
* * .. c:var:: PyObject *PyExc_KeyboardInterrupt
* :exc:`KeyboardInterrupt`
* * .. c:var:: PyObject *PyExc_LookupError
* :exc:`LookupError`
* * .. c:var:: PyObject *PyExc_MemoryError
* :exc:`MemoryError`
* * .. c:var:: PyObject *PyExc_ModuleNotFoundError
* :exc:`ModuleNotFoundError`
* * .. c:var:: PyObject *PyExc_NameError
* :exc:`NameError`
* * .. c:var:: PyObject *PyExc_NotADirectoryError
* :exc:`NotADirectoryError`
* * .. c:var:: PyObject *PyExc_NotImplementedError
* :exc:`NotImplementedError`
* * .. c:var:: PyObject *PyExc_OSError
* :exc:`OSError`
* * .. c:var:: PyObject *PyExc_OverflowError
* :exc:`OverflowError`
* * .. c:var:: PyObject *PyExc_PermissionError
* :exc:`PermissionError`
* * .. c:var:: PyObject *PyExc_ProcessLookupError
* :exc:`ProcessLookupError`
* * .. c:var:: PyObject *PyExc_PythonFinalizationError
* :exc:`PythonFinalizationError`
* * .. c:var:: PyObject *PyExc_RecursionError
* :exc:`RecursionError`
* * .. c:var:: PyObject *PyExc_ReferenceError
* :exc:`ReferenceError`
* * .. c:var:: PyObject *PyExc_RuntimeError
* :exc:`RuntimeError`
* * .. c:var:: PyObject *PyExc_StopAsyncIteration
* :exc:`StopAsyncIteration`
* * .. c:var:: PyObject *PyExc_StopIteration
* :exc:`StopIteration`
* * .. c:var:: PyObject *PyExc_SyntaxError
* :exc:`SyntaxError`
* * .. c:var:: PyObject *PyExc_SystemError
* :exc:`SystemError`
* * .. c:var:: PyObject *PyExc_SystemExit
* :exc:`SystemExit`
* * .. c:var:: PyObject *PyExc_TabError
* :exc:`TabError`
* * .. c:var:: PyObject *PyExc_TimeoutError
* :exc:`TimeoutError`
* * .. c:var:: PyObject *PyExc_TypeError
* :exc:`TypeError`
* * .. c:var:: PyObject *PyExc_UnboundLocalError
* :exc:`UnboundLocalError`
* * .. c:var:: PyObject *PyExc_UnicodeDecodeError
* :exc:`UnicodeDecodeError`
* * .. c:var:: PyObject *PyExc_UnicodeEncodeError
* :exc:`UnicodeEncodeError`
* * .. c:var:: PyObject *PyExc_UnicodeError
* :exc:`UnicodeError`
* * .. c:var:: PyObject *PyExc_UnicodeTranslateError
* :exc:`UnicodeTranslateError`
* * .. c:var:: PyObject *PyExc_ValueError
* :exc:`ValueError`
* * .. c:var:: PyObject *PyExc_ZeroDivisionError
* :exc:`ZeroDivisionError`
.. versionadded:: 3.3
:c:data:`PyExc_BlockingIOError`, :c:data:`PyExc_BrokenPipeError`,
@ -1164,88 +1197,116 @@ the variables:
.. versionadded:: 3.6
:c:data:`PyExc_ModuleNotFoundError`.
These are compatibility aliases to :c:data:`PyExc_OSError`:
.. versionadded:: 3.11
:c:data:`PyExc_BaseExceptionGroup`.
.. index::
single: PyExc_EnvironmentError (C var)
single: PyExc_IOError (C var)
single: PyExc_WindowsError (C var)
+-------------------------------------+----------+
| C Name | Notes |
+=====================================+==========+
| :c:data:`!PyExc_EnvironmentError` | |
+-------------------------------------+----------+
| :c:data:`!PyExc_IOError` | |
+-------------------------------------+----------+
| :c:data:`!PyExc_WindowsError` | [2]_ |
+-------------------------------------+----------+
OSError aliases
---------------
The following are a compatibility aliases to :c:data:`PyExc_OSError`.
.. versionchanged:: 3.3
These aliases used to be separate exception types.
.. list-table::
:align: left
:widths: auto
:header-rows: 1
* * C name
* Python name
* Notes
* * .. c:var:: PyObject *PyExc_EnvironmentError
* :exc:`OSError`
*
* * .. c:var:: PyObject *PyExc_IOError
* :exc:`OSError`
*
* * .. c:var:: PyObject *PyExc_WindowsError
* :exc:`OSError`
* [win]_
Notes:
.. [1]
This is a base class for other standard exceptions.
.. [win]
:c:var:`!PyExc_WindowsError` is only defined on Windows; protect code that
uses this by testing that the preprocessor macro ``MS_WINDOWS`` is defined.
.. [2]
Only defined on Windows; protect code that uses this by testing that the
preprocessor macro ``MS_WINDOWS`` is defined.
.. _standardwarningcategories:
Standard Warning Categories
===========================
Warning types
-------------
All standard Python warning categories are available as global variables whose
names are ``PyExc_`` followed by the Python exception name. These have the type
:c:expr:`PyObject*`; they are all class objects. For completeness, here are all
the variables:
.. list-table::
:align: left
:widths: auto
:header-rows: 1
.. index::
single: PyExc_Warning (C var)
single: PyExc_BytesWarning (C var)
single: PyExc_DeprecationWarning (C var)
single: PyExc_FutureWarning (C var)
single: PyExc_ImportWarning (C var)
single: PyExc_PendingDeprecationWarning (C var)
single: PyExc_ResourceWarning (C var)
single: PyExc_RuntimeWarning (C var)
single: PyExc_SyntaxWarning (C var)
single: PyExc_UnicodeWarning (C var)
single: PyExc_UserWarning (C var)
+------------------------------------------+---------------------------------+----------+
| C Name | Python Name | Notes |
+==========================================+=================================+==========+
| :c:data:`PyExc_Warning` | :exc:`Warning` | [3]_ |
+------------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_BytesWarning` | :exc:`BytesWarning` | |
+------------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_DeprecationWarning` | :exc:`DeprecationWarning` | |
+------------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_FutureWarning` | :exc:`FutureWarning` | |
+------------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_ImportWarning` | :exc:`ImportWarning` | |
+------------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_PendingDeprecationWarning`| :exc:`PendingDeprecationWarning`| |
+------------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_ResourceWarning` | :exc:`ResourceWarning` | |
+------------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_RuntimeWarning` | :exc:`RuntimeWarning` | |
+------------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_SyntaxWarning` | :exc:`SyntaxWarning` | |
+------------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_UnicodeWarning` | :exc:`UnicodeWarning` | |
+------------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_UserWarning` | :exc:`UserWarning` | |
+------------------------------------------+---------------------------------+----------+
* * C name
* Python name
* * .. c:var:: PyObject *PyExc_Warning
* :exc:`Warning`
* * .. c:var:: PyObject *PyExc_BytesWarning
* :exc:`BytesWarning`
* * .. c:var:: PyObject *PyExc_DeprecationWarning
* :exc:`DeprecationWarning`
* * .. c:var:: PyObject *PyExc_EncodingWarning
* :exc:`EncodingWarning`
* * .. c:var:: PyObject *PyExc_FutureWarning
* :exc:`FutureWarning`
* * .. c:var:: PyObject *PyExc_ImportWarning
* :exc:`ImportWarning`
* * .. c:var:: PyObject *PyExc_PendingDeprecationWarning
* :exc:`PendingDeprecationWarning`
* * .. c:var:: PyObject *PyExc_ResourceWarning
* :exc:`ResourceWarning`
* * .. c:var:: PyObject *PyExc_RuntimeWarning
* :exc:`RuntimeWarning`
* * .. c:var:: PyObject *PyExc_SyntaxWarning
* :exc:`SyntaxWarning`
* * .. c:var:: PyObject *PyExc_UnicodeWarning
* :exc:`UnicodeWarning`
* * .. c:var:: PyObject *PyExc_UserWarning
* :exc:`UserWarning`
.. versionadded:: 3.2
:c:data:`PyExc_ResourceWarning`.
Notes:
.. versionadded:: 3.10
:c:data:`PyExc_EncodingWarning`.
.. [3]
This is a base class for other standard warning categories.
Tracebacks
==========
.. c:var:: PyTypeObject PyTraceBack_Type
Type object for traceback objects. This is available as
:class:`types.TracebackType` in the Python layer.
.. c:function:: int PyTraceBack_Check(PyObject *op)
Return true if *op* is a traceback object, false otherwise. This function
does not account for subtypes.
.. c:function:: int PyTraceBack_Here(PyFrameObject *f)
Replace the :attr:`~BaseException.__traceback__` attribute on the current
exception with a new traceback prepending *f* to the existing chain.
Calling this function without an exception set is undefined behavior.
This function returns ``0`` on success, and returns ``-1`` with an
exception set on failure.
.. c:function:: int PyTraceBack_Print(PyObject *tb, PyObject *f)
Write the traceback *tb* into the file *f*.
This function returns ``0`` on success, and returns ``-1`` with an
exception set on failure.

Some files were not shown because too many files have changed in this diff Show more