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
1349 changed files with 149504 additions and 104541 deletions

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
}
}
}
}
}

1
.gitattributes vendored
View file

@ -104,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

837
.github/CODEOWNERS vendored
View file

@ -1,147 +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
# ----------------------------------------------------------------------------
# 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
# ----------------------------------------------------------------------------
# Build System
# ----------------------------------------------------------------------------
# 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
# generate-build-details
Tools/build/generate-build-details.py @FFY00
Lib/test/test_build_details.py @FFY00
# argparse
**/*argparse* @savannahostrowski
# asyncio
**/*asyncio* @1st1 @asvetlov @kumaraditya303 @willingc
# ----------------------------------------------------------------------------
# Documentation
# ----------------------------------------------------------------------------
# Core
**/*context* @1st1
**/*genobject* @markshannon
**/*hamt* @1st1
**/*jit* @brandtbucher @savannahostrowski
Python/perf_jit_trampoline.c # Exclude the owners of "**/*jit*", above.
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
# Internal Docs
InternalDocs/ @AA-Turner
# dbm
**/*dbm* @corona10 @erlend-aasland @serhiy-storchaka
# Doc/ tools
Doc/conf.py @AA-Turner @hugovk
# 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
@ -152,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
@ -173,178 +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
Modules/_interp*module.c @ericsnowcurrently
Lib/test/test__interp*.py @ericsnowcurrently
Lib/concurrent/interpreters/ @ericsnowcurrently
Lib/test/support/channels.py @ericsnowcurrently
Doc/library/concurrent.interpreters.rst @ericsnowcurrently
Lib/test/test_interpreters/ @ericsnowcurrently
Lib/concurrent/futures/interpreter.py @ericsnowcurrently
# Android
**/*Android* @mhsmith @freakboy3742
**/*android* @mhsmith @freakboy3742
# Apple
/Apple @freakboy3742
# iOS (but not termios)
**/iOS* @freakboy3742
**/ios* @freakboy3742
**/*_iOS* @freakboy3742
**/*_ios* @freakboy3742
**/*-iOS* @freakboy3742
**/*-ios* @freakboy3742
# WebAssembly
Tools/wasm/config.site-wasm32-emscripten @freakboy3742
/Tools/wasm/README.md @brettcannon @freakboy3742
/Tools/wasm/wasi-env @brettcannon
/Tools/wasm/wasi_build.py @brettcannon
/Tools/wasm/emscripten @freakboy3742
/Tools/wasm/wasi @brettcannon
# 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
# ----------------------------------------------------------------------------
# Remote debugging
Python/remote_debug.h @pablogsal
Python/remote_debugging.c @pablogsal
Modules/_remote_debugging_module.c @pablogsal @ambv @1st1
# 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

@ -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

@ -49,53 +49,6 @@ jobs:
if: fromJSON(needs.build-context.outputs.run-docs)
uses: ./.github/workflows/reusable-docs.yml
check-abi:
name: 'Check if the ABI has changed'
runs-on: ubuntu-22.04 # 24.04 causes spurious errors
needs: build-context
if: needs.build-context.outputs.run-tests == 'true'
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: |
sudo ./.github/workflows/posix-deps-apt.sh
sudo apt-get install -yq abigail-tools
- name: Build CPython
env:
CFLAGS: -g3 -O0
run: |
# Build Python with the libpython dynamic library
./configure --enable-shared
make -j4
- name: Check for changes in the ABI
id: check
run: |
if ! make check-abidump; then
echo "Generated ABI file is not up to date."
echo "Please add the release manager of this branch as a reviewer of this PR."
echo ""
echo "The up to date ABI file should be attached to this build as an artifact."
echo ""
echo "To learn more about this check: https://devguide.python.org/getting-started/setup-building/index.html#regenerate-the-abi-dump"
echo ""
exit 1
fi
- name: Generate updated ABI files
if: ${{ failure() && steps.check.conclusion == 'failure' }}
run: |
make regen-abidump
- uses: actions/upload-artifact@v4
name: Publish updated ABI files
if: ${{ failure() && steps.check.conclusion == 'failure' }}
with:
name: abi-data
path: ./Doc/data/*.abi
check-autoconf-regen:
name: 'Check if Autoconf files are up to date'
# Don't use ubuntu-latest but a specific version to make the job
@ -189,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: >-
@ -287,7 +243,7 @@ jobs:
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
@ -343,6 +299,72 @@ 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
@ -667,7 +689,8 @@ 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
@ -684,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: >-
@ -702,7 +726,8 @@ 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,

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,7 +68,7 @@ jobs:
- true
- false
llvm:
- 19
- 21
include:
- target: i686-pc-windows-msvc/msvc
architecture: Win32
@ -125,33 +129,61 @@ 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
@ -161,7 +193,7 @@ jobs:
fail-fast: false
matrix:
llvm:
- 19
- 21
steps:
- uses: actions/checkout@v4
with:

View file

@ -16,6 +16,7 @@ on:
- "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"

View file

@ -5,6 +5,7 @@ apt-get -yq install \
build-essential \
pkg-config \
ccache \
cmake \
gdb \
lcov \
libb2-dev \
@ -25,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

@ -35,9 +35,9 @@ jobs:
run: echo "IMAGE_OS_VERSION=${ImageOS}-${ImageVersion}" >> "$GITHUB_ENV"
- 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 \

View file

@ -9,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
@ -36,7 +36,7 @@ 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: "Add ccache to PATH"
run: echo "PATH=/usr/lib/ccache:$PATH" >> "$GITHUB_ENV"

5
.gitignore vendored
View file

@ -130,6 +130,7 @@ Tools/unicode/data/
/autom4te.cache
/build/
/builddir/
/compile_commands.json
/config.cache
/config.log
/config.status
@ -172,3 +173,7 @@ Python/frozen_modules/MANIFEST
# 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

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

View file

@ -29,6 +29,7 @@
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 = PYTHON_DIR / "cross-build"
@ -129,12 +130,11 @@ def android_env(host):
sysconfig_filename = next(sysconfig_files).name
host = re.fullmatch(r"_sysconfigdata__android_(.+).py", sysconfig_filename)[1]
env_script = ANDROID_DIR / "android-env.sh"
env_output = subprocess.run(
f"set -eu; "
f"HOST={host}; "
f"PREFIX={prefix}; "
f". {env_script}; "
f". {ENV_SCRIPT}; "
f"export",
check=True, shell=True, capture_output=True, encoding='utf-8',
).stdout
@ -151,7 +151,7 @@ def android_env(host):
env[key] = value
if not env:
raise ValueError(f"Found no variables in {env_script.name} output:\n"
raise ValueError(f"Found no variables in {ENV_SCRIPT.name} output:\n"
+ env_output)
return env
@ -281,15 +281,30 @@ def clean_all(context):
def setup_ci():
# https://github.blog/changelog/2024-04-02-github-actions-hardware-accelerated-android-virtualization-now-available/
if "GITHUB_ACTIONS" in os.environ and 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"])
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():

View file

@ -79,7 +79,7 @@ android {
val androidEnvFile = file("../../android-env.sh").absoluteFile
namespace = "org.python.testbed"
compileSdk = 34
compileSdk = 35
defaultConfig {
applicationId = "org.python.testbed"
@ -92,7 +92,7 @@ android {
}
throw GradleException("Failed to find API level in $androidEnvFile")
}
targetSdk = 34
targetSdk = 35
versionCode = 1
versionName = "1.0"

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

@ -43,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

@ -237,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
@ -248,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.
@ -277,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.
@ -306,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
-------------

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, ...)
@ -220,6 +224,10 @@ called with a non-bytes parameter.
*\*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)
@ -254,3 +262,170 @@ called with a non-bytes parameter.
.. 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

@ -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

@ -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

View file

@ -8,7 +8,8 @@ Defining extension modules
A C extension for CPython is a shared library (for example, a ``.so`` file
on Linux, ``.pyd`` DLL on Windows), which is loadable into the Python process
(for example, it is compiled with compatible compiler settings), and which
exports an :ref:`initialization function <extension-export-hook>`.
exports an :dfn:`export hook` function (or an
old-style :ref:`initialization function <extension-pyinit>`).
To be importable by default (that is, by
:py:class:`importlib.machinery.ExtensionFileLoader`),
@ -23,25 +24,127 @@ and must be named after the module name plus an extension listed in
One suitable tool is Setuptools, whose documentation can be found at
https://setuptools.pypa.io/en/latest/setuptools.html.
Normally, the initialization function returns a module definition initialized
using :c:func:`PyModuleDef_Init`.
This allows splitting the creation process into several phases:
.. _extension-export-hook:
Extension export hook
.....................
.. versionadded:: next
Support for the :samp:`PyModExport_{<name>}` export hook was added in Python
3.15. The older way of defining modules is still available: consult either
the :ref:`extension-pyinit` section or earlier versions of this
documentation if you plan to support earlier Python versions.
The export hook must be an exported function with the following signature:
.. c:function:: PyModuleDef_Slot *PyModExport_modulename(void)
For modules with ASCII-only names, the :ref:`export hook <extension-export-hook>`
must be named :samp:`PyModExport_{<name>}`,
with ``<name>`` replaced by the module's name.
For non-ASCII module names, the export hook must instead be named
:samp:`PyModExportU_{<name>}` (note the ``U``), with ``<name>`` encoded using
Python's *punycode* encoding with hyphens replaced by underscores. In Python:
.. code-block:: python
def hook_name(name):
try:
suffix = b'_' + name.encode('ascii')
except UnicodeEncodeError:
suffix = b'U_' + name.encode('punycode').replace(b'-', b'_')
return b'PyModExport' + suffix
The export hook returns an array of :c:type:`PyModuleDef_Slot` entries,
terminated by an entry with a slot ID of ``0``.
These slots describe how the module should be created and initialized.
This array must remain valid and constant until interpreter shutdown.
Typically, it should use ``static`` storage.
Prefer using the :c:macro:`Py_mod_create` and :c:macro:`Py_mod_exec` slots
for any dynamic behavior.
The export hook may return ``NULL`` with an exception set to signal failure.
It is recommended to define the export hook function using a helper macro:
.. c:macro:: PyMODEXPORT_FUNC
Declare an extension module export hook.
This macro:
* specifies the :c:expr:`PyModuleDef_Slot*` return type,
* adds any special linkage declarations required by the platform, and
* for C++, declares the function as ``extern "C"``.
For example, a module called ``spam`` would be defined like this::
PyABIInfo_VAR(abi_info);
static PyModuleDef_Slot spam_slots[] = {
{Py_mod_abi, &abi_info},
{Py_mod_name, "spam"},
{Py_mod_init, spam_init_function},
...
{0, NULL},
};
PyMODEXPORT_FUNC
PyModExport_spam(void)
{
return spam_slots;
}
The export hook is typically the only non-\ ``static``
item defined in the module's C source.
The hook should be kept short -- ideally, one line as above.
If you do need to use Python C API in this function, it is recommended to call
``PyABIInfo_Check(&abi_info, "modulename")`` first to raise an exception,
rather than crash, in common cases of ABI mismatch.
.. note::
It is possible to export multiple modules from a single shared library by
defining multiple export hooks.
However, importing them requires a custom importer or suitably named
copies/links of the extension file, because Python's import machinery only
finds the function corresponding to the filename.
See the `Multiple modules in one library <https://peps.python.org/pep-0489/#multiple-modules-in-one-library>`__
section in :pep:`489` for details.
.. _multi-phase-initialization:
Multi-phase initialization
..........................
The process of creating an extension module follows several phases:
- Python finds and calls the export hook to get information on how to
create the module.
- Before any substantial code is executed, Python can determine which
capabilities the module supports, and it can adjust the environment or
refuse loading an incompatible extension.
- By default, Python itself creates the module object -- that is, it does
the equivalent of :py:meth:`object.__new__` for classes.
It also sets initial attributes like :attr:`~module.__package__` and
:attr:`~module.__loader__`.
- Afterwards, the module object is initialized using extension-specific
code -- the equivalent of :py:meth:`~object.__init__` on classes.
Slots like :c:data:`Py_mod_abi`, :c:data:`Py_mod_gil` and
:c:data:`Py_mod_multiple_interpreters` influence this step.
- By default, Python itself then creates the module object -- that is, it does
the equivalent of calling :py:meth:`~object.__new__` when creating an object.
This step can be overridden using the :c:data:`Py_mod_create` slot.
- Python sets initial module attributes like :attr:`~module.__package__` and
:attr:`~module.__loader__`, and inserts the module object into
:py:attr:`sys.modules`.
- Afterwards, the module object is initialized in an extension-specific way
-- the equivalent of :py:meth:`~object.__init__` when creating an object,
or of executing top-level code in a Python-language module.
The behavior is specified using the :c:data:`Py_mod_exec` slot.
This is called *multi-phase initialization* to distinguish it from the legacy
(but still supported) *single-phase initialization* scheme,
where the initialization function returns a fully constructed module.
See the :ref:`single-phase-initialization section below <single-phase-initialization>`
for details.
(but still supported) :ref:`single-phase initialization <single-phase-initialization>`,
where an initialization function returns a fully constructed module.
.. versionchanged:: 3.5
@ -53,7 +156,7 @@ Multiple module instances
By default, extension modules are not singletons.
For example, if the :py:attr:`sys.modules` entry is removed and the module
is re-imported, a new module object is created, and typically populated with
is re-imported, a new module object is created and, typically, populated with
fresh method and type objects.
The old module is subject to normal garbage collection.
This mirrors the behavior of pure-Python modules.
@ -83,36 +186,34 @@ A module may also be limited to the main interpreter using
the :c:data:`Py_mod_multiple_interpreters` slot.
.. _extension-export-hook:
.. _extension-pyinit:
Initialization function
.......................
``PyInit`` function
...................
The initialization function defined by an extension module has the
following signature:
.. deprecated:: next
This functionality is :term:`soft deprecated`.
It will not get new features, but there are no plans to remove it.
Instead of :c:func:`PyModExport_modulename`, an extension module can define
an older-style :dfn:`initialization function` with the signature:
.. c:function:: PyObject* PyInit_modulename(void)
Its name should be :samp:`PyInit_{<name>}`, with ``<name>`` replaced by the
name of the module.
For non-ASCII module names, use :samp:`PyInitU_{<name>}` instead, with
``<name>`` encoded in the same way as for the
:ref:`export hook <extension-export-hook>` (that is, using Punycode
with underscores).
For modules with ASCII-only names, the function must instead be named
:samp:`PyInit_{<name>}`, with ``<name>`` replaced by the name of the module.
When using :ref:`multi-phase-initialization`, non-ASCII module names
are allowed. In this case, the initialization function name is
:samp:`PyInitU_{<name>}`, with ``<name>`` encoded using Python's
*punycode* encoding with hyphens replaced by underscores. In Python:
If a module exports both :samp:`PyInit_{<name>}` and
:samp:`PyModExport_{<name>}`, the :samp:`PyInit_{<name>}` function
is ignored.
.. code-block:: python
def initfunc_name(name):
try:
suffix = b'_' + name.encode('ascii')
except UnicodeEncodeError:
suffix = b'U_' + name.encode('punycode').replace(b'-', b'_')
return b'PyInit' + suffix
It is recommended to define the initialization function using a helper macro:
Like with :c:macro:`PyMODEXPORT_FUNC`, it is recommended to define the
initialization function using a helper macro:
.. c:macro:: PyMODINIT_FUNC
@ -123,6 +224,34 @@ It is recommended to define the initialization function using a helper macro:
* adds any special linkage declarations required by the platform, and
* for C++, declares the function as ``extern "C"``.
Normally, the initialization function (``PyInit_modulename``) returns
a :c:type:`PyModuleDef` instance with non-``NULL``
:c:member:`~PyModuleDef.m_slots`. This allows Python to use
:ref:`multi-phase initialization <multi-phase-initialization>`.
Before it is returned, the ``PyModuleDef`` instance must be initialized
using the following function:
.. c:function:: PyObject* PyModuleDef_Init(PyModuleDef *def)
Ensure a module definition is a properly initialized Python object that
correctly reports its type and a reference count.
Return *def* cast to ``PyObject*``, or ``NULL`` if an error occurred.
Calling this function is required before returning a :c:type:`PyModuleDef`
from a module initialization function.
It should not be used in other contexts.
Note that Python assumes that ``PyModuleDef`` structures are statically
allocated.
This function may return either a new reference or a borrowed one;
this reference must not be released.
.. versionadded:: 3.5
For example, a module called ``spam`` would be defined like this::
static struct PyModuleDef spam_module = {
@ -137,59 +266,23 @@ For example, a module called ``spam`` would be defined like this::
return PyModuleDef_Init(&spam_module);
}
It is possible to export multiple modules from a single shared library by
defining multiple initialization functions. However, importing them requires
using symbolic links or a custom importer, because by default only the
function corresponding to the filename is found.
See the `Multiple modules in one library <https://peps.python.org/pep-0489/#multiple-modules-in-one-library>`__
section in :pep:`489` for details.
The initialization function is typically the only non-\ ``static``
item defined in the module's C source.
.. _multi-phase-initialization:
Multi-phase initialization
..........................
Normally, the :ref:`initialization function <extension-export-hook>`
(``PyInit_modulename``) returns a :c:type:`PyModuleDef` instance with
non-``NULL`` :c:member:`~PyModuleDef.m_slots`.
Before it is returned, the ``PyModuleDef`` instance must be initialized
using the following function:
.. c:function:: PyObject* PyModuleDef_Init(PyModuleDef *def)
Ensure a module definition is a properly initialized Python object that
correctly reports its type and a reference count.
Return *def* cast to ``PyObject*``, or ``NULL`` if an error occurred.
Calling this function is required for :ref:`multi-phase-initialization`.
It should not be used in other contexts.
Note that Python assumes that ``PyModuleDef`` structures are statically
allocated.
This function may return either a new reference or a borrowed one;
this reference must not be released.
.. versionadded:: 3.5
.. _single-phase-initialization:
Legacy single-phase initialization
..................................
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. attention::
Single-phase initialization is a legacy mechanism to initialize extension
.. deprecated:: next
Single-phase initialization is :term:`soft deprecated`.
It is a legacy mechanism to initialize extension
modules, with known drawbacks and design flaws. Extension module authors
are encouraged to use multi-phase initialization instead.
In single-phase initialization, the
:ref:`initialization function <extension-export-hook>` (``PyInit_modulename``)
However, there are no plans to remove support for it.
In single-phase initialization, the old-style
:ref:`initializaton function <extension-pyinit>` (``PyInit_modulename``)
should create, populate and return a module object.
This is typically done using :c:func:`PyModule_Create` and functions like
:c:func:`PyModule_AddObjectRef`.
@ -242,6 +335,8 @@ in the following ways:
* Single-phase modules support module lookup functions like
:c:func:`PyState_FindModule`.
* The module's :c:member:`PyModuleDef.m_slots` must be NULL.
.. [#testsinglephase] ``_testsinglephase`` is an internal module used
in CPython's self-test suite; your installation may or may not
include it.

View file

@ -83,8 +83,11 @@ Floating-Point Objects
This macro expands a to constant expression of type :c:expr:`double`, that
represents the positive infinity.
On most platforms, this is equivalent to the :c:macro:`!INFINITY` macro from
the C11 standard ``<math.h>`` header.
It is equivalent to the :c:macro:`!INFINITY` macro from the C11 standard
``<math.h>`` header.
.. deprecated:: 3.15
The macro is :term:`soft deprecated`.
.. c:macro:: Py_NAN
@ -113,6 +116,8 @@ Floating-Point Objects
High precision (long double) definition of :data:`~math.e` constant.
.. deprecated-removed:: 3.15 3.20
.. c:macro:: Py_MATH_PI
@ -123,6 +128,8 @@ Floating-Point Objects
High precision (long double) definition of :data:`~math.pi` constant.
.. deprecated-removed:: 3.15 3.20
.. c:macro:: Py_MATH_TAU

View file

@ -184,6 +184,9 @@ There are a few functions specific to Python functions.
.. versionadded:: 3.12
- ``PyFunction_PYFUNC_EVENT_MODIFY_QUALNAME``
.. versionadded:: 3.15
.. c:type:: int (*PyFunction_WatchCallback)(PyFunction_WatchEvent event, PyFunctionObject *func, PyObject *new_value)
@ -206,7 +209,7 @@ There are a few functions specific to Python functions.
runtime behavior depending on optimization decisions, it does not change
the semantics of the Python code being executed.
If *event* is ``PyFunction_EVENT_DESTROY``, Taking a reference in the
If *event* is ``PyFunction_EVENT_DESTROY``, taking a reference in the
callback to the about-to-be-destroyed function will resurrect it, preventing
it from being freed at this time. When the resurrected object is destroyed
later, any watcher callbacks active at that time will be called again.

View file

@ -16,19 +16,6 @@ Importing Modules
This is a wrapper around :c:func:`PyImport_Import()` which takes a
:c:expr:`const char *` as an argument instead of a :c:expr:`PyObject *`.
.. c:function:: PyObject* PyImport_ImportModuleNoBlock(const char *name)
This function is a deprecated alias of :c:func:`PyImport_ImportModule`.
.. versionchanged:: 3.3
This function used to fail immediately when the import lock was held
by another thread. In Python 3.3 though, the locking scheme switched
to per-module locks for most purposes, so this function's special
behaviour isn't needed anymore.
.. deprecated-removed:: 3.13 3.15
Use :c:func:`PyImport_ImportModule` instead.
.. c:function:: PyObject* PyImport_ImportModuleEx(const char *name, PyObject *globals, PyObject *locals, PyObject *fromlist)
@ -353,3 +340,24 @@ Importing Modules
strings instead of Python :class:`str` objects.
.. versionadded:: 3.14
.. c:function:: PyObject* PyImport_CreateModuleFromInitfunc(PyObject *spec, PyObject* (*initfunc)(void))
This function is a building block that enables embedders to implement
the :py:meth:`~importlib.abc.Loader.create_module` step of custom
static extension importers (e.g. of statically-linked extensions).
*spec* must be a :class:`~importlib.machinery.ModuleSpec` object.
*initfunc* must be an :ref:`initialization function <extension-export-hook>`,
the same as for :c:func:`PyImport_AppendInittab`.
On success, create and return a module object.
This module will not be initialized; call :c:func:`PyModule_Exec`
to initialize it.
(Custom importers should do this in their
:py:meth:`~importlib.abc.Loader.exec_module` method.)
On error, return NULL with an exception set.
.. versionadded:: 3.15

View file

@ -41,7 +41,6 @@ The following functions can be safely called before Python is initialized:
* :c:func:`PyObject_SetArenaAllocator`
* :c:func:`Py_SetProgramName`
* :c:func:`Py_SetPythonHome`
* :c:func:`PySys_ResetWarnOptions`
* the configuration functions covered in :ref:`init-config`
* Informative functions:
@ -77,10 +76,7 @@ The following functions can be safely called before Python is initialized:
Despite their apparent similarity to some of the functions listed above,
the following functions **should not be called** before the interpreter has
been initialized: :c:func:`Py_EncodeLocale`, :c:func:`Py_GetPath`,
:c:func:`Py_GetPrefix`, :c:func:`Py_GetExecPrefix`,
:c:func:`Py_GetProgramFullPath`, :c:func:`Py_GetPythonHome`,
:c:func:`Py_GetProgramName`, :c:func:`PyEval_InitThreads`, and
been initialized: :c:func:`Py_EncodeLocale`, :c:func:`PyEval_InitThreads`, and
:c:func:`Py_RunMain`.
@ -145,9 +141,6 @@ to 1 and ``-bb`` sets :c:data:`Py_BytesWarningFlag` to 2.
:c:member:`PyConfig.pathconfig_warnings` should be used instead, see
:ref:`Python Initialization Configuration <init-config>`.
Suppress error messages when calculating the module search path in
:c:func:`Py_GetPath`.
Private flag used by ``_freeze_module`` and ``frozenmain`` programs.
.. deprecated-removed:: 3.12 3.15
@ -572,7 +565,6 @@ Process-wide parameters
.. index::
single: Py_Initialize()
single: main()
single: Py_GetPath()
This API is kept for backward compatibility: setting
:c:member:`PyConfig.program_name` should be used instead, see :ref:`Python
@ -582,7 +574,7 @@ Process-wide parameters
the first time, if it is called at all. It tells the interpreter the value
of the ``argv[0]`` argument to the :c:func:`main` function of the program
(converted to wide characters).
This is used by :c:func:`Py_GetPath` and some other functions below to find
This is used by some other functions below to find
the Python run-time libraries relative to the interpreter executable. The
default value is ``'python'``. The argument should point to a
zero-terminated wide character string in static storage whose contents will not
@ -595,146 +587,6 @@ Process-wide parameters
.. deprecated-removed:: 3.11 3.15
.. c:function:: wchar_t* Py_GetProgramName()
Return the program name set with :c:member:`PyConfig.program_name`, or the default.
The returned string points into static storage; the caller should not modify its
value.
This function should not be called before :c:func:`Py_Initialize`, otherwise
it returns ``NULL``.
.. versionchanged:: 3.10
It now returns ``NULL`` if called before :c:func:`Py_Initialize`.
.. deprecated-removed:: 3.13 3.15
Use :c:func:`PyConfig_Get("executable") <PyConfig_Get>`
(:data:`sys.executable`) instead.
.. c:function:: wchar_t* Py_GetPrefix()
Return the *prefix* for installed platform-independent files. This is derived
through a number of complicated rules from the program name set with
:c:member:`PyConfig.program_name` and some environment variables; for example, if the
program name is ``'/usr/local/bin/python'``, the prefix is ``'/usr/local'``. The
returned string points into static storage; the caller should not modify its
value. This corresponds to the :makevar:`prefix` variable in the top-level
:file:`Makefile` and the :option:`--prefix` argument to the :program:`configure`
script at build time. The value is available to Python code as ``sys.base_prefix``.
It is only useful on Unix. See also the next function.
This function should not be called before :c:func:`Py_Initialize`, otherwise
it returns ``NULL``.
.. versionchanged:: 3.10
It now returns ``NULL`` if called before :c:func:`Py_Initialize`.
.. deprecated-removed:: 3.13 3.15
Use :c:func:`PyConfig_Get("base_prefix") <PyConfig_Get>`
(:data:`sys.base_prefix`) instead. Use :c:func:`PyConfig_Get("prefix")
<PyConfig_Get>` (:data:`sys.prefix`) if :ref:`virtual environments
<venv-def>` need to be handled.
.. c:function:: wchar_t* Py_GetExecPrefix()
Return the *exec-prefix* for installed platform-*dependent* files. This is
derived through a number of complicated rules from the program name set with
:c:member:`PyConfig.program_name` and some environment variables; for example, if the
program name is ``'/usr/local/bin/python'``, the exec-prefix is
``'/usr/local'``. The returned string points into static storage; the caller
should not modify its value. This corresponds to the :makevar:`exec_prefix`
variable in the top-level :file:`Makefile` and the ``--exec-prefix``
argument to the :program:`configure` script at build time. The value is
available to Python code as ``sys.base_exec_prefix``. It is only useful on
Unix.
Background: The exec-prefix differs from the prefix when platform dependent
files (such as executables and shared libraries) are installed in a different
directory tree. In a typical installation, platform dependent files may be
installed in the :file:`/usr/local/plat` subtree while platform independent may
be installed in :file:`/usr/local`.
Generally speaking, a platform is a combination of hardware and software
families, e.g. Sparc machines running the Solaris 2.x operating system are
considered the same platform, but Intel machines running Solaris 2.x are another
platform, and Intel machines running Linux are yet another platform. Different
major revisions of the same operating system generally also form different
platforms. Non-Unix operating systems are a different story; the installation
strategies on those systems are so different that the prefix and exec-prefix are
meaningless, and set to the empty string. Note that compiled Python bytecode
files are platform independent (but not independent from the Python version by
which they were compiled!).
System administrators will know how to configure the :program:`mount` or
:program:`automount` programs to share :file:`/usr/local` between platforms
while having :file:`/usr/local/plat` be a different filesystem for each
platform.
This function should not be called before :c:func:`Py_Initialize`, otherwise
it returns ``NULL``.
.. versionchanged:: 3.10
It now returns ``NULL`` if called before :c:func:`Py_Initialize`.
.. deprecated-removed:: 3.13 3.15
Use :c:func:`PyConfig_Get("base_exec_prefix") <PyConfig_Get>`
(:data:`sys.base_exec_prefix`) instead. Use
:c:func:`PyConfig_Get("exec_prefix") <PyConfig_Get>`
(:data:`sys.exec_prefix`) if :ref:`virtual environments <venv-def>` need
to be handled.
.. c:function:: wchar_t* Py_GetProgramFullPath()
.. index::
single: executable (in module sys)
Return the full program name of the Python executable; this is computed as a
side-effect of deriving the default module search path from the program name
(set by :c:member:`PyConfig.program_name`). The returned string points into
static storage; the caller should not modify its value. The value is available
to Python code as ``sys.executable``.
This function should not be called before :c:func:`Py_Initialize`, otherwise
it returns ``NULL``.
.. versionchanged:: 3.10
It now returns ``NULL`` if called before :c:func:`Py_Initialize`.
.. deprecated-removed:: 3.13 3.15
Use :c:func:`PyConfig_Get("executable") <PyConfig_Get>`
(:data:`sys.executable`) instead.
.. c:function:: wchar_t* Py_GetPath()
.. index::
triple: module; search; path
single: path (in module sys)
Return the default module search path; this is computed from the program name
(set by :c:member:`PyConfig.program_name`) and some environment variables.
The returned string consists of a series of directory names separated by a
platform dependent delimiter character. The delimiter character is ``':'``
on Unix and macOS, ``';'`` on Windows. The returned string points into
static storage; the caller should not modify its value. The list
:data:`sys.path` is initialized with this value on interpreter startup; it
can be (and usually is) modified later to change the search path for loading
modules.
This function should not be called before :c:func:`Py_Initialize`, otherwise
it returns ``NULL``.
.. XXX should give the exact rules
.. versionchanged:: 3.10
It now returns ``NULL`` if called before :c:func:`Py_Initialize`.
.. deprecated-removed:: 3.13 3.15
Use :c:func:`PyConfig_Get("module_search_paths") <PyConfig_Get>`
(:data:`sys.path`) instead.
.. c:function:: const char* Py_GetVersion()
Return the version of this Python interpreter. This is a string that looks
@ -905,23 +757,6 @@ Process-wide parameters
.. deprecated-removed:: 3.11 3.15
.. c:function:: wchar_t* Py_GetPythonHome()
Return the default "home", that is, the value set by
:c:member:`PyConfig.home`, or the value of the :envvar:`PYTHONHOME`
environment variable if it is set.
This function should not be called before :c:func:`Py_Initialize`, otherwise
it returns ``NULL``.
.. versionchanged:: 3.10
It now returns ``NULL`` if called before :c:func:`Py_Initialize`.
.. deprecated-removed:: 3.13 3.15
Use :c:func:`PyConfig_Get("home") <PyConfig_Get>` or the
:envvar:`PYTHONHOME` environment variable instead.
.. _threads:
Thread State and the Global Interpreter Lock
@ -1555,17 +1390,7 @@ All of the following functions must be called after :c:func:`Py_Initialize`.
See :c:func:`PyUnstable_ThreadState_ResetStackProtection` for undoing this operation.
.. versionadded:: 3.14.1
.. warning::
This function was added in a bugfix release, and
extensions that use it will be incompatible with Python 3.14.0.
Most packaging tools for Python are not able to handle this
incompatibility automatically, and will need explicit configuration.
When using PyPA standards (wheels and source distributions),
specify ``Requires-Python: != 3.14.0.*`` in
`core metadata <https://packaging.python.org/en/latest/specifications/core-metadata/#requires-python>`_.
.. versionadded:: 3.15
.. c:function:: void PyUnstable_ThreadState_ResetStackProtection(PyThreadState *tstate)
@ -1575,17 +1400,7 @@ All of the following functions must be called after :c:func:`Py_Initialize`.
See :c:func:`PyUnstable_ThreadState_SetStackProtection` for an explanation.
.. versionadded:: 3.14.1
.. warning::
This function was added in a bugfix release, and
extensions that use it will be incompatible with Python 3.14.0.
Most packaging tools for Python are not able to handle this
incompatibility automatically, and will need explicit configuration.
When using PyPA standards (wheels and source distributions),
specify ``Requires-Python: != 3.14.0.*`` in
`core metadata <https://packaging.python.org/en/latest/specifications/core-metadata/#requires-python>`_.
.. versionadded:: 3.15
.. c:function:: PyInterpreterState* PyInterpreterState_Get(void)
@ -1902,7 +1717,8 @@ function. You can create and destroy them using the following functions:
Only C-level static and global variables are shared between these
module objects.
* For modules using single-phase initialization,
* For modules using legacy
:ref:`single-phase initialization <single-phase-initialization>`,
e.g. :c:func:`PyModule_Create`, the first time a particular extension
is imported, it is initialized normally, and a (shallow) copy of its
module's dictionary is squirreled away.
@ -2271,6 +2087,11 @@ Reference tracing
is set to :c:data:`PyRefTracer_DESTROY`). The **data** argument is the opaque pointer
that was provided when :c:func:`PyRefTracer_SetTracer` was called.
If a new tracing function is registered replacing the current a call to the
trace function will be made with the object set to **NULL** and **event** set to
:c:data:`PyRefTracer_TRACKER_REMOVED`. This will happen just before the new
function is registered.
.. versionadded:: 3.13
.. c:var:: int PyRefTracer_CREATE
@ -2283,6 +2104,13 @@ Reference tracing
The value for the *event* parameter to :c:type:`PyRefTracer` functions when a Python
object has been destroyed.
.. c:var:: int PyRefTracer_TRACKER_REMOVED
The value for the *event* parameter to :c:type:`PyRefTracer` functions when the
current tracer is about to be replaced by a new one.
.. versionadded:: 3.14
.. c:function:: int PyRefTracer_SetTracer(PyRefTracer tracer, void *data)
Register a reference tracer function. The function will be called when a new
@ -2298,6 +2126,10 @@ Reference tracing
There must be an :term:`attached thread state` when calling this function.
If another tracer function was already registered, the old function will be
called with **event** set to :c:data:`PyRefTracer_TRACKER_REMOVED` just before
the new function is registered.
.. versionadded:: 3.13
.. c:function:: PyRefTracer PyRefTracer_GetTracer(void** data)
@ -2365,7 +2197,7 @@ use a thread key and functions to associate a :c:expr:`void*` value per
thread.
A :term:`thread state` does *not* need to be :term:`attached <attached thread state>`
when calling these functions; they suppl their own locking.
when calling these functions; they supply their own locking.
Note that :file:`Python.h` does not include the declaration of the TLS APIs,
you need to include :file:`pythread.h` to use thread-local storage.

View file

@ -975,9 +975,7 @@ PyPreConfig
Set to ``0`` or ``1`` by the :option:`-X utf8 <-X>` command line option
and the :envvar:`PYTHONUTF8` environment variable.
Also set to ``1`` if the ``LC_CTYPE`` locale is ``C`` or ``POSIX``.
Default: ``-1`` in Python config and ``0`` in isolated config.
Default: ``1``.
.. _c-preinit:
@ -1280,6 +1278,11 @@ PyConfig
Default: ``0``.
.. deprecated-removed:: 3.15 3.17
The :option:`-b` and :option:`!-bb` options will become no-op in 3.17.
:c:member:`~PyConfig.bytes_warning` member will be removed in 3.17.
.. c:member:: int warn_default_encoding
If non-zero, emit a :exc:`EncodingWarning` warning when :class:`io.TextIOWrapper`
@ -2111,7 +2114,7 @@ initialization::
/* Specify sys.path explicitly */
/* If you want to modify the default set of paths, finish
initialization first and then use PySys_GetObject("path") */
initialization first and then use PySys_GetAttrString("path") */
config.module_search_paths_set = 1;
status = PyWideStringList_Append(&config.module_search_paths,
L"/path/to/stdlib");
@ -2260,6 +2263,7 @@ If a ``._pth`` file is present:
* Set :c:member:`~PyConfig.isolated` to ``1``.
* Set :c:member:`~PyConfig.use_environment` to ``0``.
* Set :c:member:`~PyConfig.site_import` to ``0``.
* Set :c:member:`~PyConfig.user_site_directory` to ``0`` (since 3.15).
* Set :c:member:`~PyConfig.safe_path` to ``1``.
If :c:member:`~PyConfig.home` is not set and a ``pyvenv.cfg`` file is present in
@ -2280,6 +2284,12 @@ The ``__PYVENV_LAUNCHER__`` environment variable is used to set
therefore affected by :option:`-S`.
.. versionchanged:: 3.15
:c:member:`~PyConfig.user_site_directory` is now set to ``0`` when a
``._pth`` file is present.
Py_GetArgcArgv()
================

View file

@ -825,20 +825,11 @@ found along :envvar:`PATH`.) The user can override this behavior by setting the
environment variable :envvar:`PYTHONHOME`, or insert additional directories in
front of the standard path by setting :envvar:`PYTHONPATH`.
.. index::
single: Py_GetPath (C function)
single: Py_GetPrefix (C function)
single: Py_GetExecPrefix (C function)
single: Py_GetProgramFullPath (C function)
The embedding application can steer the search by setting
:c:member:`PyConfig.program_name` *before* calling
:c:func:`Py_InitializeFromConfig`. Note that
:envvar:`PYTHONHOME` still overrides this and :envvar:`PYTHONPATH` is still
inserted in front of the standard path. An application that requires total
control has to provide its own implementation of :c:func:`Py_GetPath`,
:c:func:`Py_GetPrefix`, :c:func:`Py_GetExecPrefix`, and
:c:func:`Py_GetProgramFullPath` (all defined in :file:`Modules/getpath.c`).
inserted in front of the standard path.
.. index:: single: Py_IsInitialized (C function)
@ -872,14 +863,17 @@ frequently used builds will be described in the remainder of this section.
Compiling the interpreter with the :c:macro:`!Py_DEBUG` macro defined produces
what is generally meant by :ref:`a debug build of Python <debug-build>`.
:c:macro:`!Py_DEBUG` is enabled in the Unix build by adding
:option:`--with-pydebug` to the :file:`./configure` command.
It is also implied by the presence of the
not-Python-specific :c:macro:`!_DEBUG` macro. When :c:macro:`!Py_DEBUG` is enabled
in the Unix build, compiler optimization is disabled.
On Unix, :c:macro:`!Py_DEBUG` can be enabled by adding :option:`--with-pydebug`
to the :file:`./configure` command. This will also disable compiler optimization.
On Windows, selecting a debug build (e.g., by passing the :option:`-d` option to
:file:`PCbuild/build.bat`) automatically enables :c:macro:`!Py_DEBUG`.
Additionally, the presence of the not-Python-specific :c:macro:`!_DEBUG` macro,
when defined by the compiler, will also implicitly enable :c:macro:`!Py_DEBUG`.
In addition to the reference count debugging described below, extra checks are
performed, see :ref:`Python Debug Build <debug-build>`.
performed. See :ref:`Python Debug Build <debug-build>` for more details.
Defining :c:macro:`Py_TRACE_REFS` enables reference tracing
(see the :option:`configure --with-trace-refs option <--with-trace-refs>`).

View file

@ -54,6 +54,6 @@ There are two functions specifically for working with iterators.
- ``PYGEN_RETURN`` if iterator returns. Return value is returned via *presult*.
- ``PYGEN_NEXT`` if iterator yields. Yielded value is returned via *presult*.
- ``PYGEN_ERROR`` if iterator has raised and exception. *presult* is set to ``NULL``.
- ``PYGEN_ERROR`` if iterator has raised an exception. *presult* is set to ``NULL``.
.. versionadded:: 3.10

View file

@ -43,7 +43,7 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
.. impl-detail::
CPython keeps an array of integer objects for all integers
between ``-5`` and ``256``. When you create an int in that range
between ``-5`` and ``1024``. When you create an int in that range
you actually just get back a reference to the existing object.

View file

@ -3,11 +3,10 @@
.. _moduleobjects:
Module Objects
--------------
==============
.. index:: pair: object; module
.. c:var:: PyTypeObject PyModule_Type
.. index:: single: ModuleType (in module types)
@ -97,13 +96,6 @@ Module Objects
Note that Python code may rename a module by setting its :py:attr:`~module.__name__`
attribute.
.. c:function:: void* PyModule_GetState(PyObject *module)
Return the "state" of the module, that is, a pointer to the block of memory
allocated at module creation time, or ``NULL``. See
:c:member:`PyModuleDef.m_size`.
.. c:function:: PyModuleDef* PyModule_GetDef(PyObject *module)
Return a pointer to the :c:type:`PyModuleDef` struct from which the module was
@ -141,214 +133,108 @@ Module Objects
unencodable filenames, use :c:func:`PyModule_GetFilenameObject` instead.
.. _pymoduledef:
.. _pymoduledef_slot:
Module definitions
------------------
Module definition
-----------------
The functions in the previous section work on any module object, including
modules imported from Python code.
Modules created using the C API are typically defined using an
array of :dfn:`slots`.
The slots provide a "description" of how a module should be created.
Modules defined using the C API typically use a *module definition*,
:c:type:`PyModuleDef` -- a statically allocated, constant “description" of
how a module should be created.
.. versionchanged:: next
The definition is usually used to define an extension's “main” module object
(see :ref:`extension-modules` for details).
It is also used to
:ref:`create extension modules dynamically <moduledef-dynamic>`.
Previously, a :c:type:`PyModuleDef` struct was necessary to define modules.
The older way of defining modules is still available: consult either the
:ref:`pymoduledef` section or earlier versions of this documentation
if you plan to support earlier Python versions.
Unlike :c:func:`PyModule_New`, the definition allows management of
*module state* -- a piece of memory that is allocated and cleared together
with the module object.
Unlike the module's Python attributes, Python code cannot replace or delete
data stored in module state.
The slots array is usually used to define an extension module's “main”
module object (see :ref:`extension-modules` for details).
It can also be used to
:ref:`create extension modules dynamically <module-from-slots>`.
.. c:type:: PyModuleDef
Unless specified otherwise, the same slot ID may not be repeated
in an array of slots.
The module definition struct, which holds all information needed to create
a module object.
This structure must be statically allocated (or be otherwise guaranteed
to be valid while any modules created from it exist).
Usually, there is only one variable of this type for each extension module.
.. c:member:: PyModuleDef_Base m_base
Always initialize this member to :c:macro:`PyModuleDef_HEAD_INIT`.
.. c:member:: const char *m_name
Name for the new module.
.. c:member:: const char *m_doc
Docstring for the module; usually a docstring variable created with
:c:macro:`PyDoc_STRVAR` is used.
.. c:member:: Py_ssize_t m_size
Module state may be kept in a per-module memory area that can be
retrieved with :c:func:`PyModule_GetState`, rather than in static globals.
This makes modules safe for use in multiple sub-interpreters.
This memory area is allocated based on *m_size* on module creation,
and freed when the module object is deallocated, after the
:c:member:`~PyModuleDef.m_free` function has been called, if present.
Setting it to a non-negative value means that the module can be
re-initialized and specifies the additional amount of memory it requires
for its state.
Setting ``m_size`` to ``-1`` means that the module does not support
sub-interpreters, because it has global state.
Negative ``m_size`` is only allowed when using
:ref:`legacy single-phase initialization <single-phase-initialization>`
or when :ref:`creating modules dynamically <moduledef-dynamic>`.
See :PEP:`3121` for more details.
.. c:member:: PyMethodDef* m_methods
A pointer to a table of module-level functions, described by
:c:type:`PyMethodDef` values. Can be ``NULL`` if no functions are present.
.. c:member:: PyModuleDef_Slot* m_slots
An array of slot definitions for multi-phase initialization, terminated by
a ``{0, NULL}`` entry.
When using legacy single-phase initialization, *m_slots* must be ``NULL``.
.. versionchanged:: 3.5
Prior to version 3.5, this member was always set to ``NULL``,
and was defined as:
.. c:member:: inquiry m_reload
.. c:member:: traverseproc m_traverse
A traversal function to call during GC traversal of the module object, or
``NULL`` if not needed.
This function is not called if the module state was requested but is not
allocated yet. This is the case immediately after the module is created
and before the module is executed (:c:data:`Py_mod_exec` function). More
precisely, this function is not called if :c:member:`~PyModuleDef.m_size` is greater
than 0 and the module state (as returned by :c:func:`PyModule_GetState`)
is ``NULL``.
.. versionchanged:: 3.9
No longer called before the module state is allocated.
.. c:member:: inquiry m_clear
A clear function to call during GC clearing of the module object, or
``NULL`` if not needed.
This function is not called if the module state was requested but is not
allocated yet. This is the case immediately after the module is created
and before the module is executed (:c:data:`Py_mod_exec` function). More
precisely, this function is not called if :c:member:`~PyModuleDef.m_size` is greater
than 0 and the module state (as returned by :c:func:`PyModule_GetState`)
is ``NULL``.
Like :c:member:`PyTypeObject.tp_clear`, this function is not *always*
called before a module is deallocated. For example, when reference
counting is enough to determine that an object is no longer used,
the cyclic garbage collector is not involved and
:c:member:`~PyModuleDef.m_free` is called directly.
.. versionchanged:: 3.9
No longer called before the module state is allocated.
.. c:member:: freefunc m_free
A function to call during deallocation of the module object, or ``NULL``
if not needed.
This function is not called if the module state was requested but is not
allocated yet. This is the case immediately after the module is created
and before the module is executed (:c:data:`Py_mod_exec` function). More
precisely, this function is not called if :c:member:`~PyModuleDef.m_size` is greater
than 0 and the module state (as returned by :c:func:`PyModule_GetState`)
is ``NULL``.
.. versionchanged:: 3.9
No longer called before the module state is allocated.
Module slots
............
.. c:type:: PyModuleDef_Slot
.. c:member:: int slot
A slot ID, chosen from the available values explained below.
A slot ID, chosen from the available ``Py_mod_*`` values explained below.
An ID of 0 marks the end of a :c:type:`!PyModuleDef_Slot` array.
.. c:member:: void* value
Value of the slot, whose meaning depends on the slot ID.
.. versionadded:: 3.5
The available slot types are:
.. c:macro:: Py_mod_create
Specifies a function that is called to create the module object itself.
The *value* pointer of this slot must point to a function of the signature:
.. c:function:: PyObject* create_module(PyObject *spec, PyModuleDef *def)
:no-index-entry:
:no-contents-entry:
The function receives a :py:class:`~importlib.machinery.ModuleSpec`
instance, as defined in :PEP:`451`, and the module definition.
It should return a new module object, or set an error
and return ``NULL``.
This function should be kept minimal. In particular, it should not
call arbitrary Python code, as trying to import the same module again may
result in an infinite loop.
Multiple ``Py_mod_create`` slots may not be specified in one module
definition.
If ``Py_mod_create`` is not specified, the import machinery will create
a normal module object using :c:func:`PyModule_New`. The name is taken from
*spec*, not the definition, to allow extension modules to dynamically adjust
to their place in the module hierarchy and be imported under different
names through symlinks, all while sharing a single module definition.
There is no requirement for the returned object to be an instance of
:c:type:`PyModule_Type`. Any type can be used, as long as it supports
setting and getting import-related attributes.
However, only ``PyModule_Type`` instances may be returned if the
``PyModuleDef`` has non-``NULL`` ``m_traverse``, ``m_clear``,
``m_free``; non-zero ``m_size``; or slots other than ``Py_mod_create``.
The value may not be NULL.
To leave a slot out, omit the :c:type:`PyModuleDef_Slot` entry entirely.
.. versionadded:: 3.5
.. c:macro:: Py_mod_exec
Specifies a function that is called to *execute* the module.
This is equivalent to executing the code of a Python module: typically,
this function adds classes and constants to the module.
The signature of the function is:
Metadata slots
..............
.. c:function:: int exec_module(PyObject* module)
:no-index-entry:
:no-contents-entry:
.. c:macro:: Py_mod_name
If multiple ``Py_mod_exec`` slots are specified, they are processed in the
order they appear in the *m_slots* array.
:c:type:`Slot ID <PyModuleDef_Slot.slot>` for the name of the new module,
as a NUL-terminated UTF8-encoded ``const char *``.
.. versionadded:: 3.5
Note that modules are typically created using a
:py:class:`~importlib.machinery.ModuleSpec`, and when they are, the
name from the spec will be used instead of :c:data:`!Py_mod_name`.
However, it is still recommended to include this slot for introspection
and debugging purposes.
.. versionadded:: next
Use :c:member:`PyModuleDef.m_name` instead to support previous versions.
.. c:macro:: Py_mod_doc
:c:type:`Slot ID <PyModuleDef_Slot.slot>` for the docstring of the new
module, as a NUL-terminated UTF8-encoded ``const char *``.
Usually it is set to a variable created with :c:macro:`PyDoc_STRVAR`.
.. versionadded:: next
Use :c:member:`PyModuleDef.m_doc` instead to support previous versions.
Feature slots
.............
.. c:macro:: Py_mod_abi
:c:type:`Slot ID <PyModuleDef_Slot.slot>` whose value points to
a :c:struct:`PyABIInfo` structure describing the ABI that
the extension is using.
A suitable :c:struct:`!PyABIInfo` variable can be defined using the
:c:macro:`PyABIInfo_VAR` macro, as in:
.. code-block:: c
PyABIInfo_VAR(abi_info);
static PyModuleDef_Slot mymodule_slots[] = {
{Py_mod_abi, &abi_info},
...
};
When creating a module, Python checks the value of this slot
using :c:func:`PyABIInfo_Check`.
.. versionadded:: 3.15
.. c:macro:: Py_mod_multiple_interpreters
Specifies one of the following values:
:c:type:`Slot ID <PyModuleDef_Slot.slot>` whose value is one of:
.. c:namespace:: NULL
@ -371,9 +257,6 @@ The available slot types are:
This slot determines whether or not importing this module
in a subinterpreter will fail.
Multiple ``Py_mod_multiple_interpreters`` slots may not be specified
in one module definition.
If ``Py_mod_multiple_interpreters`` is not specified, the import
machinery defaults to ``Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED``.
@ -381,7 +264,7 @@ The available slot types are:
.. c:macro:: Py_mod_gil
Specifies one of the following values:
:c:type:`Slot ID <PyModuleDef_Slot.slot>` whose value is one of:
.. c:namespace:: NULL
@ -399,23 +282,482 @@ The available slot types are:
this module will cause the GIL to be automatically enabled. See
:ref:`whatsnew313-free-threaded-cpython` for more detail.
Multiple ``Py_mod_gil`` slots may not be specified in one module definition.
If ``Py_mod_gil`` is not specified, the import machinery defaults to
``Py_MOD_GIL_USED``.
.. versionadded:: 3.13
.. _moduledef-dynamic:
Creation and initialization slots
.................................
.. c:macro:: Py_mod_create
:c:type:`Slot ID <PyModuleDef_Slot.slot>` for a function that creates
the module object itself.
The function must have the signature:
.. c:function:: PyObject* create_module(PyObject *spec, PyModuleDef *def)
:no-index-entry:
:no-contents-entry:
The function will be called with:
- *spec*: a ``ModuleSpec``-like object, meaning that any attributes defined
for :py:class:`importlib.machinery.ModuleSpec` have matching semantics.
However, any of the attributes may be missing.
- *def*: ``NULL``, or the module definition if the module is created from one.
The function should return a new module object, or set an error
and return ``NULL``.
This function should be kept minimal. In particular, it should not
call arbitrary Python code, as trying to import the same module again may
result in an infinite loop.
If ``Py_mod_create`` is not specified, the import machinery will create
a normal module object using :c:func:`PyModule_New`. The name is taken from
*spec*, not the definition, to allow extension modules to dynamically adjust
to their place in the module hierarchy and be imported under different
names through symlinks, all while sharing a single module definition.
There is no requirement for the returned object to be an instance of
:c:type:`PyModule_Type`.
However, some slots may only be used with
:c:type:`!PyModule_Type` instances; in particular:
- :c:macro:`Py_mod_exec`,
- :ref:`module state slots <ext-module-state-slots>` (``Py_mod_state_*``),
- :c:macro:`Py_mod_token`.
.. versionadded:: 3.5
.. versionchanged:: next
The *slots* argument may be a ``ModuleSpec``-like object, rather than
a true :py:class:`~importlib.machinery.ModuleSpec` instance.
Note that previous versions of CPython did not enforce this.
The *def* argument may now be ``NULL``, since modules are not necessarily
made from definitions.
.. c:macro:: Py_mod_exec
:c:type:`Slot ID <PyModuleDef_Slot.slot>` for a function that will
:dfn:`execute`, or initialize, the module.
This function does the equivalent to executing the code of a Python module:
typically, it adds classes and constants to the module.
The signature of the function is:
.. c:function:: int exec_module(PyObject* module)
:no-index-entry:
:no-contents-entry:
See the :ref:`capi-module-support-functions` section for some useful
functions to call.
For backwards compatibility, the :c:type:`PyModuleDef.m_slots` array may
contain multiple :c:macro:`!Py_mod_exec` slots; these are processed in the
order they appear in the array.
Elsewhere (that is, in arguments to :c:func:`PyModule_FromSlotsAndSpec`
and in return values of :samp:`PyModExport_{<name>}`), repeating the slot
is not allowed.
.. versionadded:: 3.5
.. versionchanged:: next
Repeated ``Py_mod_exec`` slots are disallowed, except in
:c:type:`PyModuleDef.m_slots`.
.. c:macro:: Py_mod_methods
:c:type:`Slot ID <PyModuleDef_Slot.slot>` for a table of module-level
functions, as an array of :c:type:`PyMethodDef` values suitable as the
*functions* argument to :c:func:`PyModule_AddFunctions`.
Like other slot IDs, a slots array may only contain one
:c:macro:`!Py_mod_methods` entry.
To add functions from multiple :c:type:`PyMethodDef` arrays, call
:c:func:`PyModule_AddFunctions` in the :c:macro:`Py_mod_exec` function.
The table must be statically allocated (or otherwise guaranteed to outlive
the module object).
.. versionadded:: next
Use :c:member:`PyModuleDef.m_methods` instead to support previous versions.
.. _ext-module-state:
Module state
------------
Extension modules can have *module state* -- a
piece of memory that is allocated on module creation,
and freed when the module object is deallocated.
The module state is specified using :ref:`dedicated slots <ext-module-state-slots>`.
A typical use of module state is storing an exception type -- or indeed *any*
type object defined by the module --
Unlike the module's Python attributes, Python code cannot replace or delete
data stored in module state.
Keeping per-module information in attributes and module state, rather than in
static globals, makes module objects *isolated* and safer for use in
multiple sub-interpreters.
It also helps Python do an orderly clean-up when it shuts down.
Extensions that keep references to Python objects as part of module state must
implement :c:macro:`Py_mod_state_traverse` and :c:macro:`Py_mod_state_clear`
functions to avoid reference leaks.
To retrieve the state from a given module, use the following functions:
.. c:function:: void* PyModule_GetState(PyObject *module)
Return the "state" of the module, that is, a pointer to the block of memory
allocated at module creation time, or ``NULL``. See
:c:macro:`Py_mod_state_size`.
On error, return ``NULL`` with an exception set.
Use :c:func:`PyErr_Occurred` to tell this case apart from missing
module state.
.. c:function:: int PyModule_GetStateSize(PyObject *, Py_ssize_t *result)
Set *\*result* to the size of the module's state, as specified using
:c:macro:`Py_mod_state_size` (or :c:member:`PyModuleDef.m_size`),
and return 0.
On error, set *\*result* to -1, and return -1 with an exception set.
.. versionadded:: next
.. _ext-module-state-slots:
Slots for defining module state
...............................
The following :c:member:`PyModuleDef_Slot.slot` IDs are available for
defining the module state.
.. c:macro:: Py_mod_state_size
:c:type:`Slot ID <PyModuleDef_Slot.slot>` for the size of the module state,
in bytes.
Setting the value to a non-negative value means that the module can be
re-initialized and specifies the additional amount of memory it requires
for its state.
See :PEP:`3121` for more details.
Use :c:func:`PyModule_GetStateSize` to retrieve the size of a given module.
.. versionadded:: next
Use :c:member:`PyModuleDef.m_size` instead to support previous versions.
.. c:macro:: Py_mod_state_traverse
:c:type:`Slot ID <PyModuleDef_Slot.slot>` for a traversal function to call
during GC traversal of the module object.
The signature of the function, and meanings of the arguments,
is similar as for :c:member:`PyTypeObject.tp_traverse`:
.. c:function:: int traverse_module_state(PyObject *module, visitproc visit, void *arg)
:no-index-entry:
:no-contents-entry:
This function is not called if the module state was requested but is not
allocated yet. This is the case immediately after the module is created
and before the module is executed (:c:data:`Py_mod_exec` function). More
precisely, this function is not called if the state size
(:c:data:`Py_mod_state_size`) is greater than 0 and the module state
(as returned by :c:func:`PyModule_GetState`) is ``NULL``.
.. versionadded:: next
Use :c:member:`PyModuleDef.m_size` instead to support previous versions.
.. c:macro:: Py_mod_state_clear
:c:type:`Slot ID <PyModuleDef_Slot.slot>` for a clear function to call
during GC clearing of the module object.
The signature of the function is:
.. c:function:: int clear_module_state(PyObject* module)
:no-index-entry:
:no-contents-entry:
This function is not called if the module state was requested but is not
allocated yet. This is the case immediately after the module is created
and before the module is executed (:c:data:`Py_mod_exec` function). More
precisely, this function is not called if the state size
(:c:data:`Py_mod_state_size`) is greater than 0 and the module state
(as returned by :c:func:`PyModule_GetState`) is ``NULL``.
Like :c:member:`PyTypeObject.tp_clear`, this function is not *always*
called before a module is deallocated. For example, when reference
counting is enough to determine that an object is no longer used,
the cyclic garbage collector is not involved and
the :c:macro:`Py_mod_state_free` function is called directly.
.. versionadded:: next
Use :c:member:`PyModuleDef.m_clear` instead to support previous versions.
.. c:macro:: Py_mod_state_free
:c:type:`Slot ID <PyModuleDef_Slot.slot>` for a function to call during
deallocation of the module object.
The signature of the function is:
.. c:function:: int free_module_state(PyObject* module)
:no-index-entry:
:no-contents-entry:
This function is not called if the module state was requested but is not
allocated yet. This is the case immediately after the module is created
and before the module is executed (:c:data:`Py_mod_exec` function). More
precisely, this function is not called if the state size
(:c:data:`Py_mod_state_size`) is greater than 0 and the module state
(as returned by :c:func:`PyModule_GetState`) is ``NULL``.
.. versionadded:: next
Use :c:member:`PyModuleDef.m_free` instead to support previous versions.
.. _ext-module-token:
Module token
............
Each module may have an associated *token*: a pointer-sized value intended to
identify of the module state's memory layout.
This means that if you have a module object, but you are not sure if it
“belongs” to your extension, you can check using code like this:
.. code-block:: c
PyObject *module = <the module in question>
void *module_token;
if (PyModule_GetToken(module, &module_token) < 0) {
return NULL;
}
if (module_token != your_token) {
PyErr_SetString(PyExc_ValueError, "unexpected module")
return NULL;
}
// This module's state has the expected memory layout; it's safe to cast
struct my_state state = (struct my_state*)PyModule_GetState(module)
A module's token -- and the *your_token* value to use in the above code -- is:
- For modules created with :c:type:`PyModuleDef`: the address of that
:c:type:`PyModuleDef`;
- For modules defined with the :c:macro:`Py_mod_token` slot: the value
of that slot;
- For modules created from an ``PyModExport_*``
:ref:`export hook <extension-export-hook>`: the slots array that the export
hook returned (unless overriden with :c:macro:`Py_mod_token`).
.. c:macro:: Py_mod_token
:c:type:`Slot ID <PyModuleDef_Slot.slot>` for the module token.
If you use this slot to set the module token (rather than rely on the
default), you must ensure that:
* The pointer outlives the class, so it's not reused for something else
while the class exists.
* It "belongs" to the extension module where the class lives, so it will not
clash with other extensions.
* If the token points to a :c:type:`PyModuleDef` struct, the module should
behave as if it was created from that :c:type:`PyModuleDef`.
In particular, the module state must have matching layout and semantics.
Modules created from :c:type:`PyModuleDef` allways use the address of
the :c:type:`PyModuleDef` as the token.
This means that :c:macro:`!Py_mod_token` cannot be used in
:c:member:`PyModuleDef.m_slots`.
.. versionadded:: next
.. c:function:: int PyModule_GetToken(PyObject *module, void** result)
Set *\*result* to the module's token and return 0.
On error, set *\*result* to NULL, and return -1 with an exception set.
.. versionadded:: next
See also :c:func:`PyType_GetModuleByToken`.
.. _module-from-slots:
Creating extension modules dynamically
--------------------------------------
The following functions may be used to create a module outside of an
extension's :ref:`initialization function <extension-export-hook>`.
They are also used in
:ref:`single-phase initialization <single-phase-initialization>`.
The following functions may be used to create an extension module dynamically,
rather than from an extension's :ref:`export hook <extension-export-hook>`.
.. c:function:: PyObject *PyModule_FromSlotsAndSpec(const PyModuleDef_Slot *slots, PyObject *spec)
Create a new module object, given an array of :ref:`slots <pymoduledef_slot>`
and the :py:class:`~importlib.machinery.ModuleSpec` *spec*.
The *slots* argument must point to an array of :c:type:`PyModuleDef_Slot`
structures, terminated by an entry slot with slot ID of 0
(typically written as ``{0}`` or ``{0, NULL}`` in C).
The *slots* argument may not be ``NULL``.
The *spec* argument may be any ``ModuleSpec``-like object, as described
in :c:macro:`Py_mod_create` documentation.
Currently, the *spec* must have a ``name`` attribute.
On success, return the new module.
On error, return ``NULL`` with an exception set.
Note that this does not process the module's execution slot
(:c:data:`Py_mod_exec`).
Both :c:func:`!PyModule_FromSlotsAndSpec` and :c:func:`PyModule_Exec`
must be called to fully initialize a module.
(See also :ref:`multi-phase-initialization`.)
The *slots* array only needs to be valid for the duration of the
:c:func:`!PyModule_FromSlotsAndSpec` call.
In particular, it may be heap-allocated.
.. versionadded:: next
.. c:function:: int PyModule_Exec(PyObject *module)
Execute the :c:data:`Py_mod_exec` slot(s) of the given *module*.
On success, return 0.
On error, return -1 with an exception set.
For clarity: If *module* has no slots, for example if it uses
:ref:`legacy single-phase initialization <single-phase-initialization>`,
this function does nothing and returns 0.
.. versionadded:: next
.. _pymoduledef:
Module definition struct
------------------------
Traditionally, extension modules were defined using a *module definition*
as the “description" of how a module should be created.
Rather than using an array of :ref:`slots <pymoduledef_slot>` directly,
the definition has dedicated members for most common functionality,
and allows additional slots as an extension mechanism.
This way of defining modules is still available and there are no plans to
remove it.
.. c:type:: PyModuleDef
The module definition struct, which holds information needed to create
a module object.
This structure must be statically allocated (or be otherwise guaranteed
to be valid while any modules created from it exist).
Usually, there is only one variable of this type for each extension module
defined this way.
.. c:member:: PyModuleDef_Base m_base
Always initialize this member to :c:macro:`PyModuleDef_HEAD_INIT`:
.. c:namespace:: NULL
.. c:type:: PyModuleDef_Base
The type of :c:member:`!PyModuleDef.m_base`.
.. c:macro:: PyModuleDef_HEAD_INIT
The required initial value for :c:member:`!PyModuleDef.m_base`.
.. c:member:: const char *m_name
Corresponds to the :c:macro:`Py_mod_name` slot.
.. c:member:: const char *m_doc
These members correspond to the :c:macro:`Py_mod_doc` slot.
Setting this to NULL is equivalent to omitting the slot.
.. c:member:: Py_ssize_t m_size
Corresponds to the :c:macro:`Py_mod_state_size` slot.
Setting this to zero is equivalent to omitting the slot.
When using :ref:`legacy single-phase initialization <single-phase-initialization>`
or when creating modules dynamically using :c:func:`PyModule_Create`
or :c:func:`PyModule_Create2`, :c:member:`!m_size` may be set to -1.
This indicates that the module does not support sub-interpreters,
because it has global state.
.. c:member:: PyMethodDef *m_methods
Corresponds to the :c:macro:`Py_mod_methods` slot.
Setting this to NULL is equivalent to omitting the slot.
.. c:member:: PyModuleDef_Slot* m_slots
An array of additional slots, terminated by a ``{0, NULL}`` entry.
This array may not contain slots corresponding to :c:type:`PyModuleDef`
members.
For example, you cannot use :c:macro:`Py_mod_name` in :c:member:`!m_slots`;
the module name must be given as :c:member:`PyModuleDef.m_name`.
.. versionchanged:: 3.5
Prior to version 3.5, this member was always set to ``NULL``,
and was defined as:
.. c:member:: inquiry m_reload
.. c:member:: traverseproc m_traverse
inquiry m_clear
freefunc m_free
These members correspond to the :c:macro:`Py_mod_state_traverse`,
:c:macro:`Py_mod_state_clear`, and :c:macro:`Py_mod_state_free` slots,
respectively.
Setting these members to NULL is equivalent to omitting the
corresponding slots.
.. versionchanged:: 3.9
:c:member:`m_traverse`, :c:member:`m_clear` and :c:member:`m_free`
functions are longer called before the module state is allocated.
.. _moduledef-dynamic:
The following API can be used to create modules from a :c:type:`!PyModuleDef`
struct:
.. c:function:: PyObject* PyModule_Create(PyModuleDef *def)
@ -492,12 +834,13 @@ They are also used in
useful for versioning. This may change in the future.
.. _capi-module-support-functions:
Support functions
-----------------
The following functions are provided to help initialize a module
state.
They are intended for a module's execution slots (:c:data:`Py_mod_exec`),
The following functions are provided to help initialize a module object.
They are intended for a module's execution slot (:c:data:`Py_mod_exec`),
the initialization function for legacy :ref:`single-phase initialization <single-phase-initialization>`,
or code that creates modules dynamically.

View file

@ -85,6 +85,35 @@ Object Protocol
instead of the :func:`repr`.
.. c:function:: void PyUnstable_Object_Dump(PyObject *op)
Dump an object *op* to ``stderr``. This should only be used for debugging.
The output is intended to try dumping objects even after memory corruption:
* Information is written starting with fields that are the least likely to
crash when accessed.
* This function can be called without an :term:`attached thread state`, but
it's not recommended to do so: it can cause deadlocks.
* An object that does not belong to the current interpreter may be dumped,
but this may also cause crashes or unintended behavior.
* Implement a heuristic to detect if the object memory has been freed. Don't
display the object contents in this case, only its memory address.
* The output format may change at any time.
Example of output:
.. code-block:: output
object address : 0x7f80124702c0
object refcount : 2
object type : 0x9902e0
object type name: str
object repr : 'abcdef'
.. versionadded:: next
.. c:function:: int PyObject_HasAttrWithError(PyObject *o, PyObject *attr_name)
Returns ``1`` if *o* has the attribute *attr_name*, and ``0`` otherwise.
@ -197,6 +226,13 @@ Object Protocol
in favour of using :c:func:`PyObject_DelAttr`, but there are currently no
plans to remove it.
The function must not be called with a ``NULL`` *v* and an exception set.
This case can arise from forgetting ``NULL`` checks and would delete the
attribute.
.. versionchanged:: 3.15
Must not be called with NULL value if an exception is set.
.. c:function:: int PyObject_SetAttrString(PyObject *o, const char *attr_name, PyObject *v)
@ -207,6 +243,10 @@ Object Protocol
If *v* is ``NULL``, the attribute is deleted, but this feature is
deprecated in favour of using :c:func:`PyObject_DelAttrString`.
The function must not be called with a ``NULL`` *v* and an exception set.
This case can arise from forgetting ``NULL`` checks and would delete the
attribute.
The number of different attribute names passed to this function
should be kept small, usually by using a statically allocated string
as *attr_name*.
@ -215,6 +255,10 @@ Object Protocol
For more details, see :c:func:`PyUnicode_InternFromString`, which may be
used internally to create a key object.
.. versionchanged:: 3.15
Must not be called with NULL value if an exception is set.
.. c:function:: int PyObject_GenericSetAttr(PyObject *o, PyObject *name, PyObject *value)
Generic attribute setter and deleter function that is meant

View file

@ -5,11 +5,12 @@
Support for Perf Maps
----------------------
On supported platforms (as of this writing, only Linux), the runtime can take
On supported platforms (Linux and macOS), the runtime can take
advantage of *perf map files* to make Python functions visible to an external
profiling tool (such as `perf <https://perf.wiki.kernel.org/index.php/Main_Page>`_).
A running process may create a file in the ``/tmp`` directory, which contains entries
that can map a section of executable code to a name. This interface is described in the
profiling tool (such as `perf <https://perf.wiki.kernel.org/index.php/Main_Page>`_ or
`samply <https://github.com/mstange/samply/>`_). A running process may create a
file in the ``/tmp`` directory, which contains entries that can map a section
of executable code to a name. This interface is described in the
`documentation of the Linux Perf tool <https://git.kernel.org/pub/scm/linux/
kernel/git/torvalds/linux.git/tree/tools/perf/Documentation/jit-interface.txt>`_.

View file

@ -147,7 +147,7 @@ subtypes but not for instances of :class:`frozenset` or its subtypes.
Return ``1`` if found and removed, ``0`` if not found (no action taken), and ``-1`` if an
error is encountered. Does not raise :exc:`KeyError` for missing keys. Raise a
:exc:`TypeError` if the *key* is unhashable. Unlike the Python :meth:`~frozenset.discard`
:exc:`TypeError` if the *key* is unhashable. Unlike the Python :meth:`~set.discard`
method, this function does not automatically convert unhashable sets into
temporary frozensets. Raise :exc:`SystemError` if *set* is not an
instance of :class:`set` or its subtype.

View file

@ -2,9 +2,9 @@
.. _stable:
***************
C API Stability
***************
***********************
C API and ABI Stability
***********************
Unless documented otherwise, Python's C API is covered by the Backwards
Compatibility Policy, :pep:`387`.
@ -199,6 +199,162 @@ This is the case with Windows and macOS releases from ``python.org`` and many
third-party distributors.
ABI Checking
============
.. versionadded:: 3.15
Python includes a rudimentary check for ABI compatibility.
This check is not comprehensive.
It only guards against common cases of incompatible modules being
installed for the wrong interpreter.
It also does not take :ref:`platform incompatibilities <stable-abi-platform>`
into account.
It can only be done after an extension is successfully loaded.
Despite these limitations, it is recommended that extension modules use this
mechanism, so that detectable incompatibilities raise exceptions rather than
crash.
Most modules can use this check via the :c:data:`Py_mod_abi`
slot and the :c:macro:`PyABIInfo_VAR` macro, for example like this:
.. code-block:: c
PyABIInfo_VAR(abi_info);
static PyModuleDef_Slot mymodule_slots[] = {
{Py_mod_abi, &abi_info},
...
};
The full API is described below for advanced use cases.
.. c:function:: int PyABIInfo_Check(PyABIInfo *info, const char *module_name)
Verify that the given *info* is compatible with the currently running
interpreter.
Return 0 on success. On failure, raise an exception and return -1.
If the ABI is incompatible, the raised exception will be :py:exc:`ImportError`.
The *module_name* argument can be ``NULL``, or point to a NUL-terminated
UTF-8-encoded string used for error messages.
Note that if *info* describes the ABI that the current code uses (as defined
by :c:macro:`PyABIInfo_VAR`, for example), using any other Python C API
may lead to crashes.
In particular, it is not safe to examine the raised exception.
.. versionadded:: 3.15
.. c:macro:: PyABIInfo_VAR(NAME)
Define a static :c:struct:`PyABIInfo` variable with the given *NAME* that
describes the ABI that the current code will use.
This macro expands to:
.. code-block:: c
static PyABIInfo NAME = {
1, 0,
PyABIInfo_DEFAULT_FLAGS,
PY_VERSION_HEX,
PyABIInfo_DEFAULT_ABI_VERSION
}
.. versionadded:: 3.15
.. c:type:: PyABIInfo
.. c:member:: uint8_t abiinfo_major_version
The major version of :c:struct:`PyABIInfo`. Can be set to:
* ``0`` to skip all checking, or
* ``1`` to specify this version of :c:struct:`!PyABIInfo`.
.. c:member:: uint8_t abiinfo_minor_version
The minor version of :c:struct:`PyABIInfo`.
Must be set to ``0``; larger values are reserved for backwards-compatible
future versions of :c:struct:`!PyABIInfo`.
.. c:member:: uint16_t flags
.. c:namespace:: NULL
This field is usually set to the following macro:
.. c:macro:: PyABIInfo_DEFAULT_FLAGS
Default flags, based on current values of macros such as
:c:macro:`Py_LIMITED_API` and :c:macro:`Py_GIL_DISABLED`.
Alternately, the field can be set to the following flags, combined
by bitwise OR.
Unused bits must be set to zero.
ABI variant -- one of:
.. c:macro:: PyABIInfo_STABLE
Specifies that the stable ABI is used.
.. c:macro:: PyABIInfo_INTERNAL
Specifies ABI specific to a particular build of CPython.
Internal use only.
Free-threading compatibility -- one of:
.. c:macro:: PyABIInfo_FREETHREADED
Specifies ABI compatible with free-threading builds of CPython.
(That is, ones compiled with :option:`--disable-gil`; with ``t``
in :py:data:`sys.abiflags`)
.. c:macro:: PyABIInfo_GIL
Specifies ABI compatible with non-free-threading builds of CPython
(ones compiled *without* :option:`--disable-gil`).
.. c:member:: uint32_t build_version
The version of the Python headers used to build the code, in the format
used by :c:macro:`PY_VERSION_HEX`.
This can be set to ``0`` to skip any checks related to this field.
This option is meant mainly for projects that do not use the CPython
headers directly, and do not emulate a specific version of them.
.. c:member:: uint32_t abi_version
The ABI version.
For the Stable ABI, this field should be the value of
:c:macro:`Py_LIMITED_API`
(except if :c:macro:`Py_LIMITED_API` is ``3``; use
:c:expr:`Py_PACK_VERSION(3, 2)` in that case).
Otherwise, it should be set to :c:macro:`PY_VERSION_HEX`.
It can also be set to ``0`` to skip any checks related to this field.
.. c:namespace:: NULL
.. c:macro:: PyABIInfo_DEFAULT_ABI_VERSION
The value that should be used for this field, based on current
values of macros such as :c:macro:`Py_LIMITED_API`,
:c:macro:`PY_VERSION_HEX` and :c:macro:`Py_GIL_DISABLED`.
.. versionadded:: 3.15
.. _limited-api-list:
Contents of Limited API

View file

@ -280,6 +280,8 @@ Implementing functions and methods
Name of the method.
A ``NULL`` *ml_name* marks the end of a :c:type:`!PyMethodDef` array.
.. c:member:: PyCFunction ml_meth
Pointer to the C implementation.

View file

@ -276,10 +276,57 @@ These are utility functions that make functionality from the :mod:`sys` module
accessible to C code. They all work with the current interpreter thread's
:mod:`sys` module's dict, which is contained in the internal thread state structure.
.. c:function:: PyObject *PySys_GetAttr(PyObject *name)
Get the attribute *name* of the :mod:`sys` module.
Return a :term:`strong reference`.
Raise :exc:`RuntimeError` and return ``NULL`` if it does not exist or
if the :mod:`sys` module cannot be found.
If the non-existing object should not be treated as a failure, you can use
:c:func:`PySys_GetOptionalAttr` instead.
.. versionadded:: 3.15
.. c:function:: PyObject *PySys_GetAttrString(const char *name)
This is the same as :c:func:`PySys_GetAttr`, but *name* is
specified as a :c:expr:`const char*` UTF-8 encoded bytes string,
rather than a :c:expr:`PyObject*`.
If the non-existing object should not be treated as a failure, you can use
:c:func:`PySys_GetOptionalAttrString` instead.
.. versionadded:: 3.15
.. c:function:: int PySys_GetOptionalAttr(PyObject *name, PyObject **result)
Variant of :c:func:`PySys_GetAttr` which doesn't raise
exception if the object does not exist.
* Set *\*result* to a new :term:`strong reference` to the object and
return ``1`` if the object exists.
* Set *\*result* to ``NULL`` and return ``0`` without setting an exception
if the object does not exist.
* Set an exception, set *\*result* to ``NULL``, and return ``-1``,
if an error occurred.
.. versionadded:: 3.15
.. c:function:: int PySys_GetOptionalAttrString(const char *name, PyObject **result)
This is the same as :c:func:`PySys_GetOptionalAttr`, but *name* is
specified as a :c:expr:`const char*` UTF-8 encoded bytes string,
rather than a :c:expr:`PyObject*`.
.. versionadded:: 3.15
.. c:function:: PyObject *PySys_GetObject(const char *name)
Return the object *name* from the :mod:`sys` module or ``NULL`` if it does
not exist, without setting an exception.
Similar to :c:func:`PySys_GetAttrString`, but return a :term:`borrowed
reference` and return ``NULL`` *without* setting exception on failure.
Preserves exception that was set before the call.
.. c:function:: int PySys_SetObject(const char *name, PyObject *v)
@ -287,14 +334,6 @@ accessible to C code. They all work with the current interpreter thread's
case *name* is deleted from the sys module. Returns ``0`` on success, ``-1``
on error.
.. c:function:: void PySys_ResetWarnOptions()
Reset :data:`sys.warnoptions` to an empty list. This function may be
called prior to :c:func:`Py_Initialize`.
.. deprecated-removed:: 3.13 3.15
Clear :data:`sys.warnoptions` and :data:`!warnings.filters` instead.
.. c:function:: void PySys_WriteStdout(const char *format, ...)
Write the output string described by *format* to :data:`sys.stdout`. No

View file

@ -37,6 +37,19 @@ Tuple Objects
or ``NULL`` with an exception set on failure.
.. c:function:: PyObject* PyTuple_FromArray(PyObject *const *array, Py_ssize_t size)
Create a tuple of *size* items and copy references from *array* to the new
tuple.
*array* can be NULL if *size* is ``0``.
On success, return a new reference.
On error, set an exception and return ``NULL``.
.. versionadded:: 3.15
.. c:function:: PyObject* PyTuple_Pack(Py_ssize_t n, ...)
Return a new tuple object of size *n*,

View file

@ -283,8 +283,8 @@ Type Objects
``Py_TYPE(self)`` may be a *subclass* of the intended class, and subclasses
are not necessarily defined in the same module as their superclass.
See :c:type:`PyCMethod` to get the class that defines the method.
See :c:func:`PyType_GetModuleByDef` for cases when :c:type:`!PyCMethod` cannot
be used.
See :c:func:`PyType_GetModuleByToken` for cases when :c:type:`!PyCMethod`
cannot be used.
.. versionadded:: 3.9
@ -304,10 +304,10 @@ Type Objects
.. versionadded:: 3.9
.. c:function:: PyObject* PyType_GetModuleByDef(PyTypeObject *type, struct PyModuleDef *def)
.. c:function:: PyObject* PyType_GetModuleByToken(PyTypeObject *type, const void *mod_token)
Find the first superclass whose module was created from
the given :c:type:`PyModuleDef` *def*, and return that module.
Find the first superclass whose module has the given
:ref:`module token <ext-module-token>`, and return that module.
If no module is found, raises a :py:class:`TypeError` and returns ``NULL``.
@ -317,6 +317,23 @@ Type Objects
and other places where a method's defining class cannot be passed using the
:c:type:`PyCMethod` calling convention.
.. versionadded:: next
.. c:function:: PyObject* PyType_GetModuleByDef(PyTypeObject *type, struct PyModuleDef *def)
Find the first superclass whose module was created from the given
:c:type:`PyModuleDef` *def*, or whose :ref:`module token <ext-module-token>`
is equal to *def*, and return that module.
Note that modules created from a :c:type:`PyModuleDef` always have their
token set to the :c:type:`PyModuleDef`'s address.
In other words, this function is equivalent to
:c:func:`PyType_GetModuleByToken`, except that it:
- returns a borrowed reference, and
- has a non-``void*`` argument type (which is a cosmetic difference in C).
The returned reference is :term:`borrowed <borrowed reference>` from *type*,
and will be valid as long as you hold a reference to *type*.
Do not release it with :c:func:`Py_DECREF` or similar.
@ -324,10 +341,10 @@ Type Objects
.. versionadded:: 3.11
.. c:function:: int PyType_GetBaseByToken(PyTypeObject *type, void *token, PyTypeObject **result)
.. c:function:: int PyType_GetBaseByToken(PyTypeObject *type, void *tp_token, PyTypeObject **result)
Find the first superclass in *type*'s :term:`method resolution order` whose
:c:macro:`Py_tp_token` token is equal to the given one.
:c:macro:`Py_tp_token` token is equal to *tp_token*.
* If found, set *\*result* to a new :term:`strong reference`
to it and return ``1``.
@ -338,7 +355,7 @@ Type Objects
The *result* argument may be ``NULL``, in which case *\*result* is not set.
Use this if you need only the return value.
The *token* argument may not be ``NULL``.
The *tp_token* argument may not be ``NULL``.
.. versionadded:: 3.14

View file

@ -1278,7 +1278,7 @@ and :c:data:`PyType_Type` effectively act as defaults.)
This bit indicates that instances of the class have a :attr:`~object.__dict__`
attribute, and that the space for the dictionary is managed by the VM.
If this flag is set, :c:macro:`Py_TPFLAGS_HAVE_GC` should also be set.
If this flag is set, :c:macro:`Py_TPFLAGS_HAVE_GC` must also be set.
The type traverse function must call :c:func:`PyObject_VisitManagedDict`
and its clear function must call :c:func:`PyObject_ClearManagedDict`.
@ -1296,6 +1296,8 @@ and :c:data:`PyType_Type` effectively act as defaults.)
This bit indicates that instances of the class should be weakly
referenceable.
If this flag is set, :c:macro:`Py_TPFLAGS_HAVE_GC` must also be set.
.. versionadded:: 3.12
**Inheritance:**
@ -1304,6 +1306,19 @@ and :c:data:`PyType_Type` effectively act as defaults.)
:c:member:`~PyTypeObject.tp_weaklistoffset` field is set in a superclass.
.. c:macro:: Py_TPFLAGS_PREHEADER
These bits indicate that the VM will manage some fields by storing them
before the object. Currently, this macro is equivalent to
:c:expr:`Py_TPFLAGS_MANAGED_DICT | Py_TPFLAGS_MANAGED_WEAKREF`.
This macro value relies on the implementation of the VM, so its value is not
stable and may change in a future version. Prefer using individual
flags instead.
.. versionadded:: 3.12
.. c:macro:: Py_TPFLAGS_ITEMS_AT_END
Only usable with variable-size types, i.e. ones with non-zero

View file

@ -191,6 +191,22 @@ access to internal read-only data of Unicode objects:
.. versionadded:: 3.2
.. c:function:: Py_hash_t PyUnstable_Unicode_GET_CACHED_HASH(PyObject *str)
If the hash of *str*, as returned by :c:func:`PyObject_Hash`, has been
cached and is immediately available, return it.
Otherwise, return ``-1`` *without* setting an exception.
If *str* is not a string (that is, if ``PyUnicode_Check(obj)``
is false), the behavior is undefined.
This function never fails with an exception.
Note that there are no guarantees on when an object's hash is cached,
and the (non-)existence of a cached hash does not imply that the string has
any other properties.
Unicode Character Properties
""""""""""""""""""""""""""""

View file

@ -79,30 +79,6 @@ as much as it can.
.. versionadded:: 3.13
.. c:function:: PyObject* PyWeakref_GetObject(PyObject *ref)
Return a :term:`borrowed reference` to the referenced object from a weak
reference, *ref*. If the referent is no longer live, returns ``Py_None``.
.. note::
This function returns a :term:`borrowed reference` to the referenced object.
This means that you should always call :c:func:`Py_INCREF` on the object
except when it cannot be destroyed before the last usage of the borrowed
reference.
.. deprecated-removed:: 3.13 3.15
Use :c:func:`PyWeakref_GetRef` instead.
.. c:function:: PyObject* PyWeakref_GET_OBJECT(PyObject *ref)
Similar to :c:func:`PyWeakref_GetObject`, but does no error checking.
.. deprecated-removed:: 3.13 3.15
Use :c:func:`PyWeakref_GetRef` instead.
.. c:function:: int PyWeakref_IsDead(PyObject *ref)
Test if the weak reference *ref* is dead. Returns 1 if the reference is

File diff suppressed because it is too large Load diff

View file

@ -1117,9 +1117,6 @@ PyImport_ImportModuleLevelObject:PyObject*:locals:0:???
PyImport_ImportModuleLevelObject:PyObject*:fromlist:0:???
PyImport_ImportModuleLevelObject:int:level::
PyImport_ImportModuleNoBlock:PyObject*::+1:
PyImport_ImportModuleNoBlock:const char*:name::
PyImport_ReloadModule:PyObject*::+1:
PyImport_ReloadModule:PyObject*:m:0:
@ -1475,6 +1472,9 @@ PyModule_Create2:PyObject*::+1:
PyModule_Create2:PyModuleDef*:def::
PyModule_Create2:int:module_api_version::
PyModule_Exec:int:::
PyModule_ExecDef:PyObject*:module:0:
PyModule_ExecDef:int:::
PyModule_ExecDef:PyObject*:module:0:
PyModule_ExecDef:PyModuleDef*:def::
@ -1488,6 +1488,10 @@ PyModule_FromDefAndSpec2:PyModuleDef*:def::
PyModule_FromDefAndSpec2:PyObject*:spec:0:
PyModule_FromDefAndSpec2:int:module_api_version::
PyModule_FromSlotsAndSpec:PyObject*::+1:
PyModule_FromSlotsAndSpec:const PyModuleDef_Slot *:slots::
PyModule_FromSlotsAndSpec:PyObject*:spec:0:
PyModule_GetDef:PyModuleDef*::0:
PyModule_GetDef:PyObject*:module:0:
@ -1509,6 +1513,14 @@ PyModule_GetNameObject:PyObject*:module:0:
PyModule_GetState:void*:::
PyModule_GetState:PyObject*:module:0:
PyModule_GetStateSize:int:::
PyModule_GetStateSize:PyObject*:module:0:
PyModule_GetToken:Py_ssize_t**:result::
PyModule_GetToken:int:::
PyModule_GetToken:PyObject*:module:0:
PyModule_GetToken:void**:result::
PyModule_New:PyObject*::+1:
PyModule_New:char*:name::
@ -2415,6 +2427,10 @@ PyType_GetFlags:PyTypeObject*:type:0:
PyType_GetName:PyObject*::+1:
PyType_GetName:PyTypeObject*:type:0:
PyType_GetModuleByToken:PyObject*::+1:
PyType_GetModuleByToken:PyTypeObject*:type:0:
PyType_GetModuleByToken:PyModuleDef*:def::
PyType_GetModuleByDef:PyObject*::0:
PyType_GetModuleByDef:PyTypeObject*:type:0:
PyType_GetModuleByDef:PyModuleDef*:def::
@ -2953,12 +2969,6 @@ PyWeakref_CheckProxy:PyObject*:ob:0:
PyWeakref_CheckRef:int:::
PyWeakref_CheckRef:PyObject*:ob:0:
PyWeakref_GET_OBJECT:PyObject*::0:
PyWeakref_GET_OBJECT:PyObject*:ref:0:
PyWeakref_GetObject:PyObject*::0:
PyWeakref_GetObject:PyObject*:ref:0:
PyWeakref_GetRef:int:::
PyWeakref_GetRef:PyObject*:ref:0:
PyWeakref_GetRef:PyObject**:pobj:+1:
@ -3038,18 +3048,8 @@ Py_GetCompiler:const char*:::
Py_GetCopyright:const char*:::
Py_GetExecPrefix:wchar_t*:::
Py_GetPath:wchar_t*:::
Py_GetPlatform:const char*:::
Py_GetPrefix:wchar_t*:::
Py_GetProgramFullPath:wchar_t*:::
Py_GetProgramName:wchar_t*:::
Py_GetVersion:const char*:::
Py_INCREF:void:::

View file

@ -8,6 +8,15 @@ macro,METH_O,3.2,,
macro,METH_STATIC,3.2,,
macro,METH_VARARGS,3.2,,
macro,PY_VECTORCALL_ARGUMENTS_OFFSET,3.12,,
type,PyABIInfo,3.15,,full-abi
func,PyABIInfo_Check,3.15,,
macro,PyABIInfo_DEFAULT_ABI_VERSION,3.15,,
macro,PyABIInfo_DEFAULT_FLAGS,3.15,,
macro,PyABIInfo_FREETHREADED,3.15,,
macro,PyABIInfo_FREETHREADING_AGNOSTIC,3.15,,
macro,PyABIInfo_GIL,3.15,,
macro,PyABIInfo_STABLE,3.15,,
macro,PyABIInfo_VAR,3.15,,
func,PyAIter_Check,3.10,,
func,PyArg_Parse,3.2,,
func,PyArg_ParseTuple,3.2,,
@ -151,6 +160,7 @@ func,PyDict_Merge,3.2,,
func,PyDict_MergeFromSeq2,3.2,,
func,PyDict_New,3.2,,
func,PyDict_Next,3.2,,
func,PyDict_SetDefaultRef,3.15,,
func,PyDict_SetItem,3.2,,
func,PyDict_SetItemString,3.2,,
func,PyDict_Size,3.2,,
@ -351,7 +361,6 @@ func,PyImport_ImportFrozenModuleObject,3.7,,
func,PyImport_ImportModule,3.2,,
func,PyImport_ImportModuleLevel,3.2,,
func,PyImport_ImportModuleLevelObject,3.7,,
func,PyImport_ImportModuleNoBlock,3.2,,
func,PyImport_ReloadModule,3.2,,
func,PyIndex_Check,3.8,,
type,PyInterpreterState,3.2,,opaque
@ -417,6 +426,7 @@ func,PyLong_FromUnsignedNativeBytes,3.14,,
func,PyLong_FromVoidPtr,3.2,,
func,PyLong_GetInfo,3.2,,
data,PyLong_Type,3.2,,
macro,PyMODEXPORT_FUNC,3.15,,
data,PyMap_Type,3.2,,
func,PyMapping_Check,3.2,,
func,PyMapping_GetItemString,3.2,,
@ -464,8 +474,10 @@ func,PyModule_AddObjectRef,3.10,,
func,PyModule_AddStringConstant,3.2,,
func,PyModule_AddType,3.10,,
func,PyModule_Create2,3.2,,
func,PyModule_Exec,3.15,,
func,PyModule_ExecDef,3.7,,
func,PyModule_FromDefAndSpec2,3.7,,
func,PyModule_FromSlotsAndSpec,3.15,,
func,PyModule_GetDef,3.2,,
func,PyModule_GetDict,3.2,,
func,PyModule_GetFilename,3.2,,
@ -473,6 +485,8 @@ func,PyModule_GetFilenameObject,3.2,,
func,PyModule_GetName,3.2,,
func,PyModule_GetNameObject,3.7,,
func,PyModule_GetState,3.2,,
func,PyModule_GetStateSize,3.15,,
func,PyModule_GetToken,3.15,,
func,PyModule_New,3.2,,
func,PyModule_NewObject,3.7,,
func,PyModule_SetDocString,3.7,,
@ -658,9 +672,12 @@ func,PySys_Audit,3.13,,
func,PySys_AuditTuple,3.13,,
func,PySys_FormatStderr,3.2,,
func,PySys_FormatStdout,3.2,,
func,PySys_GetAttr,3.15,,
func,PySys_GetAttrString,3.15,,
func,PySys_GetObject,3.2,,
func,PySys_GetOptionalAttr,3.15,,
func,PySys_GetOptionalAttrString,3.15,,
func,PySys_GetXOptions,3.7,,
func,PySys_ResetWarnOptions,3.2,,
func,PySys_SetArgv,3.2,,
func,PySys_SetArgvEx,3.2,,
func,PySys_SetObject,3.2,,
@ -728,6 +745,7 @@ func,PyType_GetFlags,3.2,,
func,PyType_GetFullyQualifiedName,3.13,,
func,PyType_GetModule,3.10,,
func,PyType_GetModuleByDef,3.13,,
func,PyType_GetModuleByToken,3.15,,
func,PyType_GetModuleName,3.13,,
func,PyType_GetModuleState,3.10,,
func,PyType_GetName,3.11,,
@ -769,11 +787,7 @@ func,PyUnicode_Append,3.2,,
func,PyUnicode_AppendAndDel,3.2,,
func,PyUnicode_AsASCIIString,3.2,,
func,PyUnicode_AsCharmapString,3.2,,
func,PyUnicode_AsDecodedObject,3.2,,
func,PyUnicode_AsDecodedUnicode,3.2,,
func,PyUnicode_AsEncodedObject,3.2,,
func,PyUnicode_AsEncodedString,3.2,,
func,PyUnicode_AsEncodedUnicode,3.2,,
func,PyUnicode_AsLatin1String,3.2,,
func,PyUnicode_AsMBCSString,3.7,on Windows,
func,PyUnicode_AsRawUnicodeEscapeString,3.2,,
@ -858,7 +872,6 @@ member,PyVarObject.ob_size,3.2,,
func,PyVectorcall_Call,3.12,,
func,PyVectorcall_NARGS,3.12,,
type,PyWeakReference,3.2,,opaque
func,PyWeakref_GetObject,3.2,,
func,PyWeakref_GetRef,3.13,,
func,PyWeakref_NewProxy,3.2,,
func,PyWeakref_NewRef,3.2,,
@ -899,16 +912,11 @@ func,Py_GetCompiler,3.2,,
func,Py_GetConstant,3.13,,
func,Py_GetConstantBorrowed,3.13,,
func,Py_GetCopyright,3.2,,
func,Py_GetExecPrefix,3.2,,
func,Py_GetPath,3.2,,
func,Py_GetPlatform,3.2,,
func,Py_GetPrefix,3.2,,
func,Py_GetProgramFullPath,3.2,,
func,Py_GetProgramName,3.2,,
func,Py_GetPythonHome,3.2,,
func,Py_GetRecursionLimit,3.2,,
func,Py_GetVersion,3.2,,
data,Py_HasFileSystemDefaultEncoding,3.2,,
func,Py_IS_TYPE,3.15,,
func,Py_IncRef,3.2,,
func,Py_Initialize,3.2,,
func,Py_InitializeEx,3.2,,
@ -930,6 +938,8 @@ func,Py_REFCNT,3.14,,
macro,Py_RELATIVE_OFFSET,3.12,,
func,Py_ReprEnter,3.2,,
func,Py_ReprLeave,3.2,,
func,Py_SET_SIZE,3.15,,
func,Py_SIZE,3.15,,
func,Py_SetProgramName,3.2,,
func,Py_SetPythonHome,3.2,,
func,Py_SetRecursionLimit,3.2,,
@ -973,10 +983,19 @@ macro,Py_bf_getbuffer,3.11,,
macro,Py_bf_releasebuffer,3.11,,
type,Py_buffer,3.11,,full-abi
type,Py_intptr_t,3.2,,
macro,Py_mod_abi,3.15,,
macro,Py_mod_create,3.5,,
macro,Py_mod_doc,3.15,,
macro,Py_mod_exec,3.5,,
macro,Py_mod_gil,3.13,,
macro,Py_mod_methods,3.15,,
macro,Py_mod_multiple_interpreters,3.12,,
macro,Py_mod_name,3.15,,
macro,Py_mod_state_clear,3.15,,
macro,Py_mod_state_free,3.15,,
macro,Py_mod_state_size,3.15,,
macro,Py_mod_state_traverse,3.15,,
macro,Py_mod_token,3.15,,
macro,Py_mp_ass_subscript,3.2,,
macro,Py_mp_length,3.2,,
macro,Py_mp_subscript,3.2,,

View file

@ -1,9 +1,9 @@
Pending removal in Python 3.15
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
* The :c:func:`PyImport_ImportModuleNoBlock`:
* The :c:func:`!PyImport_ImportModuleNoBlock`:
Use :c:func:`PyImport_ImportModule` instead.
* :c:func:`PyWeakref_GetObject` and :c:func:`PyWeakref_GET_OBJECT`:
* :c:func:`!PyWeakref_GetObject` and :c:func:`!PyWeakref_GET_OBJECT`:
Use :c:func:`PyWeakref_GetRef` instead. The `pythoncapi-compat project
<https://github.com/python/pythoncapi-compat/>`__ can be used to get
:c:func:`PyWeakref_GetRef` on Python 3.12 and older.
@ -21,27 +21,27 @@ Pending removal in Python 3.15
may return a type other than :class:`bytes`, such as :class:`str`.
* Python initialization functions, deprecated in Python 3.13:
* :c:func:`Py_GetPath`:
* :c:func:`!Py_GetPath`:
Use :c:func:`PyConfig_Get("module_search_paths") <PyConfig_Get>`
(:data:`sys.path`) instead.
* :c:func:`Py_GetPrefix`:
* :c:func:`!Py_GetPrefix`:
Use :c:func:`PyConfig_Get("base_prefix") <PyConfig_Get>`
(:data:`sys.base_prefix`) instead. Use :c:func:`PyConfig_Get("prefix")
<PyConfig_Get>` (:data:`sys.prefix`) if :ref:`virtual environments
<venv-def>` need to be handled.
* :c:func:`Py_GetExecPrefix`:
* :c:func:`!Py_GetExecPrefix`:
Use :c:func:`PyConfig_Get("base_exec_prefix") <PyConfig_Get>`
(:data:`sys.base_exec_prefix`) instead. Use
:c:func:`PyConfig_Get("exec_prefix") <PyConfig_Get>`
(:data:`sys.exec_prefix`) if :ref:`virtual environments <venv-def>` need to
be handled.
* :c:func:`Py_GetProgramFullPath`:
* :c:func:`!Py_GetProgramFullPath`:
Use :c:func:`PyConfig_Get("executable") <PyConfig_Get>`
(:data:`sys.executable`) instead.
* :c:func:`Py_GetProgramName`:
* :c:func:`!Py_GetProgramName`:
Use :c:func:`PyConfig_Get("executable") <PyConfig_Get>`
(:data:`sys.executable`) instead.
* :c:func:`Py_GetPythonHome`:
* :c:func:`!Py_GetPythonHome`:
Use :c:func:`PyConfig_Get("home") <PyConfig_Get>` or the
:envvar:`PYTHONHOME` environment variable instead.
@ -59,7 +59,7 @@ Pending removal in Python 3.15
Set :c:member:`PyConfig.program_name` instead.
* :c:func:`!Py_SetPythonHome()`:
Set :c:member:`PyConfig.home` instead.
* :c:func:`PySys_ResetWarnOptions`:
* :c:func:`!PySys_ResetWarnOptions`:
Clear :data:`sys.warnoptions` and :data:`!warnings.filters` instead.
The :c:func:`Py_InitializeFromConfig` API should be used with

View file

@ -0,0 +1,9 @@
Pending removal in Python 3.20
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
* The ``cval`` field in :c:type:`PyComplexObject` (:gh:`128813`).
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.
* Macros :c:macro:`!Py_MATH_PIl` and :c:macro:`!Py_MATH_El`.

View file

@ -9,6 +9,8 @@ Deprecations
.. include:: pending-removal-in-3.19.rst
.. include:: pending-removal-in-3.20.rst
.. include:: pending-removal-in-future.rst
C API deprecations
@ -18,4 +20,6 @@ C API deprecations
.. include:: c-api-pending-removal-in-3.18.rst
.. include:: c-api-pending-removal-in-3.20.rst
.. include:: c-api-pending-removal-in-future.rst

View file

@ -20,7 +20,7 @@ Pending removal in Python 3.15
* :mod:`http.server`:
* The obsolete and rarely used :class:`~http.server.CGIHTTPRequestHandler`
* The obsolete and rarely used :class:`!CGIHTTPRequestHandler`
has been deprecated since Python 3.13.
No direct replacement exists.
*Anything* is better than CGI to interface
@ -45,13 +45,13 @@ Pending removal in Python 3.15
* :mod:`pathlib`:
* :meth:`.PurePath.is_reserved`
* :meth:`!.PurePath.is_reserved`
has been deprecated since Python 3.13.
Use :func:`os.path.isreserved` to detect reserved paths on Windows.
* :mod:`platform`:
* :func:`~platform.java_ver` has been deprecated since Python 3.13.
* :func:`!platform.java_ver` has been deprecated since Python 3.13.
This function is only useful for Jython support, has a confusing API,
and is largely untested.
@ -92,20 +92,21 @@ Pending removal in Python 3.15
Use ``class TD(TypedDict): pass`` or ``TD = TypedDict("TD", {})``
to create a TypedDict with zero field.
* The :func:`typing.no_type_check_decorator` decorator function
* The :func:`!typing.no_type_check_decorator` decorator function
has been deprecated since Python 3.13.
After eight years in the :mod:`typing` module,
it has yet to be supported by any major type checker.
* :mod:`!sre_compile`, :mod:`!sre_constants` and :mod:`!sre_parse` modules.
* :mod:`wave`:
* The :meth:`~wave.Wave_read.getmark`, :meth:`!setmark`,
and :meth:`~wave.Wave_read.getmarkers` methods of
* The ``getmark()``, ``setmark()`` and ``getmarkers()`` methods of
the :class:`~wave.Wave_read` and :class:`~wave.Wave_write` classes
have been deprecated since Python 3.13.
* :mod:`zipimport`:
* :meth:`~zipimport.zipimporter.load_module` has been deprecated since
* :meth:`!zipimport.zipimporter.load_module` has been deprecated since
Python 3.10. Use :meth:`~zipimport.zipimporter.exec_module` instead.
(Contributed by Jiahao Li in :gh:`125746`.)
(:gh:`125746`.)

View file

@ -63,9 +63,9 @@ Pending removal in Python 3.16
* :mod:`logging`:
Support for custom logging handlers with the *strm* argument is deprecated
and scheduled for removal in Python 3.16. Define handlers with the *stream*
argument instead. (Contributed by Mariusz Felisiak in :gh:`115032`.)
* Support for custom logging handlers with the *strm* argument is deprecated
and scheduled for removal in Python 3.16. Define handlers with the *stream*
argument instead. (Contributed by Mariusz Felisiak in :gh:`115032`.)
* :mod:`mimetypes`:

View file

@ -23,6 +23,12 @@ Pending removal in Python 3.17
(Contributed by Shantanu Jain in :gh:`91896`.)
* :mod:`encodings`:
- Passing non-ascii *encoding* names to :func:`encodings.normalize_encoding`
is deprecated and scheduled for removal in Python 3.17.
(Contributed by Stan Ulbrych in :gh:`136702`)
* :mod:`typing`:
- Before Python 3.14, old-style unions were implemented using the private class

View file

@ -6,3 +6,19 @@ Pending removal in Python 3.19
* Implicitly switching to the MSVC-compatible struct layout by setting
:attr:`~ctypes.Structure._pack_` but not :attr:`~ctypes.Structure._layout_`
on non-Windows platforms.
* :mod:`hashlib`:
- In hash function constructors such as :func:`~hashlib.new` or the
direct hash-named constructors such as :func:`~hashlib.md5` and
:func:`~hashlib.sha256`, their optional initial data parameter could
also be passed a keyword argument named ``data=`` or ``string=`` in
various :mod:`!hashlib` implementations.
Support for the ``string`` keyword argument name is now deprecated
and slated for removal in Python 3.19.
Before Python 3.13, the ``string`` keyword parameter was not correctly
supported depending on the backend implementation of hash functions.
Prefer passing the initial data as a positional argument for maximum
backwards compatibility.

View file

@ -0,0 +1,26 @@
Pending removal in Python 3.20
------------------------------
* The ``__version__`` attribute has been deprecated in these standard library
modules and will be removed in Python 3.20.
Use :py:data:`sys.version_info` instead.
- :mod:`argparse`
- :mod:`csv`
- :mod:`!ctypes.macholib`
- :mod:`decimal` (use :data:`decimal.SPEC_VERSION` instead)
- :mod:`imaplib`
- :mod:`ipaddress`
- :mod:`json`
- :mod:`logging` (``__date__`` also deprecated)
- :mod:`optparse`
- :mod:`pickle`
- :mod:`platform`
- :mod:`re`
- :mod:`socketserver`
- :mod:`tabnanny`
- :mod:`tkinter.font`
- :mod:`tkinter.ttk`
- :mod:`zlib`
(Contributed by Hugo van Kemenade and Stan Ulbrych in :gh:`76007`.)

View file

@ -76,7 +76,7 @@ although there is currently no date scheduled for their removal.
* :mod:`mailbox`: Use of StringIO input and text mode is deprecated, use
BytesIO and binary mode instead.
* :mod:`os`: Calling :func:`os.register_at_fork` in multi-threaded process.
* :mod:`os`: Calling :func:`os.register_at_fork` in a multi-threaded process.
* :class:`!pydoc.ErrorDuringImport`: A tuple value for *exc_info* parameter is
deprecated, use an exception instance.
@ -88,8 +88,6 @@ although there is currently no date scheduled for their removal.
underscore.
(Contributed by Serhiy Storchaka in :gh:`91760`.)
* :mod:`!sre_compile`, :mod:`!sre_constants` and :mod:`!sre_parse` modules.
* :mod:`shutil`: :func:`~shutil.rmtree`'s *onerror* parameter is deprecated in
Python 3.12; use the *onexc* parameter instead.

View file

@ -560,6 +560,8 @@ For an object to be weakly referenceable, the extension type must set the
field. The legacy :c:member:`~PyTypeObject.tp_weaklistoffset` field should
be left as zero.
If this flag is set, :c:macro:`Py_TPFLAGS_HAVE_GC` should also be set.
Concretely, here is how the statically declared type object would look::
static PyTypeObject TrivialType = {

View file

@ -420,10 +420,12 @@ strings representing the files in the current directory. Functions which
operate on this output would generally not break if you added another file or
two to the directory.
Tuples are immutable, meaning that once a tuple has been created, you can't
replace any of its elements with a new value. Lists are mutable, meaning that
you can always change a list's elements. Only immutable elements can be used as
dictionary keys, and hence only tuples and not lists can be used as keys.
Tuples are :term:`immutable`, meaning that once a tuple has been created, you can't
replace any of its elements with a new value. Lists are :term:`mutable`, meaning that
you can always change a list's elements. Only :term:`hashable` objects can
be used as dictionary keys. Most immutable types are hashable, which is why
tuples, but not lists, can be used as keys. Note, however, that a tuple is
only hashable if all of its elements are hashable.
How are lists implemented in CPython?

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

View file

@ -1,7 +1,7 @@
.. _a-conceptual-overview-of-asyncio:
****************************************
A Conceptual Overview of :mod:`!asyncio`
A conceptual overview of :mod:`!asyncio`
****************************************
This :ref:`HOWTO <how-tos>` article seeks to help you build a sturdy mental
@ -37,15 +37,15 @@ In part 1, we'll cover the main, high-level building blocks of :mod:`!asyncio`:
the event loop, coroutine functions, coroutine objects, tasks, and ``await``.
==========
Event Loop
Event loop
==========
Everything in :mod:`!asyncio` happens relative to the event loop.
It's the star of the show.
It's the star of the show, but prefers to work behind the scenes, managing
and coordinating resources.
It's like an orchestra conductor.
It's behind the scenes managing resources.
Some power is explicitly granted to it, but a lot of its ability to get things
done comes from the respect and cooperation of its worker bees.
done comes from the respect and cooperation of its band members.
In more technical terms, the event loop contains a collection of jobs to be run.
Some jobs are added directly by you, and some indirectly by :mod:`!asyncio`.
@ -59,7 +59,7 @@ This process repeats indefinitely, with the event loop cycling endlessly
onwards.
If there are no more jobs pending execution, the event loop is smart enough to
rest and avoid needlessly wasting CPU cycles, and will come back when there's
more work to be done.
more work to be done, such as when I/O operations complete or timers expire.
Effective execution relies on jobs sharing well and cooperating; a greedy job
could hog control and leave the other jobs to starve, rendering the overall
@ -170,10 +170,10 @@ Roughly speaking, :ref:`tasks <asyncio-task-obj>` are coroutines (not coroutine
functions) tied to an event loop.
A task also maintains a list of callback functions whose importance will become
clear in a moment when we discuss :keyword:`await`.
The recommended way to create tasks is via :func:`asyncio.create_task`.
Creating a task automatically schedules it for execution (by adding a
callback to run it in the event loop's to-do list, that is, collection of jobs).
The recommended way to create tasks is via :func:`asyncio.create_task`.
:mod:`!asyncio` automatically associates tasks with the event loop for you.
This automatic association was purposely designed into :mod:`!asyncio` for
@ -253,6 +253,10 @@ different ways::
In a crucial way, the behavior of ``await`` depends on the type of object
being awaited.
^^^^^^^^^^^^^^
Awaiting tasks
^^^^^^^^^^^^^^
Awaiting a task will cede control from the current task or coroutine to
the event loop.
In the process of relinquishing control, a few important things happen.
@ -284,6 +288,10 @@ This is a basic, yet reliable mental model.
In practice, the control handoffs are slightly more complex, but not by much.
In part 2, we'll walk through the details that make this possible.
^^^^^^^^^^^^^^^^^^^
Awaiting coroutines
^^^^^^^^^^^^^^^^^^^
**Unlike tasks, awaiting a coroutine does not hand control back to the event
loop!**
Wrapping a coroutine in a task first, then awaiting that would cede
@ -350,8 +358,10 @@ The design intentionally trades off some conceptual clarity around usage of
``await`` for improved performance.
Each time a task is awaited, control needs to be passed all the way up the
call stack to the event loop.
That might sound minor, but in a large program with many ``await`` statements and a deep
call stack, that overhead can add up to a meaningful performance drag.
Then, the event loop needs to manage its internal state and work through
its processing logic to resume the next job.
That might sound minor, but in a large program with many ``await``\ s, that
overhead can add up to a non-negligible performance drag.
------------------------------------------------
A conceptual overview part 2: the nuts and bolts
@ -367,7 +377,8 @@ and how to make your own asynchronous operators.
The inner workings of coroutines
================================
:mod:`!asyncio` leverages four components to pass around control.
:mod:`!asyncio` leverages four components of Python to pass
around control.
:meth:`coroutine.send(arg) <generator.send>` is the method used to start or
resume a coroutine.
@ -451,9 +462,9 @@ That might sound odd to you. You might be thinking:
That causes the error: ``SyntaxError: yield from not allowed in a coroutine.``
This was intentionally designed for the sake of simplicity -- mandating only
one way of using coroutines.
Despite that, ``yield from`` and ``await`` effectively do the same thing.
Initially ``yield`` was barred as well, but was re-accepted to allow for
async generators.
Despite that, ``yield from`` and ``await`` effectively do the same thing.
=======
Futures

View file

@ -161,6 +161,8 @@ your terminal won't be left in a funny state on exception and you'll be
able to read the exception's message and traceback.
.. _windows-and-pads:
Windows and Pads
================

View file

@ -45,9 +45,12 @@ single-phase initialization.
Multi-Phase Initialization
..........................
Extensions that use multi-phase initialization (i.e.,
:c:func:`PyModuleDef_Init`) should add a :c:data:`Py_mod_gil` slot in the
module definition. If your extension supports older versions of CPython,
Extensions that use :ref:`multi-phase initialization <multi-phase-initialization>`
(functions like :c:func:`PyModuleDef_Init`,
:c:func:`PyModExport_* <PyModExport_modulename>` export hook,
:c:func:`PyModule_FromSlotsAndSpec`) should add a
:c:data:`Py_mod_gil` slot in the module definition.
If your extension supports older versions of CPython,
you should guard the slot with a :c:data:`PY_VERSION_HEX` check.
::
@ -60,18 +63,12 @@ you should guard the slot with a :c:data:`PY_VERSION_HEX` check.
{0, NULL}
};
static struct PyModuleDef moduledef = {
PyModuleDef_HEAD_INIT,
.m_slots = module_slots,
...
};
Single-Phase Initialization
...........................
Extensions that use single-phase initialization (i.e.,
:c:func:`PyModule_Create`) should call :c:func:`PyUnstable_Module_SetGIL` to
Extensions that use legacy :ref:`single-phase initialization <single-phase-initialization>`
(that is, :c:func:`PyModule_Create`) should call :c:func:`PyUnstable_Module_SetGIL` to
indicate that they support running with the GIL disabled. The function is
only defined in the free-threaded build, so you should guard the call with
``#ifdef Py_GIL_DISABLED`` to avoid compilation errors in the regular build.
@ -173,9 +170,9 @@ that return :term:`strong references <strong reference>`.
+-----------------------------------+-----------------------------------+
| :c:func:`PyDict_Next` | none (see :ref:`PyDict_Next`) |
+-----------------------------------+-----------------------------------+
| :c:func:`PyWeakref_GetObject` | :c:func:`PyWeakref_GetRef` |
| :c:func:`!PyWeakref_GetObject` | :c:func:`PyWeakref_GetRef` |
+-----------------------------------+-----------------------------------+
| :c:func:`PyWeakref_GET_OBJECT` | :c:func:`PyWeakref_GetRef` |
| :c:func:`!PyWeakref_GET_OBJECT` | :c:func:`PyWeakref_GetRef` |
+-----------------------------------+-----------------------------------+
| :c:func:`PyImport_AddModule` | :c:func:`PyImport_AddModuleRef` |
+-----------------------------------+-----------------------------------+

View file

@ -372,8 +372,8 @@ have the form::
for expr2 in sequence2
if condition2
for expr3 in sequence3
...
if condition3
...
for exprN in sequenceN
if conditionN )

View file

@ -2,34 +2,35 @@
.. _perf_profiling:
==============================================
Python support for the Linux ``perf`` profiler
==============================================
========================================================
Python support for the ``perf map`` compatible profilers
========================================================
:author: Pablo Galindo
`The Linux perf profiler <https://perf.wiki.kernel.org>`_
is a very powerful tool that allows you to profile and obtain
information about the performance of your application.
``perf`` also has a very vibrant ecosystem of tools
that aid with the analysis of the data that it produces.
`The Linux perf profiler <https://perf.wiki.kernel.org>`_ and
`samply <https://github.com/mstange/samply>`_ are powerful tools that allow you to
profile and obtain information about the performance of your application.
Both tools have vibrant ecosystems that aid with the analysis of the data they produce.
The main problem with using the ``perf`` profiler with Python applications is that
``perf`` only gets information about native symbols, that is, the names of
The main problem with using these profilers with Python applications is that
they only get information about native symbols, that is, the names of
functions and procedures written in C. This means that the names and file names
of Python functions in your code will not appear in the output of ``perf``.
of Python functions in your code will not appear in the profiler output.
Since Python 3.12, the interpreter can run in a special mode that allows Python
functions to appear in the output of the ``perf`` profiler. When this mode is
functions to appear in the output of compatible profilers. When this mode is
enabled, the interpreter will interpose a small piece of code compiled on the
fly before the execution of every Python function and it will teach ``perf`` the
fly before the execution of every Python function and it will teach the profiler the
relationship between this piece of code and the associated Python function using
:doc:`perf map files <../c-api/perfmaps>`.
.. note::
Support for the ``perf`` profiler is currently only available for Linux on
select architectures. Check the output of the ``configure`` build step or
Support for profiling is available on Linux and macOS on select architectures.
Perf is available on Linux, while samply can be used on both Linux and macOS.
samply support on macOS is available starting from Python 3.15.
Check the output of the ``configure`` build step or
check the output of ``python -m sysconfig | grep HAVE_PERF_TRAMPOLINE``
to see if your system is supported.
@ -92,7 +93,7 @@ Then we can use ``perf report`` to analyze the data:
| | | |
| | | |--51.67%--_PyEval_EvalFrameDefault
| | | | |
| | | | |--11.52%--_PyLong_Add
| | | | |--11.52%--_PyCompactLong_Add
| | | | | |
| | | | | |--2.97%--_PyObject_Malloc
...
@ -142,12 +143,37 @@ Instead, if we run the same experiment with ``perf`` support enabled we get:
| | | |
| | | |--51.81%--_PyEval_EvalFrameDefault
| | | | |
| | | | |--13.77%--_PyLong_Add
| | | | |--13.77%--_PyCompactLong_Add
| | | | | |
| | | | | |--3.26%--_PyObject_Malloc
Using the samply profiler
-------------------------
samply is a modern profiler that can be used as an alternative to perf.
It uses the same perf map files that Python generates, making it compatible
with Python's profiling support. samply is particularly useful on macOS
where perf is not available.
To use samply with Python, first install it following the instructions at
https://github.com/mstange/samply, then run::
$ samply record PYTHONPERFSUPPORT=1 python my_script.py
This will open a web interface where you can analyze the profiling data
interactively. The advantage of samply is that it provides a modern
web-based interface for analyzing profiling data and works on both Linux
and macOS.
On macOS, samply support requires Python 3.15 or later. Also on macOS, samply
can't profile signed Python executables due to restrictions by macOS. You can
profile with Python binaries that you've compiled yourself, or which are
unsigned or locally-signed (such as anything installed by Homebrew). In
order to attach to running processes on macOS, run ``samply setup`` once (and
every time samply is updated) to self-sign the samply binary.
How to enable ``perf`` profiling support
----------------------------------------

View file

@ -120,13 +120,16 @@ This module defines the following constants and functions:
Its value may be used to uniquely identify this particular thread system-wide
(until the thread terminates, after which the value may be recycled by the OS).
.. availability:: Windows, FreeBSD, Linux, macOS, OpenBSD, NetBSD, AIX, DragonFlyBSD, GNU/kFreeBSD.
.. availability:: Windows, FreeBSD, Linux, macOS, OpenBSD, NetBSD, AIX, DragonFlyBSD, GNU/kFreeBSD, Solaris.
.. versionadded:: 3.8
.. versionchanged:: 3.13
Added support for GNU/kFreeBSD.
.. versionchanged:: 3.15
Added support for Solaris.
.. function:: stack_size([size])

View file

@ -74,7 +74,7 @@ ArgumentParser objects
prefix_chars='-', fromfile_prefix_chars=None, \
argument_default=None, conflict_handler='error', \
add_help=True, allow_abbrev=True, exit_on_error=True, \
*, suggest_on_error=False, color=True)
*, suggest_on_error=True, color=True)
Create a new :class:`ArgumentParser` object. All parameters should be passed
as keyword arguments. Each parameter has its own more detailed description
@ -117,7 +117,7 @@ ArgumentParser objects
error info when an error occurs. (default: ``True``)
* suggest_on_error_ - Enables suggestions for mistyped argument choices
and subparser names (default: ``False``)
and subparser names (default: ``True``)
* color_ - Allow color output (default: ``True``)
@ -134,6 +134,9 @@ ArgumentParser objects
.. versionchanged:: 3.14
*suggest_on_error* and *color* parameters were added.
.. versionchanged:: 3.15
*suggest_on_error* default changed to ``True``.
The following sections describe how each of these are used.
@ -596,13 +599,11 @@ suggest_on_error
^^^^^^^^^^^^^^^^
By default, when a user passes an invalid argument choice or subparser name,
:class:`ArgumentParser` will exit with error info and list the permissible
argument choices (if specified) or subparser names as part of the error message.
If the user would like to enable suggestions for mistyped argument choices and
subparser names, the feature can be enabled by setting ``suggest_on_error`` to
``True``. Note that this only applies for arguments when the choices specified
are strings::
:class:`ArgumentParser` will exit with error info and provide suggestions for
mistyped arguments. The error message will list the permissible argument
choices (if specified) or subparser names, along with a "maybe you meant"
suggestion if a close match is found. Note that this only applies for arguments
when the choices specified are strings::
>>> parser = argparse.ArgumentParser(description='Process some integers.',
suggest_on_error=True)
@ -612,16 +613,14 @@ are strings::
>>> parser.parse_args(['--action', 'sumn', 1, 2, 3])
tester.py: error: argument --action: invalid choice: 'sumn', maybe you meant 'sum'? (choose from 'sum', 'max')
If you're writing code that needs to be compatible with older Python versions
and want to opportunistically use ``suggest_on_error`` when it's available, you
can set it as an attribute after initializing the parser instead of using the
keyword argument::
You can disable suggestions by setting ``suggest_on_error`` to ``False``::
>>> parser = argparse.ArgumentParser(description='Process some integers.')
>>> parser.suggest_on_error = True
>>> parser = argparse.ArgumentParser(description='Process some integers.',
suggest_on_error=False)
.. versionadded:: 3.14
.. versionchanged:: 3.15
Changed default value of ``suggest_on_error`` from ``False`` to ``True``.
color
^^^^^
@ -1323,8 +1322,12 @@ attribute is determined by the ``dest`` keyword argument of
For optional argument actions, the value of ``dest`` is normally inferred from
the option strings. :class:`ArgumentParser` generates the value of ``dest`` by
taking the first long option string and stripping away the initial ``--``
string. If no long option strings were supplied, ``dest`` will be derived from
taking the first double-dash long option string and stripping away the initial
``-`` characters.
If no double-dash long option strings were supplied, ``dest`` will be derived
from the first single-dash long option string by stripping the initial ``-``
character.
If no long option strings were supplied, ``dest`` will be derived from
the first short option string by stripping the initial ``-`` character. Any
internal ``-`` characters will be converted to ``_`` characters to make sure
the string is a valid attribute name. The examples below illustrate this
@ -1332,11 +1335,12 @@ behavior::
>>> parser = argparse.ArgumentParser()
>>> parser.add_argument('-f', '--foo-bar', '--foo')
>>> parser.add_argument('-q', '-quz')
>>> parser.add_argument('-x', '-y')
>>> parser.parse_args('-f 1 -x 2'.split())
Namespace(foo_bar='1', x='2')
>>> parser.parse_args('--foo 1 -y 2'.split())
Namespace(foo_bar='1', x='2')
>>> parser.parse_args('-f 1 -q 2 -x 3'.split())
Namespace(foo_bar='1', quz='2', x='3')
>>> parser.parse_args('--foo 1 -quz 2 -y 3'.split())
Namespace(foo_bar='1', quz='2', x='2')
``dest`` allows a custom attribute name to be provided::
@ -1345,6 +1349,9 @@ behavior::
>>> parser.parse_args('--foo XXX'.split())
Namespace(bar='XXX')
.. versionchanged:: next
Single-dash long option now takes precedence over short options.
.. _deprecated:
@ -1438,8 +1445,18 @@ this API may be passed as the ``action`` parameter to
>>> parser.parse_args(['--no-foo'])
Namespace(foo=False)
Single-dash long options are also supported.
For example, negative option ``-nofoo`` is automatically added for
positive option ``-foo``.
But no additional options are added for short options such as ``-f``.
.. versionadded:: 3.9
.. versionchanged:: next
Added support for single-dash options.
Added support for alternate prefix_chars_.
The parse_args() method
-----------------------

View file

@ -252,12 +252,11 @@ Root nodes
>>> print(ast.dump(ast.parse('(int, str) -> List[int]', mode='func_type'), indent=4))
FunctionType(
argtypes=[
Name(id='int', ctx=Load()),
Name(id='str', ctx=Load())],
Name(id='int'),
Name(id='str')],
returns=Subscript(
value=Name(id='List', ctx=Load()),
slice=Name(id='int', ctx=Load()),
ctx=Load()))
value=Name(id='List'),
slice=Name(id='int')))
.. versionadded:: 3.8
@ -312,14 +311,14 @@ Literals
values=[
Constant(value='sin('),
FormattedValue(
value=Name(id='a', ctx=Load()),
value=Name(id='a'),
conversion=-1),
Constant(value=') is '),
FormattedValue(
value=Call(
func=Name(id='sin', ctx=Load()),
func=Name(id='sin'),
args=[
Name(id='a', ctx=Load())]),
Name(id='a')]),
conversion=-1,
format_spec=JoinedStr(
values=[
@ -342,12 +341,12 @@ Literals
body=TemplateStr(
values=[
Interpolation(
value=Name(id='name', ctx=Load()),
value=Name(id='name'),
str='name',
conversion=-1),
Constant(value=' finished '),
Interpolation(
value=Name(id='place', ctx=Load()),
value=Name(id='place'),
str='place',
conversion=-1,
format_spec=JoinedStr(
@ -398,16 +397,14 @@ Literals
elts=[
Constant(value=1),
Constant(value=2),
Constant(value=3)],
ctx=Load()))
Constant(value=3)]))
>>> print(ast.dump(ast.parse('(1, 2, 3)', mode='eval'), indent=4))
Expression(
body=Tuple(
elts=[
Constant(value=1),
Constant(value=2),
Constant(value=3)],
ctx=Load()))
Constant(value=3)]))
.. class:: Set(elts)
@ -445,7 +442,7 @@ Literals
None],
values=[
Constant(value=1),
Name(id='d', ctx=Load())]))
Name(id='d')]))
Variables
@ -471,7 +468,7 @@ Variables
Module(
body=[
Expr(
value=Name(id='a', ctx=Load()))])
value=Name(id='a'))])
>>> print(ast.dump(ast.parse('a = 1'), indent=4))
Module(
@ -509,7 +506,7 @@ Variables
value=Name(id='b', ctx=Store()),
ctx=Store())],
ctx=Store())],
value=Name(id='it', ctx=Load()))])
value=Name(id='it'))])
.. _ast-expressions:
@ -532,7 +529,7 @@ Expressions
Expr(
value=UnaryOp(
op=USub(),
operand=Name(id='a', ctx=Load())))])
operand=Name(id='a')))])
.. class:: UnaryOp(op, operand)
@ -555,7 +552,7 @@ Expressions
Expression(
body=UnaryOp(
op=Not(),
operand=Name(id='x', ctx=Load())))
operand=Name(id='x')))
.. class:: BinOp(left, op, right)
@ -568,9 +565,9 @@ Expressions
>>> print(ast.dump(ast.parse('x + y', mode='eval'), indent=4))
Expression(
body=BinOp(
left=Name(id='x', ctx=Load()),
left=Name(id='x'),
op=Add(),
right=Name(id='y', ctx=Load())))
right=Name(id='y')))
.. class:: Add
@ -606,8 +603,8 @@ Expressions
body=BoolOp(
op=Or(),
values=[
Name(id='x', ctx=Load()),
Name(id='y', ctx=Load())]))
Name(id='x'),
Name(id='y')]))
.. class:: And
@ -632,7 +629,7 @@ Expressions
LtE(),
Lt()],
comparators=[
Name(id='a', ctx=Load()),
Name(id='a'),
Constant(value=10)]))
@ -666,18 +663,17 @@ Expressions
>>> print(ast.dump(ast.parse('func(a, b=c, *d, **e)', mode='eval'), indent=4))
Expression(
body=Call(
func=Name(id='func', ctx=Load()),
func=Name(id='func'),
args=[
Name(id='a', ctx=Load()),
Name(id='a'),
Starred(
value=Name(id='d', ctx=Load()),
ctx=Load())],
value=Name(id='d'))],
keywords=[
keyword(
arg='b',
value=Name(id='c', ctx=Load())),
value=Name(id='c')),
keyword(
value=Name(id='e', ctx=Load()))]))
value=Name(id='e'))]))
.. class:: keyword(arg, value)
@ -696,9 +692,9 @@ Expressions
>>> print(ast.dump(ast.parse('a if b else c', mode='eval'), indent=4))
Expression(
body=IfExp(
test=Name(id='b', ctx=Load()),
body=Name(id='a', ctx=Load()),
orelse=Name(id='c', ctx=Load())))
test=Name(id='b'),
body=Name(id='a'),
orelse=Name(id='c')))
.. class:: Attribute(value, attr, ctx)
@ -713,9 +709,8 @@ Expressions
>>> print(ast.dump(ast.parse('snake.colour', mode='eval'), indent=4))
Expression(
body=Attribute(
value=Name(id='snake', ctx=Load()),
attr='colour',
ctx=Load()))
value=Name(id='snake'),
attr='colour'))
.. class:: NamedExpr(target, value)
@ -751,15 +746,13 @@ Subscripting
>>> print(ast.dump(ast.parse('l[1:2, 3]', mode='eval'), indent=4))
Expression(
body=Subscript(
value=Name(id='l', ctx=Load()),
value=Name(id='l'),
slice=Tuple(
elts=[
Slice(
lower=Constant(value=1),
upper=Constant(value=2)),
Constant(value=3)],
ctx=Load()),
ctx=Load()))
Constant(value=3)])))
.. class:: Slice(lower, upper, step)
@ -773,11 +766,10 @@ Subscripting
>>> print(ast.dump(ast.parse('l[1:2]', mode='eval'), indent=4))
Expression(
body=Subscript(
value=Name(id='l', ctx=Load()),
value=Name(id='l'),
slice=Slice(
lower=Constant(value=1),
upper=Constant(value=2)),
ctx=Load()))
upper=Constant(value=2))))
Comprehensions
@ -802,11 +794,11 @@ Comprehensions
... ))
Expression(
body=ListComp(
elt=Name(id='x', ctx=Load()),
elt=Name(id='x'),
generators=[
comprehension(
target=Name(id='x', ctx=Store()),
iter=Name(id='numbers', ctx=Load()),
iter=Name(id='numbers'),
is_async=0)]))
>>> print(ast.dump(
... ast.parse('{x: x**2 for x in numbers}', mode='eval'),
@ -814,15 +806,15 @@ Comprehensions
... ))
Expression(
body=DictComp(
key=Name(id='x', ctx=Load()),
key=Name(id='x'),
value=BinOp(
left=Name(id='x', ctx=Load()),
left=Name(id='x'),
op=Pow(),
right=Constant(value=2)),
generators=[
comprehension(
target=Name(id='x', ctx=Store()),
iter=Name(id='numbers', ctx=Load()),
iter=Name(id='numbers'),
is_async=0)]))
>>> print(ast.dump(
... ast.parse('{x for x in numbers}', mode='eval'),
@ -830,11 +822,11 @@ Comprehensions
... ))
Expression(
body=SetComp(
elt=Name(id='x', ctx=Load()),
elt=Name(id='x'),
generators=[
comprehension(
target=Name(id='x', ctx=Store()),
iter=Name(id='numbers', ctx=Load()),
iter=Name(id='numbers'),
is_async=0)]))
@ -855,17 +847,17 @@ Comprehensions
Expression(
body=ListComp(
elt=Call(
func=Name(id='ord', ctx=Load()),
func=Name(id='ord'),
args=[
Name(id='c', ctx=Load())]),
Name(id='c')]),
generators=[
comprehension(
target=Name(id='line', ctx=Store()),
iter=Name(id='file', ctx=Load()),
iter=Name(id='file'),
is_async=0),
comprehension(
target=Name(id='c', ctx=Store()),
iter=Name(id='line', ctx=Load()),
iter=Name(id='line'),
is_async=0)]))
>>> print(ast.dump(ast.parse('(n**2 for n in it if n>5 if n<10)', mode='eval'),
@ -873,22 +865,22 @@ Comprehensions
Expression(
body=GeneratorExp(
elt=BinOp(
left=Name(id='n', ctx=Load()),
left=Name(id='n'),
op=Pow(),
right=Constant(value=2)),
generators=[
comprehension(
target=Name(id='n', ctx=Store()),
iter=Name(id='it', ctx=Load()),
iter=Name(id='it'),
ifs=[
Compare(
left=Name(id='n', ctx=Load()),
left=Name(id='n'),
ops=[
Gt()],
comparators=[
Constant(value=5)]),
Compare(
left=Name(id='n', ctx=Load()),
left=Name(id='n'),
ops=[
Lt()],
comparators=[
@ -899,11 +891,11 @@ Comprehensions
... indent=4)) # Async comprehension
Expression(
body=ListComp(
elt=Name(id='i', ctx=Load()),
elt=Name(id='i'),
generators=[
comprehension(
target=Name(id='i', ctx=Store()),
iter=Name(id='soc', ctx=Load()),
iter=Name(id='soc'),
is_async=1)]))
@ -945,7 +937,7 @@ Statements
Name(id='a', ctx=Store()),
Name(id='b', ctx=Store())],
ctx=Store())],
value=Name(id='c', ctx=Load()))])
value=Name(id='c'))])
.. class:: AnnAssign(target, annotation, value, simple)
@ -968,7 +960,7 @@ Statements
body=[
AnnAssign(
target=Name(id='c', ctx=Store()),
annotation=Name(id='int', ctx=Load()),
annotation=Name(id='int'),
simple=1)])
>>> print(ast.dump(ast.parse('(a): int = 1'), indent=4)) # Annotation with parenthesis
@ -976,7 +968,7 @@ Statements
body=[
AnnAssign(
target=Name(id='a', ctx=Store()),
annotation=Name(id='int', ctx=Load()),
annotation=Name(id='int'),
value=Constant(value=1),
simple=0)])
@ -985,10 +977,10 @@ Statements
body=[
AnnAssign(
target=Attribute(
value=Name(id='a', ctx=Load()),
value=Name(id='a'),
attr='b',
ctx=Store()),
annotation=Name(id='int', ctx=Load()),
annotation=Name(id='int'),
simple=0)])
>>> print(ast.dump(ast.parse('a[1]: int'), indent=4)) # Subscript annotation
@ -996,10 +988,10 @@ Statements
body=[
AnnAssign(
target=Subscript(
value=Name(id='a', ctx=Load()),
value=Name(id='a'),
slice=Constant(value=1),
ctx=Store()),
annotation=Name(id='int', ctx=Load()),
annotation=Name(id='int'),
simple=0)])
@ -1036,8 +1028,8 @@ Statements
Module(
body=[
Raise(
exc=Name(id='x', ctx=Load()),
cause=Name(id='y', ctx=Load()))])
exc=Name(id='x'),
cause=Name(id='y'))])
.. class:: Assert(test, msg)
@ -1051,8 +1043,8 @@ Statements
Module(
body=[
Assert(
test=Name(id='x', ctx=Load()),
msg=Name(id='y', ctx=Load()))])
test=Name(id='x'),
msg=Name(id='y'))])
.. class:: Delete(targets)
@ -1098,7 +1090,7 @@ Statements
body=[
TypeAlias(
name=Name(id='Alias', ctx=Store()),
value=Name(id='int', ctx=Load()))])
value=Name(id='int'))])
.. versionadded:: 3.12
@ -1191,13 +1183,13 @@ Control flow
Module(
body=[
If(
test=Name(id='x', ctx=Load()),
test=Name(id='x'),
body=[
Expr(
value=Constant(value=Ellipsis))],
orelse=[
If(
test=Name(id='y', ctx=Load()),
test=Name(id='y'),
body=[
Expr(
value=Constant(value=Ellipsis))],
@ -1231,7 +1223,7 @@ Control flow
body=[
For(
target=Name(id='x', ctx=Store()),
iter=Name(id='y', ctx=Load()),
iter=Name(id='y'),
body=[
Expr(
value=Constant(value=Ellipsis))],
@ -1256,7 +1248,7 @@ Control flow
Module(
body=[
While(
test=Name(id='x', ctx=Load()),
test=Name(id='x'),
body=[
Expr(
value=Constant(value=Ellipsis))],
@ -1284,11 +1276,11 @@ Control flow
body=[
For(
target=Name(id='a', ctx=Store()),
iter=Name(id='b', ctx=Load()),
iter=Name(id='b'),
body=[
If(
test=Compare(
left=Name(id='a', ctx=Load()),
left=Name(id='a'),
ops=[
Gt()],
comparators=[
@ -1326,12 +1318,12 @@ Control flow
value=Constant(value=Ellipsis))],
handlers=[
ExceptHandler(
type=Name(id='Exception', ctx=Load()),
type=Name(id='Exception'),
body=[
Expr(
value=Constant(value=Ellipsis))]),
ExceptHandler(
type=Name(id='OtherException', ctx=Load()),
type=Name(id='OtherException'),
name='e',
body=[
Expr(
@ -1366,7 +1358,7 @@ Control flow
value=Constant(value=Ellipsis))],
handlers=[
ExceptHandler(
type=Name(id='Exception', ctx=Load()),
type=Name(id='Exception'),
body=[
Expr(
value=Constant(value=Ellipsis))])])])
@ -1394,12 +1386,12 @@ Control flow
body=[
Expr(
value=BinOp(
left=Name(id='a', ctx=Load()),
left=Name(id='a'),
op=Add(),
right=Constant(value=1)))],
handlers=[
ExceptHandler(
type=Name(id='TypeError', ctx=Load()),
type=Name(id='TypeError'),
body=[
Pass()])])])
@ -1432,18 +1424,18 @@ Control flow
With(
items=[
withitem(
context_expr=Name(id='a', ctx=Load()),
context_expr=Name(id='a'),
optional_vars=Name(id='b', ctx=Store())),
withitem(
context_expr=Name(id='c', ctx=Load()),
context_expr=Name(id='c'),
optional_vars=Name(id='d', ctx=Store()))],
body=[
Expr(
value=Call(
func=Name(id='something', ctx=Load()),
func=Name(id='something'),
args=[
Name(id='b', ctx=Load()),
Name(id='d', ctx=Load())]))])])
Name(id='b'),
Name(id='d')]))])])
Pattern matching
@ -1483,14 +1475,14 @@ Pattern matching
Module(
body=[
Match(
subject=Name(id='x', ctx=Load()),
subject=Name(id='x'),
cases=[
match_case(
pattern=MatchSequence(
patterns=[
MatchAs(name='x')]),
guard=Compare(
left=Name(id='x', ctx=Load()),
left=Name(id='x'),
ops=[
Gt()],
comparators=[
@ -1500,7 +1492,7 @@ Pattern matching
value=Constant(value=Ellipsis))]),
match_case(
pattern=MatchClass(
cls=Name(id='tuple', ctx=Load())),
cls=Name(id='tuple')),
body=[
Expr(
value=Constant(value=Ellipsis))])])])
@ -1524,7 +1516,7 @@ Pattern matching
Module(
body=[
Match(
subject=Name(id='x', ctx=Load()),
subject=Name(id='x'),
cases=[
match_case(
pattern=MatchValue(
@ -1551,7 +1543,7 @@ Pattern matching
Module(
body=[
Match(
subject=Name(id='x', ctx=Load()),
subject=Name(id='x'),
cases=[
match_case(
pattern=MatchSingleton(value=None),
@ -1578,7 +1570,7 @@ Pattern matching
Module(
body=[
Match(
subject=Name(id='x', ctx=Load()),
subject=Name(id='x'),
cases=[
match_case(
pattern=MatchSequence(
@ -1611,7 +1603,7 @@ Pattern matching
Module(
body=[
Match(
subject=Name(id='x', ctx=Load()),
subject=Name(id='x'),
cases=[
match_case(
pattern=MatchSequence(
@ -1660,7 +1652,7 @@ Pattern matching
Module(
body=[
Match(
subject=Name(id='x', ctx=Load()),
subject=Name(id='x'),
cases=[
match_case(
pattern=MatchMapping(
@ -1710,11 +1702,11 @@ Pattern matching
Module(
body=[
Match(
subject=Name(id='x', ctx=Load()),
subject=Name(id='x'),
cases=[
match_case(
pattern=MatchClass(
cls=Name(id='Point2D', ctx=Load()),
cls=Name(id='Point2D'),
patterns=[
MatchValue(
value=Constant(value=0)),
@ -1725,7 +1717,7 @@ Pattern matching
value=Constant(value=Ellipsis))]),
match_case(
pattern=MatchClass(
cls=Name(id='Point3D', ctx=Load()),
cls=Name(id='Point3D'),
kwd_attrs=[
'x',
'y',
@ -1766,7 +1758,7 @@ Pattern matching
Module(
body=[
Match(
subject=Name(id='x', ctx=Load()),
subject=Name(id='x'),
cases=[
match_case(
pattern=MatchAs(
@ -1803,7 +1795,7 @@ Pattern matching
Module(
body=[
Match(
subject=Name(id='x', ctx=Load()),
subject=Name(id='x'),
cases=[
match_case(
pattern=MatchOr(
@ -1843,7 +1835,7 @@ Type annotations
body=[
AnnAssign(
target=Name(id='x', ctx=Store()),
annotation=Name(id='bool', ctx=Load()),
annotation=Name(id='bool'),
value=Constant(value=1),
simple=1)],
type_ignores=[
@ -1881,12 +1873,11 @@ aliases.
type_params=[
TypeVar(
name='T',
bound=Name(id='int', ctx=Load()),
default_value=Name(id='bool', ctx=Load()))],
bound=Name(id='int'),
default_value=Name(id='bool'))],
value=Subscript(
value=Name(id='list', ctx=Load()),
slice=Name(id='T', ctx=Load()),
ctx=Load()))])
value=Name(id='list'),
slice=Name(id='T')))])
.. versionadded:: 3.12
@ -1911,17 +1902,14 @@ aliases.
name='P',
default_value=List(
elts=[
Name(id='int', ctx=Load()),
Name(id='str', ctx=Load())],
ctx=Load()))],
Name(id='int'),
Name(id='str')]))],
value=Subscript(
value=Name(id='Callable', ctx=Load()),
value=Name(id='Callable'),
slice=Tuple(
elts=[
Name(id='P', ctx=Load()),
Name(id='int', ctx=Load())],
ctx=Load()),
ctx=Load()))])
Name(id='P'),
Name(id='int')])))])
.. versionadded:: 3.12
@ -1942,18 +1930,13 @@ aliases.
TypeAlias(
name=Name(id='Alias', ctx=Store()),
type_params=[
TypeVarTuple(
name='Ts',
default_value=Tuple(ctx=Load()))],
TypeVarTuple(name='Ts', default_value=Tuple())],
value=Subscript(
value=Name(id='tuple', ctx=Load()),
value=Name(id='tuple'),
slice=Tuple(
elts=[
Starred(
value=Name(id='Ts', ctx=Load()),
ctx=Load())],
ctx=Load()),
ctx=Load()))])
value=Name(id='Ts'))])))])
.. versionadded:: 3.12
@ -2058,8 +2041,8 @@ Function and class definitions
body=[
Pass()],
decorator_list=[
Name(id='decorator1', ctx=Load()),
Name(id='decorator2', ctx=Load())],
Name(id='decorator1'),
Name(id='decorator2')],
returns=Constant(value='return annotation'))])
@ -2089,14 +2072,14 @@ Function and class definitions
body=[
Expr(
value=Yield(
value=Name(id='x', ctx=Load())))])
value=Name(id='x')))])
>>> print(ast.dump(ast.parse('yield from x'), indent=4))
Module(
body=[
Expr(
value=YieldFrom(
value=Name(id='x', ctx=Load())))])
value=Name(id='x')))])
.. class:: Global(names)
@ -2151,17 +2134,17 @@ Function and class definitions
ClassDef(
name='Foo',
bases=[
Name(id='base1', ctx=Load()),
Name(id='base2', ctx=Load())],
Name(id='base1'),
Name(id='base2')],
keywords=[
keyword(
arg='metaclass',
value=Name(id='meta', ctx=Load()))],
value=Name(id='meta'))],
body=[
Pass()],
decorator_list=[
Name(id='decorator1', ctx=Load()),
Name(id='decorator2', ctx=Load())])])
Name(id='decorator1'),
Name(id='decorator2')])])
.. versionchanged:: 3.12
Added ``type_params``.
@ -2198,7 +2181,7 @@ Async and await
Expr(
value=Await(
value=Call(
func=Name(id='other_func', ctx=Load()))))])])
func=Name(id='other_func'))))])])
.. class:: AsyncFor(target, iter, body, orelse, type_comment)
@ -2222,10 +2205,10 @@ Async and await
Apart from the node classes, the :mod:`ast` module defines these utility functions
and classes for traversing abstract syntax trees:
.. function:: parse(source, filename='<unknown>', mode='exec', *, type_comments=False, feature_version=None, optimize=-1)
.. function:: parse(source, filename='<unknown>', mode='exec', *, type_comments=False, feature_version=None, optimize=-1, module=None)
Parse the source into an AST node. Equivalent to ``compile(source,
filename, mode, flags=FLAGS_VALUE, optimize=optimize)``,
filename, mode, flags=FLAGS_VALUE, optimize=optimize, module=module)``,
where ``FLAGS_VALUE`` is ``ast.PyCF_ONLY_AST`` if ``optimize <= 0``
and ``ast.PyCF_OPTIMIZED_AST`` otherwise.
@ -2278,6 +2261,9 @@ and classes for traversing abstract syntax trees:
The minimum supported version for ``feature_version`` is now ``(3, 7)``.
The ``optimize`` argument was added.
.. versionadded:: 3.15
Added the *module* parameter.
.. function:: unparse(ast_obj)
@ -2459,7 +2445,7 @@ and classes for traversing abstract syntax trees:
def visit_Name(self, node):
return Subscript(
value=Name(id='data', ctx=Load()),
value=Name(id='data'),
slice=Constant(value=node.id),
ctx=node.ctx
)
@ -2502,42 +2488,35 @@ and classes for traversing abstract syntax trees:
indents that many spaces per level. If *indent* is a string (such as ``"\t"``),
that string is used to indent each level.
If *show_empty* is false (the default), optional empty lists will be
omitted from the output.
If *show_empty* is false (the default), optional empty lists and
``Load()`` values will be omitted from the output.
Optional ``None`` values are always omitted.
.. doctest::
>>> tree = ast.parse('print(None)', '?', 'eval')
>>> print(ast.dump(tree, indent=4))
Expression(
body=Call(
func=Name(id='print'),
args=[
Constant(value=None)]))
>>> print(ast.dump(tree, indent=4, show_empty=True))
Expression(
body=Call(
func=Name(id='print', ctx=Load()),
args=[
Constant(value=None)],
keywords=[]))
.. versionchanged:: 3.9
Added the *indent* option.
.. versionchanged:: 3.13
Added the *show_empty* option.
.. doctest::
>>> print(ast.dump(ast.parse("""\
... async def f():
... await other_func()
... """), indent=4, show_empty=True))
Module(
body=[
AsyncFunctionDef(
name='f',
args=arguments(
posonlyargs=[],
args=[],
kwonlyargs=[],
kw_defaults=[],
defaults=[]),
body=[
Expr(
value=Await(
value=Call(
func=Name(id='other_func', ctx=Load()),
args=[],
keywords=[])))],
decorator_list=[],
type_params=[])],
type_ignores=[])
.. versionchanged:: 3.15
Omit optional ``Load()`` values by default.
.. _ast-compiler-flags:

View file

@ -1221,8 +1221,8 @@ Task Object
To cancel a running Task use the :meth:`cancel` method. Calling it
will cause the Task to throw a :exc:`CancelledError` exception into
the wrapped coroutine. If a coroutine is awaiting on a Future
object during cancellation, the Future object will be cancelled.
the wrapped coroutine. If a coroutine is awaiting on a future-like
object during cancellation, the awaited object will be cancelled.
:meth:`cancelled` can be used to check if the Task was cancelled.
The method returns ``True`` if the wrapped coroutine did not
@ -1411,6 +1411,10 @@ Task Object
the cancellation, it needs to call :meth:`Task.uncancel` in addition
to catching the exception.
If the Task being cancelled is currently awaiting on a future-like
object, that awaited object will also be cancelled. This cancellation
propagates down the entire chain of awaited objects.
.. versionchanged:: 3.9
Added the *msg* parameter.

View file

@ -192,12 +192,8 @@ The :mod:`bdb` module also defines two classes:
entered.
* ``"return"``: A function or other code block is about to return.
* ``"exception"``: An exception has occurred.
* ``"c_call"``: A C function is about to be called.
* ``"c_return"``: A C function has returned.
* ``"c_exception"``: A C function has raised an exception.
For the Python events, specialized functions (see below) are called. For
the C events, no action is taken.
For all the events, specialized functions (see below) are called.
The *arg* parameter depends on the previous event.
@ -240,7 +236,7 @@ The :mod:`bdb` module also defines two classes:
Normally derived classes don't override the following methods, but they may
if they want to redefine the definition of stopping and breakpoints.
.. method:: is_skipped_line(module_name)
.. method:: is_skipped_module(module_name)
Return ``True`` if *module_name* matches any skip pattern.

View file

@ -251,7 +251,7 @@ interpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is
3) specifies the number of months per row. *css* is the name for the
cascading style sheet to be used. :const:`None` can be passed if no style
sheet should be used. *encoding* specifies the encoding to be used for the
output (defaulting to the system default encoding).
output (defaulting to ``'utf-8'``).
.. method:: formatmonthname(theyear, themonth, withyear=True)
@ -501,6 +501,14 @@ The :mod:`calendar` module exports the following data attributes:
>>> list(calendar.month_name)
['', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
.. caution::
In locales with alternative month names forms, the :data:`!month_name` sequence
may not be suitable when a month name stands by itself and not as part of a date.
For instance, in Greek and in many Slavic and Baltic languages, :data:`!month_name`
will produce the month in genitive case. Use :data:`standalone_month_name` for a form
suitable for standalone use.
.. data:: month_abbr
@ -512,6 +520,31 @@ The :mod:`calendar` module exports the following data attributes:
>>> list(calendar.month_abbr)
['', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
.. caution::
In locales with alternative month names forms, the :data:`!month_abbr` sequence
may not be suitable when a month name stands by itself and not as part of a date.
Use :data:`standalone_month_abbr` for a form suitable for standalone use.
.. data:: standalone_month_name
A sequence that represents the months of the year in the current locale
in the standalone form if the locale provides one. Else it is equivalent
to :data:`month_name`.
.. versionadded:: 3.15
.. data:: standalone_month_abbr
A sequence that represents the abbreviated months of the year in the current
locale in the standalone form if the locale provides one. Else it is
equivalent to :data:`month_abbr`.
.. versionadded:: 3.15
.. data:: JANUARY
FEBRUARY
MARCH
@ -677,8 +710,7 @@ The following options are accepted:
.. option:: month
The month of the specified :option:`year` to print the calendar for.
Must be a number between 1 and 12,
and may only be used in text mode.
Must be a number between 1 and 12.
Defaults to printing a calendar for the full year.

View file

@ -29,7 +29,7 @@ build applications which provide an interactive interpreter prompt.
module.
.. class:: InteractiveConsole(locals=None, filename="<console>", local_exit=False)
.. class:: InteractiveConsole(locals=None, filename="<console>", *, local_exit=False)
Closely emulate the behavior of the interactive Python interpreter. This class
builds on :class:`InteractiveInterpreter` and adds prompting using the familiar

View file

@ -68,11 +68,21 @@ The full details for each codec can also be looked up directly:
Looks up the codec info in the Python codec registry and returns a
:class:`CodecInfo` object as defined below.
Encodings are first looked up in the registry's cache. If not found, the list of
This function first normalizes the *encoding*: all ASCII letters are
converted to lower case, spaces are replaced with hyphens.
Then encoding is looked up in the registry's cache. If not found, the list of
registered search functions is scanned. If no :class:`CodecInfo` object is
found, a :exc:`LookupError` is raised. Otherwise, the :class:`CodecInfo` object
is stored in the cache and returned to the caller.
.. versionchanged:: 3.9
Any characters except ASCII letters and digits and a dot are converted to underscore.
.. versionchanged:: 3.15
No characters are converted to underscore anymore.
Spaces are converted to hyphens.
.. class:: CodecInfo(encode, decode, streamreader=None, streamwriter=None, incrementalencoder=None, incrementaldecoder=None, name=None)
Codec details when looking up the codec registry. The constructor
@ -167,14 +177,11 @@ function:
.. function:: register(search_function, /)
Register a codec search function. Search functions are expected to take one
argument, being the encoding name in all lower case letters with hyphens
and spaces converted to underscores, and return a :class:`CodecInfo` object.
argument, being the encoding name in all lower case letters with spaces
converted to hyphens, and return a :class:`CodecInfo` object.
In case a search function cannot find a given encoding, it should return
``None``.
.. versionchanged:: 3.9
Hyphens and spaces are converted to underscore.
.. function:: unregister(search_function, /)
@ -1070,7 +1077,7 @@ or with dictionaries as mapping tables. The following table lists the codecs by
name, together with a few common aliases, and the languages for which the
encoding is likely used. Neither the list of aliases nor the list of languages
is meant to be exhaustive. Notice that spelling alternatives that only differ in
case or use a hyphen instead of an underscore are also valid aliases
case or use a space or a hyphen instead of an underscore are also valid aliases
because they are equivalent when normalized by
:func:`~encodings.normalize_encoding`. For example, ``'utf-8'`` is a valid
alias for the ``'utf_8'`` codec.
@ -1081,7 +1088,7 @@ alias for the ``'utf_8'`` codec.
refer to the source :source:`aliases.py <Lib/encodings/aliases.py>` file.
On Windows, ``cpXXX`` codecs are available for all code pages.
But only codecs listed in the following table are guarantead to exist on
But only codecs listed in the following table are guaranteed to exist on
other platforms.
.. impl-detail::
@ -1337,7 +1344,7 @@ particular, the following variants typically exist:
+-----------------+--------------------------------+--------------------------------+
| utf_8 | U8, UTF, utf8, cp65001 | all languages |
+-----------------+--------------------------------+--------------------------------+
| utf_8_sig | | all languages |
| utf_8_sig | utf8-sig | all languages |
+-----------------+--------------------------------+--------------------------------+
.. versionchanged:: 3.4

View file

@ -367,9 +367,11 @@ Several mathematical operations are provided for combining :class:`Counter`
objects to produce multisets (counters that have counts greater than zero).
Addition and subtraction combine counters by adding or subtracting the counts
of corresponding elements. Intersection and union return the minimum and
maximum of corresponding counts. Equality and inclusion compare
corresponding counts. Each operation can accept inputs with signed
counts, but the output will exclude results with counts of zero or less.
maximum of corresponding counts. Symmetric difference returns the difference
between the maximum and minimum of the corresponding counts. Equality and
inclusion compare corresponding counts. Each operation can accept inputs
with signed counts, but the output will exclude results with counts of zero
or below.
.. doctest::
@ -383,6 +385,8 @@ counts, but the output will exclude results with counts of zero or less.
Counter({'a': 1, 'b': 1})
>>> c | d # union: max(c[x], d[x])
Counter({'a': 3, 'b': 2})
>>> c ^ d # max(c[x], d[x]) - min(c[x], d[x])
Counter({'a': 2, 'b': 1})
>>> c == d # equality: c[x] == d[x]
False
>>> c <= d # inclusion: c[x] <= d[x]
@ -400,6 +404,9 @@ or subtracting from an empty counter.
.. versionadded:: 3.3
Added support for unary plus, unary minus, and in-place multiset operations.
.. versionadded:: 3.15
Added support for the symmetric difference multiset operation, ``c ^ d``.
.. note::
Counters were primarily designed to work with positive integers to represent
@ -1202,7 +1209,7 @@ If a new entry overwrites an existing entry, the
original insertion position is changed and moved to the end::
class LastUpdatedOrderedDict(OrderedDict):
'Store items in the order the keys were last added'
'Store items in the order that the keys were last updated.'
def __setitem__(self, key, value):
super().__setitem__(key, value)

View file

@ -327,10 +327,10 @@ Functions and classes provided:
.. function:: redirect_stdout(new_target)
Context manager for temporarily redirecting :data:`sys.stdout` to
another file or file-like object.
another :term:`file object`.
This tool adds flexibility to existing functions or classes whose output
is hardwired to stdout.
is hardwired to :data:`sys.stdout`.
For example, the output of :func:`help` normally is sent to *sys.stdout*.
You can capture that output in a string by redirecting the output to an
@ -366,8 +366,8 @@ Functions and classes provided:
.. function:: redirect_stderr(new_target)
Similar to :func:`~contextlib.redirect_stdout` but redirecting
:data:`sys.stderr` to another file or file-like object.
Similar to :func:`~contextlib.redirect_stdout` but redirecting the global
:data:`sys.stderr` to another :term:`file object`.
This context manager is :ref:`reentrant <reentrant-cms>`.

View file

@ -313,7 +313,7 @@ client::
addr = writer.transport.get_extra_info('socket').getpeername()
client_addr_var.set(addr)
# In any code that we call is now possible to get
# In any code that we call, it is now possible to get the
# client's address by calling 'client_addr_var.get()'.
while True:

View file

@ -535,6 +535,9 @@ Other constructors, all class methods:
:c:func:`localtime` function. Raise :exc:`OSError` instead of
:exc:`ValueError` on :c:func:`localtime` failure.
.. versionchanged:: 3.15
Accepts any real number as *timestamp*, not only integer or float.
.. classmethod:: date.fromordinal(ordinal)
@ -1020,6 +1023,10 @@ Other constructors, all class methods:
.. versionchanged:: 3.6
:meth:`fromtimestamp` may return instances with :attr:`.fold` set to 1.
.. versionchanged:: 3.15
Accepts any real number as *timestamp*, not only integer or float.
.. classmethod:: datetime.utcfromtimestamp(timestamp)
Return the UTC :class:`.datetime` corresponding to the POSIX timestamp, with
@ -1060,6 +1067,9 @@ Other constructors, all class methods:
Use :meth:`datetime.fromtimestamp` with :const:`UTC` instead.
.. versionchanged:: 3.15
Accepts any real number as *timestamp*, not only integer or float.
.. classmethod:: datetime.fromordinal(ordinal)
@ -1502,11 +1512,11 @@ Instance methods:
returned by :func:`time.time`.
Naive :class:`.datetime` instances are assumed to represent local
time and this method relies on the platform C :c:func:`mktime`
function to perform the conversion. Since :class:`.datetime`
supports wider range of values than :c:func:`mktime` on many
platforms, this method may raise :exc:`OverflowError` or :exc:`OSError`
for times far in the past or far in the future.
time and this method relies on platform C functions to perform
the conversion. Since :class:`.datetime` supports a wider range of
values than the platform C functions on many platforms, this
method may raise :exc:`OverflowError` or :exc:`OSError` for times
far in the past or far in the future.
For aware :class:`.datetime` instances, the return value is computed
as::
@ -1519,6 +1529,10 @@ Instance methods:
The :meth:`timestamp` method uses the :attr:`.fold` attribute to
disambiguate the times during a repeated interval.
.. versionchanged:: 3.6
This method no longer relies on the platform C :c:func:`mktime`
function to perform conversions.
.. note::
There is no method to obtain the POSIX timestamp directly from a
@ -2379,7 +2393,7 @@ locations where different offsets are used in different days of the year or
where historical changes have been made to civil time.
.. class:: timezone(offset, name=None)
.. class:: timezone(offset[, name])
The *offset* argument must be specified as a :class:`timedelta`
object representing the difference between the local time and UTC. It must
@ -2625,7 +2639,10 @@ differences between platforms in handling of unsupported format specifiers.
``%G``, ``%u`` and ``%V`` were added.
.. versionadded:: 3.12
``%:z`` was added.
``%:z`` was added for :meth:`~.datetime.strftime`
.. versionadded:: 3.15
``%:z`` was added for :meth:`~.datetime.strptime`
Technical Detail
^^^^^^^^^^^^^^^^
@ -2720,12 +2737,18 @@ Notes:
When the ``%z`` directive is provided to the :meth:`~.datetime.strptime` method,
the UTC offsets can have a colon as a separator between hours, minutes
and seconds.
For example, ``'+01:00:00'`` will be parsed as an offset of one hour.
In addition, providing ``'Z'`` is identical to ``'+00:00'``.
For example, both ``'+010000'`` and ``'+01:00:00'`` will be parsed as an offset
of one hour. In addition, providing ``'Z'`` is identical to ``'+00:00'``.
``%:z``
Behaves exactly as ``%z``, but has a colon separator added between
hours, minutes and seconds.
When used with :meth:`~.datetime.strftime`, behaves exactly as ``%z``,
except that a colon separator is added between hours, minutes and seconds.
When used with :meth:`~.datetime.strptime`, the UTC offset is *required*
to have a colon as a separator between hours, minutes and seconds.
For example, ``'+01:00:00'`` (but *not* ``'+010000'``) will be parsed as
an offset of one hour. In addition, providing ``'Z'`` is identical to
``'+00:00'``.
``%Z``
In :meth:`~.datetime.strftime`, ``%Z`` is replaced by an empty string if

View file

@ -15,10 +15,16 @@
* :mod:`dbm.ndbm`
If none of these modules are installed, the
slow-but-simple implementation in module :mod:`dbm.dumb` will be used. There
slow-but-simple implementation in module :mod:`dbm.dumb` will be used. There
is a `third party interface <https://www.jcea.es/programacion/pybsddb.htm>`_ to
the Oracle Berkeley DB.
.. note::
None of the underlying modules will automatically shrink the disk space used by
the database file. However, :mod:`dbm.sqlite3`, :mod:`dbm.gnu` and :mod:`dbm.dumb`
provide a :meth:`!reorganize` method that can be used for this purpose.
.. exception:: error
A tuple containing the exceptions that can be raised by each of the supported
@ -195,12 +201,24 @@ or any other SQLite browser, including the SQLite CLI.
the :meth:`!setdefault` method requires two arguments.
It also supports a "closing" context manager via the :keyword:`with` keyword.
The following method is also provided:
The following methods are also provided:
.. method:: sqlite3.close()
Close the SQLite database.
.. method:: sqlite3.reorganize()
If you have carried out a lot of deletions and would like to shrink the space
used on disk, this method will reorganize the database; otherwise, deleted file
space will be kept and reused as new (key, value) pairs are added.
.. note::
While reorganizing, as much as two times the size of the original database is required
in free disk space. However, be aware that this factor changes for each :mod:`dbm` submodule.
.. versionadded:: 3.15
:mod:`dbm.gnu` --- GNU database manager
---------------------------------------
@ -315,6 +333,10 @@ functionality like crash tolerance.
reorganization; otherwise, deleted file space will be kept and reused as new
(key, value) pairs are added.
.. note::
While reorganizing, as much as one time the size of the original database is required
in free disk space. However, be aware that this factor changes for each :mod:`dbm` submodule.
.. method:: gdbm.sync()
When the database has been opened in fast mode, this method forces any
@ -461,6 +483,11 @@ The :mod:`!dbm.dumb` module defines the following:
with a sufficiently large/complex entry due to stack depth limitations in
Python's AST compiler.
.. warning::
:mod:`dbm.dumb` does not support concurrent read/write access. (Multiple
simultaneous read accesses are safe.) When a program has the database open
for writing, no other program should have it open for reading or writing.
.. versionchanged:: 3.5
:func:`~dbm.dumb.open` always creates a new database when *flag* is ``'n'``.
@ -482,6 +509,18 @@ The :mod:`!dbm.dumb` module defines the following:
Close the database.
.. method:: dumbdbm.reorganize()
If you have carried out a lot of deletions and would like to shrink the space
used on disk, this method will reorganize the database; otherwise, deleted file
space will not be reused.
.. note::
While reorganizing, no additional free disk space is required. However, be aware
that this factor changes for each :mod:`dbm` submodule.
.. versionadded:: 3.15
.. method:: dumbdbm.sync()
Synchronize the on-disk directory and data files. This method is called

View file

@ -1569,7 +1569,16 @@ In addition to the three supplied contexts, new contexts can be created with the
Constants
---------
The constants in this section are only relevant for the C module. They
.. data:: SPEC_VERSION
The highest version of the General Decimal Arithmetic
Specification that this implementation complies with.
See https://speleotrove.com/decimal/decarith.html for the specification.
.. versionadded:: 3.15
The following constants are only relevant for the C module. They
are also included in the pure Python version for compatibility.
+---------------------------------+---------------------+-------------------------------+

View file

@ -278,7 +278,7 @@ diffs. For comparing directories and files, see also, the :mod:`filecmp` module.
emu
.. function:: unified_diff(a, b, fromfile='', tofile='', fromfiledate='', tofiledate='', n=3, lineterm='\n')
.. function:: unified_diff(a, b, fromfile='', tofile='', fromfiledate='', tofiledate='', n=3, lineterm='\n', *, color=False)
Compare *a* and *b* (lists of strings); return a delta (a :term:`generator`
generating the delta lines) in unified diff format.
@ -297,6 +297,10 @@ diffs. For comparing directories and files, see also, the :mod:`filecmp` module.
For inputs that do not have trailing newlines, set the *lineterm* argument to
``""`` so that the output will be uniformly newline free.
Set *color* to ``True`` to enable output in color, similar to
:program:`git diff --color`. Even if enabled, it can be
:ref:`controlled using environment variables <using-on-controlling-color>`.
The unified diff format normally has a header for filenames and modification
times. Any or all of these may be specified using strings for *fromfile*,
*tofile*, *fromfiledate*, and *tofiledate*. The modification times are normally
@ -319,6 +323,10 @@ diffs. For comparing directories and files, see also, the :mod:`filecmp` module.
See :ref:`difflib-interface` for a more detailed example.
.. versionchanged:: 3.15
Added the *color* parameter.
.. function:: diff_bytes(dfunc, a, b, fromfile=b'', tofile=b'', fromfiledate=b'', tofiledate=b'', n=3, lineterm=b'\n')
Compare *a* and *b* (lists of bytes objects) using *dfunc*; yield a

View file

@ -1968,11 +1968,6 @@ but are replaced by real opcodes or removed before bytecode is generated.
``SETUP_CLEANUP`` or ``SETUP_WITH``.
.. opcode:: LOAD_CONST_IMMORTAL (consti)
Works as :opcode:`LOAD_CONST`, but is more efficient for immortal objects.
.. opcode:: JUMP
JUMP_NO_INTERRUPT

View file

@ -1057,12 +1057,15 @@ from text files and modules with doctests:
Convert doctest tests from one or more text files to a
:class:`unittest.TestSuite`.
The returned :class:`unittest.TestSuite` is to be run by the unittest framework
and runs the interactive examples in each file. If an example in any file
fails, then the synthesized unit test fails, and a :exc:`~unittest.TestCase.failureException`
exception is raised showing the name of the file containing the test and a
(sometimes approximate) line number. If all the examples in a file are
skipped, then the synthesized unit test is also marked as skipped.
The returned :class:`unittest.TestSuite` is to be run by the unittest
framework and runs the interactive examples in each file.
Each file is run as a separate unit test, and each example in a file
is run as a :ref:`subtest <subtests>`.
If any example in a file fails, then the synthesized unit test fails.
The traceback for failure or error contains the name of the file
containing the test and a (sometimes approximate) line number.
If all the examples in a file are skipped, then the synthesized unit
test is also marked as skipped.
Pass one or more paths (as strings) to text files to be examined.
@ -1120,18 +1123,23 @@ from text files and modules with doctests:
The global ``__file__`` is added to the globals provided to doctests loaded
from a text file using :func:`DocFileSuite`.
.. versionchanged:: 3.15
Run each example as a :ref:`subtest <subtests>`.
.. function:: DocTestSuite(module=None, globs=None, extraglobs=None, test_finder=None, setUp=None, tearDown=None, optionflags=0, checker=None)
Convert doctest tests for a module to a :class:`unittest.TestSuite`.
The returned :class:`unittest.TestSuite` is to be run by the unittest framework
and runs each doctest in the module.
Each docstring is run as a separate unit test.
If any of the doctests fail, then the synthesized unit test fails,
and a :exc:`unittest.TestCase.failureException` exception is raised
showing the name of the file containing the test and a (sometimes approximate)
line number. If all the examples in a docstring are skipped, then the
The returned :class:`unittest.TestSuite` is to be run by the unittest
framework and runs each doctest in the module.
Each docstring is run as a separate unit test, and each example in
a docstring is run as a :ref:`subtest <subtests>`.
If any of the doctests fail, then the synthesized unit test fails.
The traceback for failure or error contains the name of the file
containing the test and a (sometimes approximate) line number.
If all the examples in a docstring are skipped, then the
synthesized unit test is also marked as skipped.
Optional argument *module* provides the module to be tested. It can be a module
object or a (possibly dotted) module name. If not specified, the module calling
@ -1156,6 +1164,9 @@ from text files and modules with doctests:
:func:`DocTestSuite` returns an empty :class:`unittest.TestSuite` if *module*
contains no docstrings instead of raising :exc:`ValueError`.
.. versionchanged:: 3.15
Run each example as a :ref:`subtest <subtests>`.
Under the covers, :func:`DocTestSuite` creates a :class:`unittest.TestSuite` out
of :class:`!doctest.DocTestCase` instances, and :class:`!DocTestCase` is a
subclass of :class:`unittest.TestCase`. :class:`!DocTestCase` isn't documented
@ -1518,7 +1529,7 @@ DocTestRunner objects
with strings that should be displayed. It defaults to ``sys.stdout.write``. If
capturing the output is not sufficient, then the display output can be also
customized by subclassing DocTestRunner, and overriding the methods
:meth:`report_start`, :meth:`report_success`,
:meth:`report_skip`, :meth:`report_start`, :meth:`report_success`,
:meth:`report_unexpected_exception`, and :meth:`report_failure`.
The optional keyword argument *checker* specifies the :class:`OutputChecker`
@ -1543,6 +1554,19 @@ DocTestRunner objects
:class:`DocTestRunner` defines the following methods:
.. method:: report_skip(out, test, example)
Report that the given example was skipped. This method is provided to
allow subclasses of :class:`DocTestRunner` to customize their output; it
should not be called directly.
*example* is the example about to be processed. *test* is the test
containing *example*. *out* is the output function that was passed to
:meth:`DocTestRunner.run`.
.. versionadded:: 3.15
.. method:: report_start(out, test, example)
Report that the test runner is about to process the given example. This method

View file

@ -437,7 +437,9 @@ The following exceptions are the exceptions that are usually raised.
* Creating a new Python thread.
* :meth:`Joining <threading.Thread.join>` a running daemon thread.
* :func:`os.fork`.
* :func:`os.fork`,
* acquiring a lock such as :class:`threading.Lock`, when it is known that
the operation would otherwise deadlock.
See also the :func:`sys.is_finalizing` function.
@ -448,6 +450,11 @@ The following exceptions are the exceptions that are usually raised.
:meth:`threading.Thread.join` can now raise this exception.
.. versionchanged:: 3.15
This exception may be raised when acquiring :meth:`threading.Lock`
or :meth:`threading.RLock`.
.. exception:: RecursionError
This exception is derived from :exc:`RuntimeError`. It is raised when the
@ -971,6 +978,12 @@ their subgroups based on the types of the contained exceptions.
raises a :exc:`TypeError` if any contained exception is not an
:exc:`Exception` subclass.
.. impl-detail::
The ``excs`` parameter may be any sequence, but lists and tuples are
specifically processed more efficiently here. For optimal performance,
pass a tuple as ``excs``.
.. attribute:: message
The ``msg`` argument to the constructor. This is a read-only attribute.

View file

@ -237,13 +237,13 @@ handler:
Binary file "/opt/python/python", at +0x32df8a [0x5b27f7d85f8a]
Binary file "/usr/lib/libc.so.6", at +0x3def0 [0x77b73226bef0]
Binary file "/usr/lib/libc.so.6", at +0x17ef9c [0x77b7323acf9c]
Binary file "/opt/python/build/lib.linux-x86_64-3.14/_ctypes.cpython-314d-x86_64-linux-gnu.so", at +0xcdf6 [0x77b7315dddf6]
Binary file "/opt/python/build/lib.linux-x86_64-3.15/_ctypes.cpython-315d-x86_64-linux-gnu.so", at +0xcdf6 [0x77b7315dddf6]
Binary file "/usr/lib/libffi.so.8", at +0x7976 [0x77b73158f976]
Binary file "/usr/lib/libffi.so.8", at +0x413c [0x77b73158c13c]
Binary file "/usr/lib/libffi.so.8", at ffi_call+0x12e [0x77b73158ef0e]
Binary file "/opt/python/build/lib.linux-x86_64-3.14/_ctypes.cpython-314d-x86_64-linux-gnu.so", at +0x15a33 [0x77b7315e6a33]
Binary file "/opt/python/build/lib.linux-x86_64-3.14/_ctypes.cpython-314d-x86_64-linux-gnu.so", at +0x164fa [0x77b7315e74fa]
Binary file "/opt/python/build/lib.linux-x86_64-3.14/_ctypes.cpython-314d-x86_64-linux-gnu.so", at +0xc624 [0x77b7315dd624]
Binary file "/opt/python/build/lib.linux-x86_64-3.15/_ctypes.cpython-315d-x86_64-linux-gnu.so", at +0x15a33 [0x77b7315e6a33]
Binary file "/opt/python/build/lib.linux-x86_64-3.15/_ctypes.cpython-315d-x86_64-linux-gnu.so", at +0x164fa [0x77b7315e74fa]
Binary file "/opt/python/build/lib.linux-x86_64-3.15/_ctypes.cpython-315d-x86_64-linux-gnu.so", at +0xc624 [0x77b7315dd624]
Binary file "/opt/python/python", at _PyObject_MakeTpCall+0xce [0x5b27f7b73883]
Binary file "/opt/python/python", at +0x11bab6 [0x5b27f7b73ab6]
Binary file "/opt/python/python", at PyObject_Vectorcall+0x23 [0x5b27f7b73b04]

View file

@ -107,15 +107,15 @@ The module defines the following functions:
passed to the C :c:func:`fcntl` call. The return value after a successful
call is the contents of the buffer, converted to a :class:`bytes` object.
The length of the returned object will be the same as the length of the
*arg* argument. This is limited to 1024 bytes.
*arg* argument.
If the :c:func:`fcntl` call fails, an :exc:`OSError` is raised.
.. note::
If the type or the size of *arg* does not match the type or size
of the argument of the operation (for example, if an integer is
If the type or size of *arg* does not match the type or size
of the operation's argument (for example, if an integer is
passed when a pointer is expected, or the information returned in
the buffer by the operating system is larger than 1024 bytes),
the buffer by the operating system is larger than the size of *arg*),
this is most likely to result in a segmentation violation or
a more subtle data corruption.
@ -125,6 +125,9 @@ The module defines the following functions:
Add support of arbitrary :term:`bytes-like objects <bytes-like object>`,
not only :class:`bytes`.
.. versionchanged:: 3.15
The size of bytes-like objects is no longer limited to 1024 bytes.
.. function:: ioctl(fd, request, arg=0, mutate_flag=True, /)
@ -161,8 +164,7 @@ The module defines the following functions:
If the type or size of *arg* does not match the type or size
of the operation's argument (for example, if an integer is
passed when a pointer is expected, or the information returned in
the buffer by the operating system is larger than 1024 bytes,
or the size of the mutable bytes-like object is too small),
the buffer by the operating system is larger than the size of *arg*),
this is most likely to result in a segmentation violation or
a more subtle data corruption.
@ -185,6 +187,10 @@ The module defines the following functions:
The GIL is always released during a system call.
System calls failing with EINTR are automatically retried.
.. versionchanged:: 3.15
The size of not mutated bytes-like objects is no longer
limited to 1024 bytes.
.. function:: flock(fd, operation, /)
Perform the lock operation *operation* on file descriptor *fd* (file objects providing

View file

@ -292,7 +292,9 @@ are always available. They are listed here in alphabetical order.
:func:`property`.
.. function:: compile(source, filename, mode, flags=0, dont_inherit=False, optimize=-1)
.. function:: compile(source, filename, mode, flags=0, \
dont_inherit=False, optimize=-1, \
*, module=None)
Compile the *source* into a code or AST object. Code objects can be executed
by :func:`exec` or :func:`eval`. *source* can either be a normal string, a
@ -334,6 +336,10 @@ are always available. They are listed here in alphabetical order.
``__debug__`` is true), ``1`` (asserts are removed, ``__debug__`` is false)
or ``2`` (docstrings are removed too).
The optional argument *module* specifies the module name.
It is needed to unambiguous :ref:`filter <warning-filter>` syntax warnings
by module name.
This function raises :exc:`SyntaxError` if the compiled source is invalid,
and :exc:`ValueError` if the source contains null bytes.
@ -371,6 +377,9 @@ are always available. They are listed here in alphabetical order.
``ast.PyCF_ALLOW_TOP_LEVEL_AWAIT`` can now be passed in flags to enable
support for top-level ``await``, ``async for``, and ``async with``.
.. versionadded:: 3.15
Added the *module* parameter.
.. class:: complex(number=0, /)
complex(string, /)
@ -1419,38 +1428,10 @@ are always available. They are listed here in alphabetical order.
*errors* is an optional string that specifies how encoding and decoding
errors are to be handled—this cannot be used in binary mode.
A variety of standard error handlers are available
(listed under :ref:`error-handlers`), though any
error handling name that has been registered with
A variety of standard error handlers are available,
though any error handling name that has been registered with
:func:`codecs.register_error` is also valid. The standard names
include:
* ``'strict'`` to raise a :exc:`ValueError` exception if there is
an encoding error. The default value of ``None`` has the same
effect.
* ``'ignore'`` ignores errors. Note that ignoring encoding errors
can lead to data loss.
* ``'replace'`` causes a replacement marker (such as ``'?'``) to be inserted
where there is malformed data.
* ``'surrogateescape'`` will represent any incorrect bytes as low
surrogate code units ranging from U+DC80 to U+DCFF.
These surrogate code units will then be turned back into
the same bytes when the ``surrogateescape`` error handler is used
when writing data. This is useful for processing files in an
unknown encoding.
* ``'xmlcharrefreplace'`` is only supported when writing to a file.
Characters not supported by the encoding are replaced with the
appropriate XML character reference :samp:`&#{nnn};`.
* ``'backslashreplace'`` replaces malformed data by Python's backslashed
escape sequences.
* ``'namereplace'`` (also only supported when writing)
replaces unsupported characters with ``\N{...}`` escape sequences.
can be found in :ref:`error-handlers`.
.. index::
single: universal newlines; open() built-in function

View file

@ -57,6 +57,10 @@ The :mod:`functools` module defines the following functions:
another thread makes an additional call before the initial call has been
completed and cached.
Call-once behavior is not guaranteed because locks are not held during the
function call. Potentially another call with the same arguments could
occur while the first call is still running.
.. versionadded:: 3.9
@ -190,7 +194,7 @@ The :mod:`functools` module defines the following functions:
Note, type specificity applies only to the function's immediate arguments
rather than their contents. The scalar arguments, ``Decimal(42)`` and
``Fraction(42)`` are be treated as distinct calls with distinct results.
``Fraction(42)`` are treated as distinct calls with distinct results.
In contrast, the tuple arguments ``('answer', Decimal(42))`` and
``('answer', Fraction(42))`` are treated as equivalent.
@ -716,6 +720,9 @@ The :mod:`functools` module defines the following functions:
.. versionadded:: 3.8
.. versionchanged:: 3.15
Added support of non-:term:`descriptor` callables.
.. function:: update_wrapper(wrapper, wrapped, assigned=WRAPPER_ASSIGNMENTS, updated=WRAPPER_UPDATES)

View file

@ -108,10 +108,19 @@ The :mod:`gc` module provides the following functions:
* ``uncollectable`` is the total number of objects which were found
to be uncollectable (and were therefore moved to the :data:`garbage`
list) inside this generation.
list) inside this generation;
* ``candidates`` is the total number of objects in this generation which were
considered for collection and traversed;
* ``duration`` is the total time in seconds spent in collections for this
generation.
.. versionadded:: 3.4
.. versionchanged:: next
Add ``duration`` and ``candidates``.
.. function:: set_threshold(threshold0, [threshold1, [threshold2]])
@ -140,7 +149,7 @@ The :mod:`gc` module provides the following functions:
*threshold2* is ignored.
See `Garbage collector design <https://github.com/python/cpython/blob/3.14/InternalDocs/garbage_collector.md>`_ for more information.
See `Garbage collector design <https://devguide.python.org/garbage_collector>`_ for more information.
.. versionchanged:: 3.14
*threshold2* is ignored
@ -313,6 +322,12 @@ values but should not rebind them):
"uncollectable": When *phase* is "stop", the number of objects
that could not be collected and were put in :data:`garbage`.
"candidates": When *phase* is "stop", the total number of objects in this
generation which were considered for collection and traversed.
"duration": When *phase* is "stop", the time in seconds spent in the
collection.
Applications can add their own callbacks to this list. The primary
use cases are:
@ -325,6 +340,9 @@ values but should not rebind them):
.. versionadded:: 3.3
.. versionchanged:: next
Add "duration" and "candidates".
The following constants are provided for use with :func:`set_debug`:

View file

@ -28,7 +28,7 @@ Note that additional file formats which can be decompressed by the
The module defines the following items:
.. function:: open(filename, mode='rb', compresslevel=9, encoding=None, errors=None, newline=None)
.. function:: open(filename, mode='rb', compresslevel=6, encoding=None, errors=None, newline=None)
Open a gzip-compressed file in binary or text mode, returning a :term:`file
object`.
@ -61,6 +61,11 @@ The module defines the following items:
.. versionchanged:: 3.6
Accepts a :term:`path-like object`.
.. versionchanged:: 3.15
The default compression level was reduced to 6 (down from 9).
It is the default level used by most compression tools and a better
tradeoff between speed and performance.
.. exception:: BadGzipFile
An exception raised for invalid gzip files. It inherits from :exc:`OSError`.
@ -69,7 +74,7 @@ The module defines the following items:
.. versionadded:: 3.8
.. class:: GzipFile(filename=None, mode=None, compresslevel=9, fileobj=None, mtime=None)
.. class:: GzipFile(filename=None, mode=None, compresslevel=6, fileobj=None, mtime=None)
Constructor for the :class:`GzipFile` class, which simulates most of the
methods of a :term:`file object`, with the exception of the :meth:`~io.IOBase.truncate`
@ -183,8 +188,13 @@ The module defines the following items:
Remove the ``filename`` attribute, use the :attr:`~GzipFile.name`
attribute instead.
.. versionchanged:: 3.15
The default compression level was reduced to 6 (down from 9).
It is the default level used by most compression tools and a better
tradeoff between speed and performance.
.. function:: compress(data, compresslevel=9, *, mtime=0)
.. function:: compress(data, compresslevel=6, *, mtime=0)
Compress the *data*, returning a :class:`bytes` object containing
the compressed data. *compresslevel* and *mtime* have the same meaning as in
@ -208,6 +218,10 @@ The module defines the following items:
The *mtime* parameter now defaults to 0 for reproducible output.
For the previous behaviour of using the current time,
pass ``None`` to *mtime*.
.. versionchanged:: 3.15
The default compression level was reduced to 6 (down from 9).
It is the default level used by most compression tools and a better
tradeoff between speed and performance.
.. function:: decompress(data)

View file

@ -94,6 +94,13 @@ accessible by name via :func:`new`. See :data:`algorithms_available`.
OpenSSL does not provide we fall back to a verified implementation from
the `HACL\* project`_.
.. deprecated-removed:: 3.15 3.19
The undocumented ``string`` keyword parameter in :func:`!_hashlib.new`
and hash-named constructors such as :func:`!_md5.md5` is deprecated.
Prefer passing the initial data as a positional argument for maximum
backwards compatibility.
Usage
-----

View file

@ -0,0 +1,211 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="89.9 70 450.78 193.82">
<defs>
<g>
<g id="glyph-0-0">
<path d="M 4.578125 -3.1875 C 4.578125 -3.984375 4.53125 -4.78125 4.1875 -5.515625 C 3.734375 -6.484375 2.90625 -6.640625 2.5 -6.640625 C 1.890625 -6.640625 1.171875 -6.375 0.75 -5.453125 C 0.4375 -4.765625 0.390625 -3.984375 0.390625 -3.1875 C 0.390625 -2.4375 0.421875 -1.546875 0.84375 -0.78125 C 1.265625 0.015625 2 0.21875 2.484375 0.21875 C 3.015625 0.21875 3.78125 0.015625 4.21875 -0.9375 C 4.53125 -1.625 4.578125 -2.40625 4.578125 -3.1875 Z M 2.484375 0 C 2.09375 0 1.5 -0.25 1.328125 -1.203125 C 1.21875 -1.796875 1.21875 -2.71875 1.21875 -3.3125 C 1.21875 -3.953125 1.21875 -4.609375 1.296875 -5.140625 C 1.484375 -6.328125 2.234375 -6.421875 2.484375 -6.421875 C 2.8125 -6.421875 3.46875 -6.234375 3.65625 -5.25 C 3.765625 -4.6875 3.765625 -3.9375 3.765625 -3.3125 C 3.765625 -2.5625 3.765625 -1.890625 3.65625 -1.25 C 3.5 -0.296875 2.9375 0 2.484375 0 Z M 2.484375 0 "/>
</g>
<g id="glyph-0-1">
<path d="M 2.9375 -6.375 C 2.9375 -6.625 2.9375 -6.640625 2.703125 -6.640625 C 2.078125 -6 1.203125 -6 0.890625 -6 L 0.890625 -5.6875 C 1.09375 -5.6875 1.671875 -5.6875 2.1875 -5.953125 L 2.1875 -0.78125 C 2.1875 -0.421875 2.15625 -0.3125 1.265625 -0.3125 L 0.953125 -0.3125 L 0.953125 0 C 1.296875 -0.03125 2.15625 -0.03125 2.5625 -0.03125 C 2.953125 -0.03125 3.828125 -0.03125 4.171875 0 L 4.171875 -0.3125 L 3.859375 -0.3125 C 2.953125 -0.3125 2.9375 -0.421875 2.9375 -0.78125 Z M 2.9375 -6.375 "/>
</g>
<g id="glyph-0-2">
<path d="M 2.890625 -3.515625 C 3.703125 -3.78125 4.28125 -4.46875 4.28125 -5.265625 C 4.28125 -6.078125 3.40625 -6.640625 2.453125 -6.640625 C 1.453125 -6.640625 0.6875 -6.046875 0.6875 -5.28125 C 0.6875 -4.953125 0.90625 -4.765625 1.203125 -4.765625 C 1.5 -4.765625 1.703125 -4.984375 1.703125 -5.28125 C 1.703125 -5.765625 1.234375 -5.765625 1.09375 -5.765625 C 1.390625 -6.265625 2.046875 -6.390625 2.40625 -6.390625 C 2.828125 -6.390625 3.375 -6.171875 3.375 -5.28125 C 3.375 -5.15625 3.34375 -4.578125 3.09375 -4.140625 C 2.796875 -3.65625 2.453125 -3.625 2.203125 -3.625 C 2.125 -3.609375 1.890625 -3.59375 1.8125 -3.59375 C 1.734375 -3.578125 1.671875 -3.5625 1.671875 -3.46875 C 1.671875 -3.359375 1.734375 -3.359375 1.90625 -3.359375 L 2.34375 -3.359375 C 3.15625 -3.359375 3.53125 -2.6875 3.53125 -1.703125 C 3.53125 -0.34375 2.84375 -0.0625 2.40625 -0.0625 C 1.96875 -0.0625 1.21875 -0.234375 0.875 -0.8125 C 1.21875 -0.765625 1.53125 -0.984375 1.53125 -1.359375 C 1.53125 -1.71875 1.265625 -1.921875 0.984375 -1.921875 C 0.734375 -1.921875 0.421875 -1.78125 0.421875 -1.34375 C 0.421875 -0.4375 1.34375 0.21875 2.4375 0.21875 C 3.65625 0.21875 4.5625 -0.6875 4.5625 -1.703125 C 4.5625 -2.515625 3.921875 -3.296875 2.890625 -3.515625 Z M 2.890625 -3.515625 "/>
</g>
<g id="glyph-0-3">
<path d="M 4.75 -6.078125 C 4.828125 -6.1875 4.828125 -6.203125 4.828125 -6.421875 L 2.40625 -6.421875 C 1.203125 -6.421875 1.171875 -6.546875 1.140625 -6.734375 L 0.890625 -6.734375 L 0.5625 -4.6875 L 0.8125 -4.6875 C 0.84375 -4.84375 0.921875 -5.46875 1.0625 -5.59375 C 1.125 -5.65625 1.90625 -5.65625 2.03125 -5.65625 L 4.09375 -5.65625 C 3.984375 -5.5 3.203125 -4.40625 2.984375 -4.078125 C 2.078125 -2.734375 1.75 -1.34375 1.75 -0.328125 C 1.75 -0.234375 1.75 0.21875 2.21875 0.21875 C 2.671875 0.21875 2.671875 -0.234375 2.671875 -0.328125 L 2.671875 -0.84375 C 2.671875 -1.390625 2.703125 -1.9375 2.78125 -2.46875 C 2.828125 -2.703125 2.953125 -3.5625 3.40625 -4.171875 Z M 4.75 -6.078125 "/>
</g>
<g id="glyph-0-4">
<path d="M 4.46875 -2 C 4.46875 -3.1875 3.65625 -4.1875 2.578125 -4.1875 C 2.109375 -4.1875 1.671875 -4.03125 1.3125 -3.671875 L 1.3125 -5.625 C 1.515625 -5.5625 1.84375 -5.5 2.15625 -5.5 C 3.390625 -5.5 4.09375 -6.40625 4.09375 -6.53125 C 4.09375 -6.59375 4.0625 -6.640625 3.984375 -6.640625 C 3.984375 -6.640625 3.953125 -6.640625 3.90625 -6.609375 C 3.703125 -6.515625 3.21875 -6.3125 2.546875 -6.3125 C 2.15625 -6.3125 1.6875 -6.390625 1.21875 -6.59375 C 1.140625 -6.625 1.125 -6.625 1.109375 -6.625 C 1 -6.625 1 -6.546875 1 -6.390625 L 1 -3.4375 C 1 -3.265625 1 -3.1875 1.140625 -3.1875 C 1.21875 -3.1875 1.234375 -3.203125 1.28125 -3.265625 C 1.390625 -3.421875 1.75 -3.96875 2.5625 -3.96875 C 3.078125 -3.96875 3.328125 -3.515625 3.40625 -3.328125 C 3.5625 -2.953125 3.59375 -2.578125 3.59375 -2.078125 C 3.59375 -1.71875 3.59375 -1.125 3.34375 -0.703125 C 3.109375 -0.3125 2.734375 -0.0625 2.28125 -0.0625 C 1.5625 -0.0625 0.984375 -0.59375 0.8125 -1.171875 C 0.84375 -1.171875 0.875 -1.15625 0.984375 -1.15625 C 1.3125 -1.15625 1.484375 -1.40625 1.484375 -1.640625 C 1.484375 -1.890625 1.3125 -2.140625 0.984375 -2.140625 C 0.84375 -2.140625 0.5 -2.0625 0.5 -1.609375 C 0.5 -0.75 1.1875 0.21875 2.296875 0.21875 C 3.453125 0.21875 4.46875 -0.734375 4.46875 -2 Z M 4.46875 -2 "/>
</g>
<g id="glyph-0-5">
<path d="M 1.3125 -3.265625 L 1.3125 -3.515625 C 1.3125 -6.03125 2.546875 -6.390625 3.0625 -6.390625 C 3.296875 -6.390625 3.71875 -6.328125 3.9375 -5.984375 C 3.78125 -5.984375 3.390625 -5.984375 3.390625 -5.546875 C 3.390625 -5.234375 3.625 -5.078125 3.84375 -5.078125 C 4 -5.078125 4.3125 -5.171875 4.3125 -5.5625 C 4.3125 -6.15625 3.875 -6.640625 3.046875 -6.640625 C 1.765625 -6.640625 0.421875 -5.359375 0.421875 -3.15625 C 0.421875 -0.484375 1.578125 0.21875 2.5 0.21875 C 3.609375 0.21875 4.5625 -0.71875 4.5625 -2.03125 C 4.5625 -3.296875 3.671875 -4.25 2.5625 -4.25 C 1.890625 -4.25 1.515625 -3.75 1.3125 -3.265625 Z M 2.5 -0.0625 C 1.875 -0.0625 1.578125 -0.65625 1.515625 -0.8125 C 1.328125 -1.28125 1.328125 -2.078125 1.328125 -2.25 C 1.328125 -3.03125 1.65625 -4.03125 2.546875 -4.03125 C 2.71875 -4.03125 3.171875 -4.03125 3.484375 -3.40625 C 3.65625 -3.046875 3.65625 -2.53125 3.65625 -2.046875 C 3.65625 -1.5625 3.65625 -1.0625 3.484375 -0.703125 C 3.1875 -0.109375 2.734375 -0.0625 2.5 -0.0625 Z M 2.5 -0.0625 "/>
</g>
<g id="glyph-0-6">
<path d="M 1.625 -4.5625 C 1.171875 -4.859375 1.125 -5.1875 1.125 -5.359375 C 1.125 -5.96875 1.78125 -6.390625 2.484375 -6.390625 C 3.203125 -6.390625 3.84375 -5.875 3.84375 -5.15625 C 3.84375 -4.578125 3.453125 -4.109375 2.859375 -3.765625 Z M 3.078125 -3.609375 C 3.796875 -3.984375 4.28125 -4.5 4.28125 -5.15625 C 4.28125 -6.078125 3.40625 -6.640625 2.5 -6.640625 C 1.5 -6.640625 0.6875 -5.90625 0.6875 -4.96875 C 0.6875 -4.796875 0.703125 -4.34375 1.125 -3.875 C 1.234375 -3.765625 1.609375 -3.515625 1.859375 -3.34375 C 1.28125 -3.046875 0.421875 -2.5 0.421875 -1.5 C 0.421875 -0.453125 1.4375 0.21875 2.484375 0.21875 C 3.609375 0.21875 4.5625 -0.609375 4.5625 -1.671875 C 4.5625 -2.03125 4.453125 -2.484375 4.0625 -2.90625 C 3.875 -3.109375 3.71875 -3.203125 3.078125 -3.609375 Z M 2.078125 -3.1875 L 3.3125 -2.40625 C 3.59375 -2.21875 4.0625 -1.921875 4.0625 -1.3125 C 4.0625 -0.578125 3.3125 -0.0625 2.5 -0.0625 C 1.640625 -0.0625 0.921875 -0.671875 0.921875 -1.5 C 0.921875 -2.078125 1.234375 -2.71875 2.078125 -3.1875 Z M 2.078125 -3.1875 "/>
</g>
<g id="glyph-0-7">
<path d="M 2.9375 -1.640625 L 2.9375 -0.78125 C 2.9375 -0.421875 2.90625 -0.3125 2.171875 -0.3125 L 1.96875 -0.3125 L 1.96875 0 C 2.375 -0.03125 2.890625 -0.03125 3.3125 -0.03125 C 3.734375 -0.03125 4.25 -0.03125 4.671875 0 L 4.671875 -0.3125 L 4.453125 -0.3125 C 3.71875 -0.3125 3.703125 -0.421875 3.703125 -0.78125 L 3.703125 -1.640625 L 4.6875 -1.640625 L 4.6875 -1.953125 L 3.703125 -1.953125 L 3.703125 -6.484375 C 3.703125 -6.6875 3.703125 -6.75 3.53125 -6.75 C 3.453125 -6.75 3.421875 -6.75 3.34375 -6.625 L 0.28125 -1.953125 L 0.28125 -1.640625 Z M 2.984375 -1.953125 L 0.5625 -1.953125 L 2.984375 -5.671875 Z M 2.984375 -1.953125 "/>
</g>
<g id="glyph-0-8">
<path d="M 3.65625 -3.171875 L 3.65625 -2.84375 C 3.65625 -0.515625 2.625 -0.0625 2.046875 -0.0625 C 1.875 -0.0625 1.328125 -0.078125 1.0625 -0.421875 C 1.5 -0.421875 1.578125 -0.703125 1.578125 -0.875 C 1.578125 -1.1875 1.34375 -1.328125 1.125 -1.328125 C 0.96875 -1.328125 0.671875 -1.25 0.671875 -0.859375 C 0.671875 -0.1875 1.203125 0.21875 2.046875 0.21875 C 3.34375 0.21875 4.5625 -1.140625 4.5625 -3.28125 C 4.5625 -5.96875 3.40625 -6.640625 2.515625 -6.640625 C 1.96875 -6.640625 1.484375 -6.453125 1.0625 -6.015625 C 0.640625 -5.5625 0.421875 -5.140625 0.421875 -4.390625 C 0.421875 -3.15625 1.296875 -2.171875 2.40625 -2.171875 C 3.015625 -2.171875 3.421875 -2.59375 3.65625 -3.171875 Z M 2.421875 -2.40625 C 2.265625 -2.40625 1.796875 -2.40625 1.5 -3.03125 C 1.3125 -3.40625 1.3125 -3.890625 1.3125 -4.390625 C 1.3125 -4.921875 1.3125 -5.390625 1.53125 -5.765625 C 1.796875 -6.265625 2.171875 -6.390625 2.515625 -6.390625 C 2.984375 -6.390625 3.3125 -6.046875 3.484375 -5.609375 C 3.59375 -5.28125 3.640625 -4.65625 3.640625 -4.203125 C 3.640625 -3.375 3.296875 -2.40625 2.421875 -2.40625 Z M 2.421875 -2.40625 "/>
</g>
<g id="glyph-0-9">
<path d="M 1.265625 -0.765625 L 2.328125 -1.796875 C 3.875 -3.171875 4.46875 -3.703125 4.46875 -4.703125 C 4.46875 -5.84375 3.578125 -6.640625 2.359375 -6.640625 C 1.234375 -6.640625 0.5 -5.71875 0.5 -4.828125 C 0.5 -4.28125 1 -4.28125 1.03125 -4.28125 C 1.203125 -4.28125 1.546875 -4.390625 1.546875 -4.8125 C 1.546875 -5.0625 1.359375 -5.328125 1.015625 -5.328125 C 0.9375 -5.328125 0.921875 -5.328125 0.890625 -5.3125 C 1.109375 -5.96875 1.65625 -6.328125 2.234375 -6.328125 C 3.140625 -6.328125 3.5625 -5.515625 3.5625 -4.703125 C 3.5625 -3.90625 3.078125 -3.125 2.515625 -2.5 L 0.609375 -0.375 C 0.5 -0.265625 0.5 -0.234375 0.5 0 L 4.203125 0 L 4.46875 -1.734375 L 4.234375 -1.734375 C 4.171875 -1.4375 4.109375 -1 4 -0.84375 C 3.9375 -0.765625 3.28125 -0.765625 3.0625 -0.765625 Z M 1.265625 -0.765625 "/>
</g>
</g>
</defs>
<path fill-rule="nonzero" fill="rgb(79.998779%, 79.998779%, 100%)" fill-opacity="1" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 100%)" stroke-opacity="1" stroke-miterlimit="10" d="M 8.754781 -0.000125 C 8.754781 4.835813 4.832906 8.753781 0.000875 8.753781 C -4.835062 8.753781 -8.753031 4.835813 -8.753031 -0.000125 C -8.753031 -4.836062 -4.835062 -8.754031 0.000875 -8.754031 C 4.832906 -8.754031 8.754781 -4.836062 8.754781 -0.000125 Z M 8.754781 -0.000125 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<g fill="rgb(0%, 0%, 0%)" fill-opacity="1">
<use xlink:href="#glyph-0-0" x="312.806" y="84.163"/>
</g>
<path fill-rule="nonzero" fill="rgb(79.998779%, 79.998779%, 100%)" fill-opacity="1" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 100%)" stroke-opacity="1" stroke-miterlimit="10" d="M -104.635844 -42.519656 C -104.635844 -37.687625 -108.553812 -33.76575 -113.385844 -33.76575 C -118.221781 -33.76575 -122.13975 -37.687625 -122.13975 -42.519656 C -122.13975 -47.355594 -118.221781 -51.273562 -113.385844 -51.273562 C -108.553812 -51.273562 -104.635844 -47.355594 -104.635844 -42.519656 Z M -104.635844 -42.519656 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<g fill="rgb(0%, 0%, 0%)" fill-opacity="1">
<use xlink:href="#glyph-0-1" x="199.42" y="126.682"/>
</g>
<path fill="none" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 0%)" stroke-opacity="1" stroke-miterlimit="10" d="M -8.381937 -3.144656 L -105.006937 -39.375125 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<path fill-rule="nonzero" fill="rgb(79.998779%, 79.998779%, 100%)" fill-opacity="1" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 100%)" stroke-opacity="1" stroke-miterlimit="10" d="M -161.32725 -85.039187 C -161.32725 -80.207156 -165.245219 -76.289187 -170.081156 -76.289187 C -174.917094 -76.289187 -178.835062 -80.207156 -178.835062 -85.039187 C -178.835062 -89.875125 -174.917094 -93.793094 -170.081156 -93.793094 C -165.245219 -93.793094 -161.32725 -89.875125 -161.32725 -85.039187 Z M -161.32725 -85.039187 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<g fill="rgb(0%, 0%, 0%)" fill-opacity="1">
<use xlink:href="#glyph-0-2" x="142.727" y="169.202"/>
</g>
<path fill="none" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 0%)" stroke-opacity="1" stroke-miterlimit="10" d="M -120.549906 -47.89075 L -162.921 -79.668094 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<path fill-rule="nonzero" fill="rgb(79.998779%, 79.998779%, 100%)" fill-opacity="1" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 100%)" stroke-opacity="1" stroke-miterlimit="10" d="M -189.674906 -127.558719 C -189.674906 -122.726687 -193.592875 -118.808719 -198.428812 -118.808719 C -203.260844 -118.808719 -207.182719 -122.726687 -207.182719 -127.558719 C -207.182719 -132.394656 -203.260844 -136.312625 -198.428812 -136.312625 C -193.592875 -136.312625 -189.674906 -132.394656 -189.674906 -127.558719 Z M -189.674906 -127.558719 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<g fill="rgb(0%, 0%, 0%)" fill-opacity="1">
<use xlink:href="#glyph-0-3" x="114.38" y="211.722"/>
</g>
<path fill="none" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 0%)" stroke-opacity="1" stroke-miterlimit="10" d="M -175.046 -92.488406 L -193.463969 -120.113406 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<path fill-rule="nonzero" fill="rgb(79.998779%, 79.998779%, 100%)" fill-opacity="1" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 100%)" stroke-opacity="1" stroke-miterlimit="10" d="M -202.026469 -170.082156 C -202.026469 -164.242312 -206.760844 -159.507937 -212.600687 -159.507937 C -218.440531 -159.507937 -223.174906 -164.242312 -223.174906 -170.082156 C -223.174906 -175.922 -218.440531 -180.652469 -212.600687 -180.652469 C -206.760844 -180.652469 -202.026469 -175.922 -202.026469 -170.082156 Z M -202.026469 -170.082156 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<g fill="rgb(0%, 0%, 0%)" fill-opacity="1">
<use xlink:href="#glyph-0-1" x="97.717" y="254.241"/>
<use xlink:href="#glyph-0-4" x="102.6983" y="254.241"/>
</g>
<path fill="none" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 0%)" stroke-opacity="1" stroke-miterlimit="10" d="M -201.256937 -136.054812 L -209.194437 -159.8595 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<path fill-rule="nonzero" fill="rgb(79.998779%, 79.998779%, 100%)" fill-opacity="1" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 100%)" stroke-opacity="1" stroke-miterlimit="10" d="M -173.678812 -170.082156 C -173.678812 -164.242312 -178.413187 -159.507937 -184.253031 -159.507937 C -190.092875 -159.507937 -194.82725 -164.242312 -194.82725 -170.082156 C -194.82725 -175.922 -190.092875 -180.652469 -184.253031 -180.652469 C -178.413187 -180.652469 -173.678812 -175.922 -173.678812 -170.082156 Z M -173.678812 -170.082156 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<g fill="rgb(0%, 0%, 0%)" fill-opacity="1">
<use xlink:href="#glyph-0-1" x="126.063" y="254.241"/>
<use xlink:href="#glyph-0-5" x="131.0443" y="254.241"/>
</g>
<path fill="none" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 0%)" stroke-opacity="1" stroke-miterlimit="10" d="M -195.596781 -136.054812 L -187.659281 -159.8595 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<path fill-rule="nonzero" fill="rgb(79.998779%, 79.998779%, 100%)" fill-opacity="1" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 100%)" stroke-opacity="1" stroke-miterlimit="10" d="M -132.979594 -127.558719 C -132.979594 -122.726687 -136.901469 -118.808719 -141.7335 -118.808719 C -146.569437 -118.808719 -150.487406 -122.726687 -150.487406 -127.558719 C -150.487406 -132.394656 -146.569437 -136.312625 -141.7335 -136.312625 C -136.901469 -136.312625 -132.979594 -132.394656 -132.979594 -127.558719 Z M -132.979594 -127.558719 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<g fill="rgb(0%, 0%, 0%)" fill-opacity="1">
<use xlink:href="#glyph-0-6" x="171.073" y="211.722"/>
</g>
<path fill="none" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 0%)" stroke-opacity="1" stroke-miterlimit="10" d="M -165.116312 -92.488406 L -146.698344 -120.113406 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<path fill-rule="nonzero" fill="rgb(79.998779%, 79.998779%, 100%)" fill-opacity="1" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 100%)" stroke-opacity="1" stroke-miterlimit="10" d="M -145.335062 -170.082156 C -145.335062 -164.242312 -150.069437 -159.507937 -155.909281 -159.507937 C -161.745219 -159.507937 -166.479594 -164.242312 -166.479594 -170.082156 C -166.479594 -175.922 -161.745219 -180.652469 -155.909281 -180.652469 C -150.069437 -180.652469 -145.335062 -175.922 -145.335062 -170.082156 Z M -145.335062 -170.082156 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<g fill="rgb(0%, 0%, 0%)" fill-opacity="1">
<use xlink:href="#glyph-0-1" x="154.409" y="254.241"/>
<use xlink:href="#glyph-0-3" x="159.3903" y="254.241"/>
</g>
<path fill="none" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 0%)" stroke-opacity="1" stroke-miterlimit="10" d="M -144.565531 -136.054812 L -152.499125 -159.8595 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<path fill-rule="nonzero" fill="rgb(79.998779%, 79.998779%, 100%)" fill-opacity="1" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 100%)" stroke-opacity="1" stroke-miterlimit="10" d="M -116.987406 -170.082156 C -116.987406 -164.242312 -121.721781 -159.507937 -127.561625 -159.507937 C -133.401469 -159.507937 -138.135844 -164.242312 -138.135844 -170.082156 C -138.135844 -175.922 -133.401469 -180.652469 -127.561625 -180.652469 C -121.721781 -180.652469 -116.987406 -175.922 -116.987406 -170.082156 Z M -116.987406 -170.082156 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<g fill="rgb(0%, 0%, 0%)" fill-opacity="1">
<use xlink:href="#glyph-0-1" x="182.756" y="254.241"/>
<use xlink:href="#glyph-0-6" x="187.7373" y="254.241"/>
</g>
<path fill="none" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 0%)" stroke-opacity="1" stroke-miterlimit="10" d="M -138.901469 -136.054812 L -130.967875 -159.8595 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<path fill-rule="nonzero" fill="rgb(79.998779%, 79.998779%, 100%)" fill-opacity="1" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 100%)" stroke-opacity="1" stroke-miterlimit="10" d="M -47.940531 -85.039187 C -47.940531 -80.207156 -51.8585 -76.289187 -56.694437 -76.289187 C -61.526469 -76.289187 -65.448344 -80.207156 -65.448344 -85.039187 C -65.448344 -89.875125 -61.526469 -93.793094 -56.694437 -93.793094 C -51.8585 -93.793094 -47.940531 -89.875125 -47.940531 -85.039187 Z M -47.940531 -85.039187 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<g fill="rgb(0%, 0%, 0%)" fill-opacity="1">
<use xlink:href="#glyph-0-7" x="256.113" y="169.202"/>
</g>
<path fill="none" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 0%)" stroke-opacity="1" stroke-miterlimit="10" d="M -106.225687 -47.89075 L -63.854594 -79.668094 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<path fill-rule="nonzero" fill="rgb(79.998779%, 79.998779%, 100%)" fill-opacity="1" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 100%)" stroke-opacity="1" stroke-miterlimit="10" d="M -76.288187 -127.558719 C -76.288187 -122.726687 -80.206156 -118.808719 -85.042094 -118.808719 C -89.874125 -118.808719 -93.792094 -122.726687 -93.792094 -127.558719 C -93.792094 -132.394656 -89.874125 -136.312625 -85.042094 -136.312625 C -80.206156 -136.312625 -76.288187 -132.394656 -76.288187 -127.558719 Z M -76.288187 -127.558719 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<g fill="rgb(0%, 0%, 0%)" fill-opacity="1">
<use xlink:href="#glyph-0-8" x="227.766" y="211.722"/>
</g>
<path fill="none" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 0%)" stroke-opacity="1" stroke-miterlimit="10" d="M -61.659281 -92.488406 L -80.073344 -120.113406 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<path fill-rule="nonzero" fill="rgb(79.998779%, 79.998779%, 100%)" fill-opacity="1" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 100%)" stroke-opacity="1" stroke-miterlimit="10" d="M -88.63975 -170.082156 C -88.63975 -164.242312 -93.374125 -159.507937 -99.213969 -159.507937 C -105.053812 -159.507937 -109.788187 -164.242312 -109.788187 -170.082156 C -109.788187 -175.922 -105.053812 -180.652469 -99.213969 -180.652469 C -93.374125 -180.652469 -88.63975 -175.922 -88.63975 -170.082156 Z M -88.63975 -170.082156 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<g fill="rgb(0%, 0%, 0%)" fill-opacity="1">
<use xlink:href="#glyph-0-1" x="211.102" y="254.241"/>
<use xlink:href="#glyph-0-8" x="216.0833" y="254.241"/>
</g>
<path fill="none" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 0%)" stroke-opacity="1" stroke-miterlimit="10" d="M -87.870219 -136.054812 L -95.807719 -159.8595 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<path fill-rule="nonzero" fill="rgb(79.998779%, 79.998779%, 100%)" fill-opacity="1" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 100%)" stroke-opacity="1" stroke-miterlimit="10" d="M -60.292094 -170.082156 C -60.292094 -164.242312 -65.026469 -159.507937 -70.866312 -159.507937 C -76.706156 -159.507937 -81.440531 -164.242312 -81.440531 -170.082156 C -81.440531 -175.922 -76.706156 -180.652469 -70.866312 -180.652469 C -65.026469 -180.652469 -60.292094 -175.922 -60.292094 -170.082156 Z M -60.292094 -170.082156 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<g fill="rgb(0%, 0%, 0%)" fill-opacity="1">
<use xlink:href="#glyph-0-9" x="239.449" y="254.241"/>
<use xlink:href="#glyph-0-0" x="244.4303" y="254.241"/>
</g>
<path fill="none" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 0%)" stroke-opacity="1" stroke-miterlimit="10" d="M -82.210062 -136.054812 L -74.272562 -159.8595 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<path fill-rule="nonzero" fill="rgb(79.998779%, 79.998779%, 100%)" fill-opacity="1" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 100%)" stroke-opacity="1" stroke-miterlimit="10" d="M -17.772562 -127.558719 C -17.772562 -121.722781 -22.506937 -116.988406 -28.346781 -116.988406 C -34.186625 -116.988406 -38.921 -121.722781 -38.921 -127.558719 C -38.921 -133.398562 -34.186625 -138.132937 -28.346781 -138.132937 C -22.506937 -138.132937 -17.772562 -133.398562 -17.772562 -127.558719 Z M -17.772562 -127.558719 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<g fill="rgb(0%, 0%, 0%)" fill-opacity="1">
<use xlink:href="#glyph-0-1" x="281.968" y="211.722"/>
<use xlink:href="#glyph-0-0" x="286.9493" y="211.722"/>
</g>
<path fill="none" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 0%)" stroke-opacity="1" stroke-miterlimit="10" d="M -51.729594 -92.488406 L -34.323344 -118.597781 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<path fill-rule="nonzero" fill="rgb(79.998779%, 79.998779%, 100%)" fill-opacity="1" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 100%)" stroke-opacity="1" stroke-miterlimit="10" d="M -31.948344 -170.082156 C -31.948344 -164.242312 -36.678812 -159.507937 -42.518656 -159.507937 C -48.3585 -159.507937 -53.092875 -164.242312 -53.092875 -170.082156 C -53.092875 -175.922 -48.3585 -180.652469 -42.518656 -180.652469 C -36.678812 -180.652469 -31.948344 -175.922 -31.948344 -170.082156 Z M -31.948344 -170.082156 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<g fill="rgb(0%, 0%, 0%)" fill-opacity="1">
<use xlink:href="#glyph-0-9" x="267.795" y="254.241"/>
<use xlink:href="#glyph-0-1" x="272.7763" y="254.241"/>
</g>
<path fill="none" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 0%)" stroke-opacity="1" stroke-miterlimit="10" d="M -31.753031 -137.781375 L -39.112406 -159.8595 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<path fill-rule="nonzero" fill="rgb(79.998779%, 79.998779%, 100%)" fill-opacity="1" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 100%)" stroke-opacity="1" stroke-miterlimit="10" d="M -3.600687 -170.082156 C -3.600687 -164.242312 -8.335062 -159.507937 -14.174906 -159.507937 C -20.01475 -159.507937 -24.745219 -164.242312 -24.745219 -170.082156 C -24.745219 -175.922 -20.01475 -180.652469 -14.174906 -180.652469 C -8.335062 -180.652469 -3.600687 -175.922 -3.600687 -170.082156 Z M -3.600687 -170.082156 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<g fill="rgb(0%, 0%, 0%)" fill-opacity="1">
<use xlink:href="#glyph-0-9" x="296.142" y="254.241"/>
<use xlink:href="#glyph-0-9" x="301.1233" y="254.241"/>
</g>
<path fill="none" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 0%)" stroke-opacity="1" stroke-miterlimit="10" d="M -24.940531 -137.781375 L -17.581156 -159.8595 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<path fill-rule="nonzero" fill="rgb(79.998779%, 79.998779%, 100%)" fill-opacity="1" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 100%)" stroke-opacity="1" stroke-miterlimit="10" d="M 122.1415 -42.519656 C 122.1415 -37.687625 118.223531 -33.76575 113.387594 -33.76575 C 108.551656 -33.76575 104.633688 -37.687625 104.633688 -42.519656 C 104.633688 -47.355594 108.551656 -51.273562 113.387594 -51.273562 C 118.223531 -51.273562 122.1415 -47.355594 122.1415 -42.519656 Z M 122.1415 -42.519656 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<g fill="rgb(0%, 0%, 0%)" fill-opacity="1">
<use xlink:href="#glyph-0-9" x="426.191" y="126.682"/>
</g>
<path fill="none" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 0%)" stroke-opacity="1" stroke-miterlimit="10" d="M 8.383688 -3.144656 L 105.004781 -39.375125 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<path fill-rule="nonzero" fill="rgb(79.998779%, 79.998779%, 100%)" fill-opacity="1" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 100%)" stroke-opacity="1" stroke-miterlimit="10" d="M 65.446188 -85.039187 C 65.446188 -80.207156 61.528219 -76.289187 56.692281 -76.289187 C 51.86025 -76.289187 47.942281 -80.207156 47.942281 -85.039187 C 47.942281 -89.875125 51.86025 -93.793094 56.692281 -93.793094 C 61.528219 -93.793094 65.446188 -89.875125 65.446188 -85.039187 Z M 65.446188 -85.039187 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<g fill="rgb(0%, 0%, 0%)" fill-opacity="1">
<use xlink:href="#glyph-0-4" x="369.498" y="169.202"/>
</g>
<path fill="none" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 0%)" stroke-opacity="1" stroke-miterlimit="10" d="M 106.227438 -47.89075 L 63.856344 -79.668094 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<path fill-rule="nonzero" fill="rgb(79.998779%, 79.998779%, 100%)" fill-opacity="1" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 100%)" stroke-opacity="1" stroke-miterlimit="10" d="M 38.918844 -127.558719 C 38.918844 -121.722781 34.188375 -116.988406 28.348531 -116.988406 C 22.508688 -116.988406 17.774313 -121.722781 17.774313 -127.558719 C 17.774313 -133.398562 22.508688 -138.132937 28.348531 -138.132937 C 34.188375 -138.132937 38.918844 -133.398562 38.918844 -127.558719 Z M 38.918844 -127.558719 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<g fill="rgb(0%, 0%, 0%)" fill-opacity="1">
<use xlink:href="#glyph-0-1" x="338.661" y="211.722"/>
<use xlink:href="#glyph-0-1" x="343.6423" y="211.722"/>
</g>
<path fill="none" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 0%)" stroke-opacity="1" stroke-miterlimit="10" d="M 51.727438 -92.488406 L 34.321188 -118.597781 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<path fill-rule="nonzero" fill="rgb(79.998779%, 79.998779%, 100%)" fill-opacity="1" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 100%)" stroke-opacity="1" stroke-miterlimit="10" d="M 24.746969 -170.082156 C 24.746969 -164.242312 20.012594 -159.507937 14.17275 -159.507937 C 8.332906 -159.507937 3.598531 -164.242312 3.598531 -170.082156 C 3.598531 -175.922 8.332906 -180.652469 14.17275 -180.652469 C 20.012594 -180.652469 24.746969 -175.922 24.746969 -170.082156 Z M 24.746969 -170.082156 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<g fill="rgb(0%, 0%, 0%)" fill-opacity="1">
<use xlink:href="#glyph-0-9" x="324.488" y="254.241"/>
<use xlink:href="#glyph-0-2" x="329.4693" y="254.241"/>
</g>
<path fill="none" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 0%)" stroke-opacity="1" stroke-miterlimit="10" d="M 24.942281 -137.781375 L 17.579 -159.8595 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<path fill-rule="nonzero" fill="rgb(79.998779%, 79.998779%, 100%)" fill-opacity="1" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 100%)" stroke-opacity="1" stroke-miterlimit="10" d="M 53.094625 -170.082156 C 53.094625 -164.242312 48.36025 -159.507937 42.520406 -159.507937 C 36.680563 -159.507937 31.946188 -164.242312 31.946188 -170.082156 C 31.946188 -175.922 36.680563 -180.652469 42.520406 -180.652469 C 48.36025 -180.652469 53.094625 -175.922 53.094625 -170.082156 Z M 53.094625 -170.082156 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<g fill="rgb(0%, 0%, 0%)" fill-opacity="1">
<use xlink:href="#glyph-0-9" x="352.835" y="254.241"/>
<use xlink:href="#glyph-0-7" x="357.8163" y="254.241"/>
</g>
<path fill="none" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 0%)" stroke-opacity="1" stroke-miterlimit="10" d="M 31.754781 -137.781375 L 39.114156 -159.8595 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<path fill-rule="nonzero" fill="rgb(79.998779%, 79.998779%, 100%)" fill-opacity="1" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 100%)" stroke-opacity="1" stroke-miterlimit="10" d="M 95.614156 -127.558719 C 95.614156 -121.722781 90.879781 -116.988406 85.039938 -116.988406 C 79.200094 -116.988406 74.465719 -121.722781 74.465719 -127.558719 C 74.465719 -133.398562 79.200094 -138.132937 85.039938 -138.132937 C 90.879781 -138.132937 95.614156 -133.398562 95.614156 -127.558719 Z M 95.614156 -127.558719 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<g fill="rgb(0%, 0%, 0%)" fill-opacity="1">
<use xlink:href="#glyph-0-1" x="395.354" y="211.722"/>
<use xlink:href="#glyph-0-9" x="400.3353" y="211.722"/>
</g>
<path fill="none" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 0%)" stroke-opacity="1" stroke-miterlimit="10" d="M 61.661031 -92.488406 L 79.063375 -118.597781 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<path fill-rule="nonzero" fill="rgb(79.998779%, 79.998779%, 100%)" fill-opacity="1" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 100%)" stroke-opacity="1" stroke-miterlimit="10" d="M 81.442281 -170.082156 C 81.442281 -164.242312 76.707906 -159.507937 70.868063 -159.507937 C 65.028219 -159.507937 60.293844 -164.242312 60.293844 -170.082156 C 60.293844 -175.922 65.028219 -180.652469 70.868063 -180.652469 C 76.707906 -180.652469 81.442281 -175.922 81.442281 -170.082156 Z M 81.442281 -170.082156 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<g fill="rgb(0%, 0%, 0%)" fill-opacity="1">
<use xlink:href="#glyph-0-9" x="381.181" y="254.241"/>
<use xlink:href="#glyph-0-4" x="386.1623" y="254.241"/>
</g>
<path fill="none" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 0%)" stroke-opacity="1" stroke-miterlimit="10" d="M 81.633688 -137.781375 L 74.274313 -159.8595 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<path fill-rule="nonzero" fill="rgb(79.998779%, 79.998779%, 100%)" fill-opacity="1" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 100%)" stroke-opacity="1" stroke-miterlimit="10" d="M 109.786031 -170.082156 C 109.786031 -164.242312 105.051656 -159.507937 99.215719 -159.507937 C 93.375875 -159.507937 88.6415 -164.242312 88.6415 -170.082156 C 88.6415 -175.922 93.375875 -180.652469 99.215719 -180.652469 C 105.051656 -180.652469 109.786031 -175.922 109.786031 -170.082156 Z M 109.786031 -170.082156 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<g fill="rgb(0%, 0%, 0%)" fill-opacity="1">
<use xlink:href="#glyph-0-9" x="409.527" y="254.241"/>
<use xlink:href="#glyph-0-5" x="414.5083" y="254.241"/>
</g>
<path fill="none" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 0%)" stroke-opacity="1" stroke-miterlimit="10" d="M 88.446188 -137.781375 L 95.805563 -159.8595 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<path fill-rule="nonzero" fill="rgb(79.998779%, 79.998779%, 100%)" fill-opacity="1" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 100%)" stroke-opacity="1" stroke-miterlimit="10" d="M 178.832906 -85.039187 C 178.832906 -80.207156 174.914938 -76.289187 170.079 -76.289187 C 165.246969 -76.289187 161.329 -80.207156 161.329 -85.039187 C 161.329 -89.875125 165.246969 -93.793094 170.079 -93.793094 C 174.914938 -93.793094 178.832906 -89.875125 178.832906 -85.039187 Z M 178.832906 -85.039187 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<g fill="rgb(0%, 0%, 0%)" fill-opacity="1">
<use xlink:href="#glyph-0-5" x="482.884" y="169.202"/>
</g>
<path fill="none" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 0%)" stroke-opacity="1" stroke-miterlimit="10" d="M 120.54775 -47.89075 L 162.918844 -79.668094 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<path fill-rule="nonzero" fill="rgb(79.998779%, 79.998779%, 100%)" fill-opacity="1" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 100%)" stroke-opacity="1" stroke-miterlimit="10" d="M 152.309469 -127.558719 C 152.309469 -121.722781 147.575094 -116.988406 141.73525 -116.988406 C 135.895406 -116.988406 131.161031 -121.722781 131.161031 -127.558719 C 131.161031 -133.398562 135.895406 -138.132937 141.73525 -138.132937 C 147.575094 -138.132937 152.309469 -133.398562 152.309469 -127.558719 Z M 152.309469 -127.558719 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<g fill="rgb(0%, 0%, 0%)" fill-opacity="1">
<use xlink:href="#glyph-0-1" x="452.047" y="211.722"/>
<use xlink:href="#glyph-0-2" x="457.0283" y="211.722"/>
</g>
<path fill="none" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 0%)" stroke-opacity="1" stroke-miterlimit="10" d="M 165.114156 -92.488406 L 147.707906 -118.597781 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<path fill-rule="nonzero" fill="rgb(79.998779%, 79.998779%, 100%)" fill-opacity="1" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 100%)" stroke-opacity="1" stroke-miterlimit="10" d="M 138.133688 -170.082156 C 138.133688 -164.242312 133.399313 -159.507937 127.559469 -159.507937 C 121.719625 -159.507937 116.989156 -164.242312 116.989156 -170.082156 C 116.989156 -175.922 121.719625 -180.652469 127.559469 -180.652469 C 133.399313 -180.652469 138.133688 -175.922 138.133688 -170.082156 Z M 138.133688 -170.082156 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<g fill="rgb(0%, 0%, 0%)" fill-opacity="1">
<use xlink:href="#glyph-0-9" x="437.874" y="254.241"/>
<use xlink:href="#glyph-0-3" x="442.8553" y="254.241"/>
</g>
<path fill="none" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 0%)" stroke-opacity="1" stroke-miterlimit="10" d="M 138.329 -137.781375 L 130.965719 -159.8595 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<path fill-rule="nonzero" fill="rgb(79.998779%, 79.998779%, 100%)" fill-opacity="1" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 100%)" stroke-opacity="1" stroke-miterlimit="10" d="M 166.481344 -170.082156 C 166.481344 -164.242312 161.746969 -159.507937 155.907125 -159.507937 C 150.067281 -159.507937 145.332906 -164.242312 145.332906 -170.082156 C 145.332906 -175.922 150.067281 -180.652469 155.907125 -180.652469 C 161.746969 -180.652469 166.481344 -175.922 166.481344 -170.082156 Z M 166.481344 -170.082156 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<g fill="rgb(0%, 0%, 0%)" fill-opacity="1">
<use xlink:href="#glyph-0-9" x="466.22" y="254.241"/>
<use xlink:href="#glyph-0-6" x="471.2013" y="254.241"/>
</g>
<path fill="none" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 0%)" stroke-opacity="1" stroke-miterlimit="10" d="M 145.1415 -137.781375 L 152.500875 -159.8595 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<path fill-rule="nonzero" fill="rgb(79.998779%, 79.998779%, 100%)" fill-opacity="1" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 100%)" stroke-opacity="1" stroke-miterlimit="10" d="M 209.000875 -127.558719 C 209.000875 -121.722781 204.2665 -116.988406 198.426656 -116.988406 C 192.586813 -116.988406 187.852438 -121.722781 187.852438 -127.558719 C 187.852438 -133.398562 192.586813 -138.132937 198.426656 -138.132937 C 204.2665 -138.132937 209.000875 -133.398562 209.000875 -127.558719 Z M 209.000875 -127.558719 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<g fill="rgb(0%, 0%, 0%)" fill-opacity="1">
<use xlink:href="#glyph-0-1" x="508.74" y="211.722"/>
<use xlink:href="#glyph-0-7" x="513.7213" y="211.722"/>
</g>
<path fill="none" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 0%)" stroke-opacity="1" stroke-miterlimit="10" d="M 175.04775 -92.488406 L 192.454 -118.597781 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<path fill-rule="nonzero" fill="rgb(79.998779%, 79.998779%, 100%)" fill-opacity="1" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 100%)" stroke-opacity="1" stroke-miterlimit="10" d="M 194.829 -170.082156 C 194.829 -164.242312 190.094625 -159.507937 184.254781 -159.507937 C 178.414938 -159.507937 173.680563 -164.242312 173.680563 -170.082156 C 173.680563 -175.922 178.414938 -180.652469 184.254781 -180.652469 C 190.094625 -180.652469 194.829 -175.922 194.829 -170.082156 Z M 194.829 -170.082156 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<g fill="rgb(0%, 0%, 0%)" fill-opacity="1">
<use xlink:href="#glyph-0-9" x="494.567" y="254.241"/>
<use xlink:href="#glyph-0-8" x="499.5483" y="254.241"/>
</g>
<path fill="none" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 0%)" stroke-opacity="1" stroke-miterlimit="10" d="M 195.020406 -137.781375 L 187.661031 -159.8595 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<path fill-rule="nonzero" fill="rgb(79.998779%, 79.998779%, 100%)" fill-opacity="1" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 100%)" stroke-opacity="1" stroke-miterlimit="10" d="M 223.176656 -170.082156 C 223.176656 -164.242312 218.442281 -159.507937 212.602438 -159.507937 C 206.762594 -159.507937 202.028219 -164.242312 202.028219 -170.082156 C 202.028219 -175.922 206.762594 -180.652469 212.602438 -180.652469 C 218.442281 -180.652469 223.176656 -175.922 223.176656 -170.082156 Z M 223.176656 -170.082156 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
<g fill="rgb(0%, 0%, 0%)" fill-opacity="1">
<use xlink:href="#glyph-0-2" x="522.913" y="254.241"/>
<use xlink:href="#glyph-0-0" x="527.8943" y="254.241"/>
</g>
<path fill="none" stroke-width="0.3985" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(0%, 0%, 0%)" stroke-opacity="1" stroke-miterlimit="10" d="M 201.832906 -137.781375 L 209.196188 -159.8595 " transform="matrix(1, 0, 0, -1, 315.296, 80.953)"/>
</svg>

After

Width:  |  Height:  |  Size: 40 KiB

View file

@ -231,6 +231,42 @@ Heap elements can be tuples. This is useful for assigning comparison values
(1, 'write spec')
Other Applications
------------------
`Medians <https://en.wikipedia.org/wiki/Median>`_ are a measure of
central tendency for a set of numbers. In distributions skewed by
outliers, the median provides a more stable estimate than an average
(arithmetic mean). A running median is an `online algorithm
<https://en.wikipedia.org/wiki/Online_algorithm>`_ that updates
continuously as new data arrives.
A running median can be efficiently implemented by balancing two heaps,
a max-heap for values at or below the midpoint and a min-heap for values
above the midpoint. When the two heaps have the same size, the new
median is the average of the tops of the two heaps; otherwise, the
median is at the top of the larger heap::
def running_median(iterable):
"Yields the cumulative median of values seen so far."
lo = [] # max-heap
hi = [] # min-heap (same size as or one smaller than lo)
for x in iterable:
if len(lo) == len(hi):
heappush_max(lo, heappushpop(hi, x))
yield lo[0]
else:
heappush(hi, heappushpop_max(lo, x))
yield (lo[0] + hi[0]) / 2
For example::
>>> list(running_median([5.0, 9.0, 4.0, 12.0, 8.0, 9.0]))
[5.0, 7.0, 5.0, 7.0, 8.0, 8.5]
Priority Queue Implementation Notes
-----------------------------------
@ -312,17 +348,12 @@ elements are considered to be infinite. The interesting property of a heap is
that ``a[0]`` is always its smallest element.
The strange invariant above is meant to be an efficient memory representation
for a tournament. The numbers below are *k*, not ``a[k]``::
for a tournament. The numbers below are *k*, not ``a[k]``:
0
1 2
3 4 5 6
7 8 9 10 11 12 13 14
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
.. figure:: heapq-binary-tree.svg
:class: invert-in-dark-mode
:align: center
:alt: Example (min-heap) binary tree.
In the tree above, each cell *k* is topping ``2*k+1`` and ``2*k+2``. In a usual
binary tournament we see in sports, each cell is the winner over the two cells

View file

@ -34,7 +34,7 @@ The module provides the following classes:
.. class:: HTTPConnection(host, port=None[, timeout], source_address=None, \
blocksize=8192)
blocksize=8192, max_response_headers=None)
An :class:`HTTPConnection` instance represents one transaction with an HTTP
server. It should be instantiated by passing it a host and optional port
@ -46,7 +46,9 @@ The module provides the following classes:
The optional *source_address* parameter may be a tuple of a (host, port)
to use as the source address the HTTP connection is made from.
The optional *blocksize* parameter sets the buffer size in bytes for
sending a file-like message body.
sending a file-like message body. The optional *max_response_headers*
parameter sets the maximum number of allowed response headers to help
prevent denial-of-service attacks, otherwise the default value (100) is used.
For example, the following calls all create instances that connect to the server
at the same host and port::
@ -66,10 +68,13 @@ The module provides the following classes:
.. versionchanged:: 3.7
*blocksize* parameter was added.
.. versionchanged:: 3.15
*max_response_headers* parameter was added.
.. class:: HTTPSConnection(host, port=None, *[, timeout], \
source_address=None, context=None, \
blocksize=8192)
blocksize=8192, max_response_headers=None)
A subclass of :class:`HTTPConnection` that uses SSL for communication with
secure servers. Default port is ``443``. If *context* is specified, it
@ -109,6 +114,9 @@ The module provides the following classes:
The deprecated *key_file*, *cert_file* and *check_hostname* parameters
have been removed.
.. versionchanged:: 3.15
*max_response_headers* parameter was added.
.. class:: HTTPResponse(sock, debuglevel=0, method=None, url=None)
@ -416,6 +424,14 @@ HTTPConnection Objects
.. versionadded:: 3.7
.. attribute:: HTTPConnection.max_response_headers
The maximum number of allowed response headers to help prevent denial-of-service
attacks. By default, the maximum number of allowed headers is set to 100.
.. versionadded:: 3.15
As an alternative to using the :meth:`~HTTPConnection.request` method described above, you can
also send your request step by step, by using the four functions below.

View file

@ -28,8 +28,10 @@ The character set, :data:`string.ascii_letters`, :data:`string.digits` and
in a cookie name (as :attr:`~Morsel.key`).
.. versionchanged:: 3.3
Allowed ':' as a valid cookie name character.
Allowed '``:``' as a valid cookie name character.
.. versionchanged:: 3.15
Allowed '``"``' as a valid cookie value character.
.. note::
@ -314,3 +316,10 @@ The following example demonstrates how to use the :mod:`http.cookies` module.
>>> print(C)
Set-Cookie: number=7
Set-Cookie: string=seven
>>> import json
>>> C = cookies.SimpleCookie()
>>> C.load(f'cookies=7; mixins="{json.dumps({"chips": "dark chocolate"})}"; state=gooey')
>>> print(C)
Set-Cookie: cookies=7
Set-Cookie: mixins="{"chips": "dark chocolate"}"
Set-Cookie: state=gooey

View file

@ -458,55 +458,6 @@ such as using different index file names by overriding the class attribute
:attr:`index_pages`.
.. class:: CGIHTTPRequestHandler(request, client_address, server)
This class is used to serve either files or output of CGI scripts from the
current directory and below. Note that mapping HTTP hierarchic structure to
local directory structure is exactly as in :class:`SimpleHTTPRequestHandler`.
.. note::
CGI scripts run by the :class:`CGIHTTPRequestHandler` class cannot execute
redirects (HTTP code 302), because code 200 (script output follows) is
sent prior to execution of the CGI script. This pre-empts the status
code.
The class will however, run the CGI script, instead of serving it as a file,
if it guesses it to be a CGI script. Only directory-based CGI are used ---
the other common server configuration is to treat special extensions as
denoting CGI scripts.
The :func:`do_GET` and :func:`do_HEAD` functions are modified to run CGI scripts
and serve the output, instead of serving files, if the request leads to
somewhere below the ``cgi_directories`` path.
The :class:`CGIHTTPRequestHandler` defines the following data member:
.. attribute:: cgi_directories
This defaults to ``['/cgi-bin', '/htbin']`` and describes directories to
treat as containing CGI scripts.
The :class:`CGIHTTPRequestHandler` defines the following method:
.. method:: do_POST()
This method serves the ``'POST'`` request type, only allowed for CGI
scripts. Error 501, "Can only POST to CGI scripts", is output when trying
to POST to a non-CGI url.
Note that CGI scripts will be run with UID of user nobody, for security
reasons. Problems with the CGI script will be translated to error 403.
.. deprecated-removed:: 3.13 3.15
:class:`CGIHTTPRequestHandler` is being removed in 3.15. CGI has not
been considered a good way to do things for well over a decade. This code
has been unmaintained for a while now and sees very little practical use.
Retaining it could lead to further :ref:`security considerations
<http.server-security>`.
.. _http-server-cli:
Command-line interface
@ -563,24 +514,6 @@ The following options are accepted:
.. versionadded:: 3.11
.. option:: --cgi
:class:`CGIHTTPRequestHandler` can be enabled in the command line by passing
the ``--cgi`` option::
python -m http.server --cgi
.. deprecated-removed:: 3.13 3.15
:mod:`http.server` command line ``--cgi`` support is being removed
because :class:`CGIHTTPRequestHandler` is being removed.
.. warning::
:class:`CGIHTTPRequestHandler` and the ``--cgi`` command-line option
are not intended for use by untrusted clients and may be vulnerable
to exploitation. Always use within a secure environment.
.. option:: --tls-cert
Specifies a TLS certificate chain for HTTPS connections::

View file

@ -413,7 +413,7 @@ An :class:`IMAP4` instance has the following methods:
the password. Will only work if the server ``CAPABILITY`` response includes the
phrase ``AUTH=CRAM-MD5``.
.. versionchanged:: 3.14
.. versionchanged:: 3.15
An :exc:`IMAP4.error` is raised if MD5 support is not available.

View file

@ -73,12 +73,15 @@ for example, a package and its resources can be imported from a zip file using
.. versionadded:: 3.9
.. versionchanged:: 3.12
*package* parameter was renamed to *anchor*. *anchor* can now
be a non-package module and if omitted will default to the caller's
module. *package* is still accepted for compatibility but will raise
a :exc:`DeprecationWarning`. Consider passing the anchor positionally or
using ``importlib_resources >= 5.10`` for a compatible interface
on older Pythons.
*package* parameter was renamed to *anchor*.
*package* was still accepted, but deprecated.
.. versionchanged:: 3.15
*package* parameter was fully removed. *anchor* can now be a
non-package module and if omitted will default to the caller's module.
*package* is no longer accepted since Python 3.15. Consider passing the
anchor positionally or using ``importlib_resources >= 5.10`` for a
compatible interface on older Pythons.
.. function:: as_file(traversable)

View file

@ -124,6 +124,10 @@ Functions
need to call :func:`invalidate_caches` in order for the new module to be
noticed by the import system.
If the module cannot be imported, :func:`import_module` will raise
:exc:`ImportError` or an appropriate subclass like
:exc:`ModuleNotFoundError`.
.. versionchanged:: 3.3
Parent packages are automatically imported.
@ -455,7 +459,7 @@ ABC hierarchy::
.. versionchanged:: 3.4
Raises :exc:`ImportError` instead of :exc:`NotImplementedError`.
.. staticmethod:: source_to_code(data, path='<string>')
.. staticmethod:: source_to_code(data, path='<string>', fullname=None)
Create a code object from Python source.
@ -467,11 +471,19 @@ ABC hierarchy::
With the subsequent code object one can execute it in a module by
running ``exec(code, module.__dict__)``.
The optional argument *fullname* specifies the module name.
It is needed to unambiguous :ref:`filter <warning-filter>` syntax
warnings by module name.
.. versionadded:: 3.4
.. versionchanged:: 3.5
Made the method static.
.. versionadded:: 3.15
Added the *fullname* parameter.
.. method:: exec_module(module)
Implementation of :meth:`Loader.exec_module`.
@ -1009,6 +1021,36 @@ find and load modules.
:exc:`ImportError` is raised.
.. class:: NamespacePath(name, path, path_finder)
Represents a :term:`namespace package`'s path (:attr:`module.__path__`).
When its ``__path__`` value is accessed it will be recomputed if necessary.
This keeps it in-sync with the global state (:attr:`sys.modules`).
The *name* argument is the name of the namespace module.
The *path* argument is the initial path value.
The *path_finder* argument is the callable used to recompute the path value.
The callable has the same signature as :meth:`importlib.abc.MetaPathFinder.find_spec`.
When the parent's :attr:`module.__path__` attribute is updated, the path
value is recomputed.
If the parent module is missing from :data:`sys.modules`, then
:exc:`ModuleNotFoundError` will be raised.
For top-level modules, the parent module's path is :data:`sys.path`.
.. note::
:meth:`PathFinder.invalidate_caches` invalidates :class:`NamespacePath`,
forcing the path value to be recomputed next time it is accessed.
.. versionadded:: 3.15
.. class:: SourceFileLoader(fullname, path)
A concrete implementation of :class:`importlib.abc.SourceLoader` by

View file

@ -619,17 +619,29 @@ attributes (see :ref:`import-mod-attrs` for module attributes):
Retrieving source code
----------------------
.. function:: getdoc(object)
.. function:: getdoc(object, *, inherit_class_doc=True, fallback_to_class_doc=True)
Get the documentation string for an object, cleaned up with :func:`cleandoc`.
If the documentation string for an object is not provided and the object is
a class, a method, a property or a descriptor, retrieve the documentation
string from the inheritance hierarchy.
If the documentation string for an object is not provided:
* if the object is a class and *inherit_class_doc* is true (by default),
retrieve the documentation string from the inheritance hierarchy;
* if the object is a method, a property or a descriptor, retrieve
the documentation string from the inheritance hierarchy;
* otherwise, if *fallback_to_class_doc* is true (by default), retrieve
the documentation string from the class of the object.
Return ``None`` if the documentation string is invalid or missing.
.. versionchanged:: 3.5
Documentation strings are now inherited if not overridden.
.. versionchanged:: 3.15
Added parameters *inherit_class_doc* and *fallback_to_class_doc*.
Documentation strings on :class:`~functools.cached_property`
objects are now inherited if not overriden.
.. function:: getcomments(object)

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