Commit graph

120431 commits

Author SHA1 Message Date
Miss Islington (bot)
7a8097c57a
[3.12] gh-116666: Add "token" glossary term (GH-130888) (GH-131368)
gh-116666: Add "token" glossary term (GH-130888)

Add glossary entry for `token`, and link to it.
Avoid talking about tokens in the SyntaxError intro (errors.rst); at this point
tokenization is too much of a technical detail. (Even to an advanced reader,
the fact that a *single* token is highlighted isn't too relevant. Also, we don't
need to guarantee that it's a single token.)
(cherry picked from commit 30d5205849)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-03-18 12:51:09 +01:00
Miss Islington (bot)
9d23a6d57b
[3.12] gh-131002: clarify how to enforce sqlite3 column types for generated fields (GH-131006) (#131386)
(cherry picked from commit f48887fb97)

Co-authored-by: Erlend E. Aasland <erlend@python.org>
2025-03-18 12:10:01 +01:00
Miss Islington (bot)
2601dae183
[3.12] gh-130132: properly free resources in urrlib.urlopen examples (GH-130280) (#131395)
gh-130132: properly free resources in `urrlib.urlopen` examples (GH-130280)
(cherry picked from commit 77d2fd4413)

Co-authored-by: Kanishk Pachauri <itskanishkp.py@gmail.com>
Co-authored-by: sobolevn <mail@sobolevn.me>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-03-18 09:34:45 +00:00
Miss Islington (bot)
c23a2d3bdc
[3.12] gh-131094: Refine math.isclose docs (GH-131139) (#131393)
gh-131094: Refine `math.isclose` docs (GH-131139)
(cherry picked from commit 3f50f96586)

Co-authored-by: Guy Jacoby <49398101+guyjacoby@users.noreply.github.com>
2025-03-18 09:20:52 +00:00
Bénédikt Tran
304ef8440b
[3.12] gh-127667: refactor and improve _hashopenssl.c error branches (#131145) (#131348)
gh-127667: refactor and improve `_hashopenssl.c` error branches (#131145)

Refactor `_setException()` into different helpers that can be used separately:

- set_ssl_exception_from_errcode(): set an exception from an explicit SSL error code.
- raise_ssl_error(): set an exception from the last SSL error code or use a user-defined message.
- notify_ssl_error_occurred(): same as raise_ssl_error() but with a generic default message.

(cherry-picked from commit ac50ece6ce).
2025-03-18 10:16:26 +01:00
Miss Islington (bot)
c1faeadd82
[3.12] gh-131325: fix sendfile fallback implementation to drain data after writing to transport (GH-131376) (#131378)
gh-131325: fix sendfile fallback implementation to drain data after writing to transport (GH-131376)
(cherry picked from commit 94f4d87aeb)

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-03-17 19:40:43 +00:00
Miss Islington (bot)
18e4eb410a
[3.12] gh-130727: Retry test_wmi on TimeoutError (GH-130832) (#130840)
gh-130727: Retry test_wmi on TimeoutError (GH-130832)

Use sleeping_retry() in test_wmi to retry multiple times on
TimeoutError. Wait up to LONG_TIMEOUT seconds (5 minutes by default).
(cherry picked from commit f67ff9e820)

Co-authored-by: Victor Stinner <vstinner@python.org>
2025-03-17 15:57:28 +00:00
Miss Islington (bot)
040583387b
[3.12] gh-129675: Update documentation for tp_basicsize & tp_itemsize (GH-129850) (GH-131078)
- Add alignment requirement
- Mention that ob_size is unreliable if you don't control it
- Add some links for context
- basicsize should include the base type in generaly not just PyObject
- suggest Py_SIZE & Py_SET_SIZE

This adds a “by-the-way” link to `PyObject_New`, which shouldn't be
used for GC types. In order to be comfortable linking to it, I also
add a link to `PyObject_GC_New` from its docs. And the same for
`*Var` variants, while I'm here.

(cherry picked from commit ad0f618ab3)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
2025-03-17 16:18:14 +01:00
Hugo van Kemenade
4c1d52934d
[3.12] gh-124385: Document and soft-deprecate PyLong_AS_LONG (GH-124386) (#130549)
(cherry picked from commit 425587a110)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
2025-03-17 14:59:12 +02:00
Hugo van Kemenade
3983fcad95
[3.12] gh-109961: Docs: Fix incorrect rendering of __replace__ in copy.rst (GH-109968) (#130909)
(cherry picked from commit 0baf72696e)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2025-03-17 14:58:14 +02:00
Miss Islington (bot)
6e7432f130
[3.12] gh-131339: test PyBytes_Size for a zero-size bytes object (GH-131340) (#131344)
gh-131339: test PyBytes_Size for a zero-size bytes object (GH-131340)
(cherry picked from commit 3ae67ba97e)

Co-authored-by: Nybblista <170842536+nybblista@users.noreply.github.com>
2025-03-17 12:20:32 +00:00
Miss Islington (bot)
e5e8b8ab44
[3.12] gh-129843: fix pure Python implementation of warnings.warn_explicit (GH-129848) (#131350)
gh-129843: fix pure Python implementation of `warnings.warn_explicit` (GH-129848)

The pure Python implementation of `warnings.warn_explicit` constructs a `WarningMessage`
with an incorrect source (it incorrectly sets the WarningMessage's line to the given `source`).
(cherry picked from commit 80e00ecc39)

Co-authored-by: Srinivas Reddy Thatiparthy (తాటిపర్తి శ్రీనివాస్  రెడ్డి) <thatiparthysreenivas@gmail.com>
2025-03-17 12:19:09 +01:00
donBarbos
baea0e2b05
[3.12] gh-130160: use .. program:: directive for documenting http.server CLI (GH-131010) (#131294)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-03-17 10:28:11 +02:00
Miss Islington (bot)
c5a23ab9a6
[3.12] gh-131327: Document winsound.SND_APPLICATION (GH-131328) (#131329)
gh-131327: Document winsound.SND_APPLICATION (GH-131328)
(cherry picked from commit bf4c1bf344)

Co-authored-by: AN Long <aisk@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-03-16 15:45:57 +00:00
Miss Islington (bot)
1d17f1a979
[3.12] gh-130160: use .. program:: directive for documenting doctest CLI (GH-131034) (#131321)
gh-130160: use `.. program::` directive for documenting `doctest` CLI (GH-131034)
(cherry picked from commit 9558d22ac3)

Co-authored-by: donBarbos <donbarbos@proton.me>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-03-16 12:00:39 +00:00
Wulian233
e364a4212e
[3.12] gh-131204: Fix difflib.HtmlDiff may not use monospaced font (GH-131221) (#131243)
(cherry picked from commit 7fd6160)
2025-03-14 12:23:39 +00:00
Miss Islington (bot)
9a612a850c
[3.12] gh-131234: Improve test_popen with more asserts (GH-131235) (#131241)
gh-131234: Improve `test_popen` with more asserts (GH-131235)
(cherry picked from commit fc07f863ee)

Co-authored-by: sobolevn <mail@sobolevn.me>
2025-03-14 11:54:56 +00:00
sobolevn
6658ada1ea
[3.12] gh-131219: Improve tests in test_lzma.py by adding more asserts (GH-131220) (#131237)
Co-authored-by: sobolevn <mail@sobolevn.me>
2025-03-14 11:54:37 +00:00
Miss Islington (bot)
77ece5aed8
[3.12] gh-130814: Enhance documentation for Python C API type objects (GH-130817) (#131224)
gh-130814: Enhance documentation for Python C API type objects (GH-130817)

The "Type Objects" title in `c-api/typeobj.rst`, duplicating the title of `c-api/type.rst`,
has been changed to "Type Objects Structures", thereby slightly improving Sphinx
search.
(cherry picked from commit 6b932edc52)

Co-authored-by: sharktide <meherrihaan@gmail.com>
2025-03-14 10:01:05 +00:00
Miss Islington (bot)
39b4f8b6ed
[3.12] gh-124269: Simplify typing.Annotated docs (GH-130770) (#131223)
gh-124269: Simplify `typing.Annotated` docs (GH-130770)

---------
(cherry picked from commit e4ac196aaa)

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-03-14 09:54:08 +00:00
Serhiy Storchaka
a3f4889413
[3.12] gh-85012: Properly reset msgctxt when compiling messages with msgfmt (GH-130525) (GH-131206)
Add also human-readable snapshots for tests.
(cherry picked from commit 7ea6e88eb4)

Co-authored-by: Tomas R <tomas.roun8@gmail.com>
2025-03-13 19:09:42 +00:00
Alexandra
ba363894bb
[3.12] gh-131181: Assert that PyObject_stgdict isn't NULL for PyCData (#131188)
PyCData types have stgdict, so `PyObject_stgdict` can not return NULL.
Add an assert to make this clear.
2025-03-13 15:06:39 +00:00
Miss Islington (bot)
969631aec9
[3.12] gh-93096: Load doctests in test_itertools (GH-131133) (#131137)
gh-93096: Load doctests in `test_itertools` (GH-131133)
(cherry picked from commit 15a8412b5e)

Co-authored-by: donBarbos <donbarbos@proton.me>
2025-03-12 08:00:17 +00:00
Miss Islington (bot)
afffd97cd9
[3.12] gh-130957: Use sleeping_retry in test_free_reference (GH-130958) (#131092)
The weak reference may not be immediately dead.
(cherry picked from commit 1908115871)

Co-authored-by: Sam Gross <colesbury@gmail.com>
2025-03-11 10:13:41 -04:00
Yuki Kobayashi
729ec5b4fc
[3.12] gh-101100: Fix sphinx warnings in library/asyncio-subprocess.rst (GH-130994) (#131075)
(cherry picked from commit 7cc99a54b7)
2025-03-11 12:31:33 +00:00
Miss Islington (bot)
8f26a79b33
gh-130959: Reject whitespace in fractions, in pure Python fromisoformat() (GH-130962) (GH-131076) (#131086)
Fix the pure Python implementation of `fromisoformat()` to reject any
non-digit characters, including whitespace, in the fractional part
of time specification.  This makes the behavior consistent with the C
implementation, and prevents incorrect parsing of these fractions
(e.g. `.400 ` would be misinterpreted as `.04`).

(cherry picked from commit 33494b4d0d)
(cherry picked from commit 27fd328cf6)

Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Michał Górny <mgorny@gentoo.org>
2025-03-11 12:00:06 +00:00
Victor Stinner
3f226c5a7f
[3.12] gh-131082: Add missing guards for WIN32_LEAN_AND_MEAN (#131044) (#131085)
gh-131082: Add missing guards for WIN32_LEAN_AND_MEAN (#131044)

(cherry picked from commit de8818ae23)

Co-authored-by: Max Bachmann <kontakt@maxbachmann.de>
2025-03-11 11:55:13 +00:00
Miss Islington (bot)
bfad0b56d9
[3.12] gh-93096: Fix loading doctests in test_pickle (GH-131069) (GH-131081)
(cherry picked from commit 3bb20d13a8)

Co-authored-by: donBarbos <donbarbos@proton.me>
2025-03-11 10:42:47 +00:00
Kyle Cutler
33605da91c
[3.12] gh-130809: Fix PyFrame_LocalsToFast copying the wrong value (#130816)
* gh-130809: Fix `PyFrame_LocalsToFast` copying the wrong value

* Skip hidden locals

* test, blurb

* Update Misc/NEWS.d/next/Core_and_Builtins/2025-03-04-12-52-21.gh-issue-130809.fSXq60.rst

Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>

* Update test

* PR feedback

* formatting

* comment

---------

Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
2025-03-10 20:27:07 -04:00
Miss Islington (bot)
fcf1f57d91
[3.12] gh-125331: Allow the parser to activate future imports on the fly (GH-125482) (#131063)
gh-125331: Allow the parser to activate future imports on the fly (GH-125482)
(cherry picked from commit 3bd3e09588)

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2025-03-10 22:13:59 +00:00
Miss Islington (bot)
22ac71dc8e
gh-131020: py.exe launcher does not correctly detect a BOM when searching for the shebang (GH-131021)
(cherry picked from commit 36ef3bfe39)

Co-authored-by: Chris Eibl <138194463+chris-eibl@users.noreply.github.com>
2025-03-10 20:12:40 +00:00
Miss Islington (bot)
c82795a0bb
[3.12] gh-130711: Document PyBaseObject_Type (GH-130712) (GH-130793)
(cherry picked from commit b3c18bfd82)

Co-authored-by: Yuki Kobayashi <drsuaimqjgar@gmail.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-03-10 15:05:45 +01:00
Miss Islington (bot)
8584790d6f
[3.12] gh-80421: Correct definitions of time (GH-130984) (#131023)
gh-80421: Correct definitions of time (GH-130984)

Based on the Wikipedia article, UTC is better said to be a successor than a renaming of GTC and language agnostic rather than an English-French compromise.
(cherry picked from commit 98fa4a49fe)

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2025-03-09 20:18:31 +00:00
Miss Islington (bot)
9f7f2c0df1
[3.12] gh-130160: use .. program:: directive for documenting pdb CLI (GH-130996) (#131013)
gh-130160: use `.. program::` directive for documenting `pdb` CLI (GH-130996)
(cherry picked from commit c240c2d88a)

Co-authored-by: donBarbos <donbarbos@proton.me>
2025-03-09 16:18:43 +00:00
donBarbos
11d550c2f3
[3.12] gh-130160: use .. program:: directive for documenting webbrowser CLI (GH-130995) (#131004)
* gh-130160: use `.. program::` directive for documenting `webbrowser` CLI (#130995)

use `.. program::` directive for documenting `webbrowser` CLI

(cherry picked from commit 92e5f826ac)

* remove extra paragraph
2025-03-09 07:33:56 +00:00
Miss Islington (bot)
552dad1692
[3.12] gh-123726: Document caveats of zipfile.Path around name sanitization (GH-130537) (#130987)
gh-123726: Document caveats of zipfile.Path around name sanitization (GH-130537)

Add a note to the `zipfile.Path` class documentation clarifying that it does not sanitize filenames. This emphasizes the caller's responsibility to validate or sanitize inputs, especially when handling untrusted ZIP archives, to prevent path traversal vulnerabilities. The note also references the `extract` and `extractall` methods for comparison and suggests using `os.path.abspath` and `os.path.commonpath` for safe filename resolution.
(cherry picked from commit a3990df612)

Co-authored-by: Affan Shaikhsurab <51104750+AffanShaikhsurab@users.noreply.github.com>
2025-03-08 21:45:48 +00:00
Miss Islington (bot)
a69107b335
[3.12] gh-130917: update timer and workload in test_signal (GH-130918) (#130968)
The workload to advance the virtual timeout is too lightweight for some
platforms. As result the test goes in timeout as it never reaches the
end of the timer. By having a heavier workload, the virtual timer
advances rapidly and the SIGVTALRM is sent before the timeout.
(cherry picked from commit 7879081198)

Co-authored-by: Diego Russo <diego.russo@arm.com>
2025-03-08 18:21:46 +00:00
Miss Islington (bot)
4eb4785afd
[3.12] gh-130954: Fix multiprocessing test_notify_n (GH-130955) (#130982)
The test could deadlock trying join on the worker processes.
Apply the same technique as gh-130933.

Join the process before the test ends in `test_notify` as well.
(cherry picked from commit edd1eca336)

Co-authored-by: Sam Gross <colesbury@gmail.com>
2025-03-08 18:21:37 +00:00
Hugo van Kemenade
d128edb0ec
[3.12] gh-113238: add Anchor to importlib.resources (GH-113801) (#130499)
(cherry picked from commit c85c0026a6)

Co-authored-by: Mike Zimin <122507876+mikeziminio@users.noreply.github.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2025-03-08 11:27:34 -05:00
Miss Islington (bot)
4230697886
[3.12] gh-110206: Fix multiprocessing test_notify_all (GH-130933) (#130951)
The test could deadlock trying join on the worker processes due to a
combination of behaviors:

* The use of `assertReachesEventually` did not ensure that workers
  actually woken.release() because the SyncManager's Semaphore does not
  implement get_value.

* This mean that the test could finish and the variable "sleeping" would
  got out of scope and be collected. This unregisters the proxy leading
  to failures in the worker or possibly the manager.

* The subsequent call to `p.join()` during cleanUp therefore never
  finished.

This takes two approaches to fix this:

1) Use woken.acquire() to ensure that the workers actually finish
   calling woken.release()

2) At the end of the test, wait until the workers are finished, while `cond`,
   `sleeping`, and `woken` are still valid.
(cherry picked from commit c476410dc5)

Co-authored-by: Sam Gross <colesbury@gmail.com>
2025-03-07 12:20:00 -05:00
Miss Islington (bot)
56fa6f39ff
[3.12] Correct function name in Doc/extending/embedding.rst (GH-127539) (#130946)
Correct function name in `Doc/extending/embedding.rst` (GH-127539)
(cherry picked from commit e5527f2cdd)

Co-authored-by: Boris Verkhovskiy <boris.verk@gmail.com>
2025-03-07 13:14:25 +00:00
Miss Islington (bot)
397e69d009
[3.12] gh-127371 Avoid unbounded growth SpooledTempfile.writelines (GH-127372) (#130885)
gh-127371 Avoid unbounded growth SpooledTempfile.writelines (GH-127372)
(cherry picked from commit cb67b44ca9)

Co-authored-by: Bert Peters <bert@bertptrs.nl>
2025-03-05 18:42:35 +01:00
Miss Islington (bot)
60be65aaf0
[3.12] Update links from typing.readthedocs.io to typing.python.org (GH-130877) (#130884)
Update links from typing.readthedocs.io to typing.python.org (GH-130877)
(cherry picked from commit 4f6218959e)

Co-authored-by: Sebastian Rittau <srittau@rittau.biz>
2025-03-05 15:35:46 +00:00
Miss Islington (bot)
ed015d05f2
[3.12] gh-116742: Fix subprocess test_check_output_timeout() (GH-130836) (#130874)
gh-116742: Fix subprocess test_check_output_timeout() (GH-130836)

Fix a race condition in test_check_output_timeout() of
test_subprocess. Don't write into stdout anymore, since there is no
reliable way to synchronize the parent and the child processes.

Change the timeout from 3 seconds to 0.1 seconds, and remove
@requires_resource('walltime') decorator.
(cherry picked from commit 67a942d427)

Co-authored-by: Victor Stinner <vstinner@python.org>
2025-03-05 13:00:41 +01:00
Petr Viktorin
8fe011af38
[3.12] gh-130824: Add tests for NULL in PyLong_*AndOverflow functions (GH-130828) (GH-130876)
(cherry picked from commit 90130807d9)

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
2025-03-05 13:52:40 +02:00
Miss Islington (bot)
919300e42a
[3.12] GH-125722: Increase minimum supported Sphinx to 8.2.0 (GH-130444) (#130859)
GH-125722: Increase minimum supported Sphinx to 8.2.0 (GH-130444)
(cherry picked from commit e53d105872)

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-03-05 00:38:04 +00:00
Miss Islington (bot)
45e667c7c2
[3.12] gh-130730: Fix multiprocessing test_active_children() (GH-130837) (#130846)
gh-130730: Fix multiprocessing test_active_children() (GH-130837)

Replace a sleep with an event: sleep is not a reliable
synchronization primitive.
(cherry picked from commit 3dd3675492)

Co-authored-by: Victor Stinner <vstinner@python.org>
2025-03-04 17:22:12 +00:00
sobolevn
50270fc980
[3.12] gh-129567: Add a note to typing.TypedDict docs about name mangling (GH-130233) (#130842) 2025-03-04 15:34:34 +00:00
Miss Islington (bot)
a0ac4dbe88
[3.12] gh-130736: Fix asyncio test_shutdown_default_executor_timeout() (GH-130800) (#130826)
gh-130736: Fix asyncio test_shutdown_default_executor_timeout() (GH-130800)

Replace time.sleep() with threading.Event.
(cherry picked from commit 6c48ed7d62)

Co-authored-by: Victor Stinner <vstinner@python.org>
2025-03-04 17:41:00 +05:30
Bénédikt Tran
7ce5f15981
[3.12] gh-130740: Move some stdbool.h includes after Python.h (#130738) (#130757)
gh-130740: Move some `stdbool.h` includes after `Python.h` (#130738)

Move some `#include <stdbool.h>` after `#include "Python.h"` when `pyconfig.h` is not
included first and when we are in a platform-agnostic context. This is to avoid having
features defined by `stdbool.h` before those decided by `Python.h` (this caused some
build failures when compiling CPython with `zig cc`).

(cherry-picked from commit 214562ed4d)

---------

Co-authored-by: Hugo Beauzée-Luyssen <hugo@beauzee.fr>
2025-03-04 10:38:24 +01:00