[3.12] gh-106033: Get rid of new occurrences of PyDict_GetItem and PyObject_HasAttr (GH-106034)
These functions are broken by design because they discard any exceptions raised
inside, including MemoryError and KeyboardInterrupt. They should not be
used in new code.
(cherry picked from commit 1d33d53780)
gh-106033: [docs] Improve C API GetItem & HasAttr notes. (GH-106047)
Use a note:: tag so that these dict and object API deficiencies show up clearly.
A caution:: tag was considered, but our current python docs rendering doesn't do much with that (no box or color change). warning:: seemed too extreme. note looks good.
(cherry picked from commit 19d6511b0b)
Co-authored-by: Gregory P. Smith <greg@krypto.org>
gh-105974: Revert unintentional behaviour change for protocols with non-callable members and custom `__subclasshook__` methods (GH-105976)
(cherry picked from commit 9499b0f138)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Typing docs: improve the guidance on annotating tuples (GH-106021)
(cherry picked from commit 968435ddb1)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Docs: Avoid a DeprecationWarning in `pyspecific.py` when running with Sphinx >=6.1 (GH-105886)
(cherry picked from commit a72683ba8e)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
gh-104212: Explain how to port imp code to importlib (GH-105905)
(cherry picked from commit 7a56a4148c)
Co-authored-by: Victor Stinner <vstinner@python.org>
GH-105808: Fix a regression introduced in GH-101251 (GH-105910)
Fix a regression introduced in pythonGH-101251, causing GzipFile.flush() to
not flush the compressor (nor pass along the zip_mode argument).
(cherry picked from commit 1858db7cbd)
Co-authored-by: T. Wouters <thomas@python.org>
typing docs: Improve the intro to each section (GH-105901)
(cherry picked from commit 4426279a43)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Docs: move sphinx-lint to pre-commit (GH-105750)
(cherry picked from commit bc07c8f096)
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
GH-105840: Fix assertion failures when specializing calls with too many __defaults__ (GH-105847)
(cherry picked from commit 2beab5bdef)
Co-authored-by: Brandt Bucher <brandtbucher@microsoft.com>
bpo-44530: Document the change in MAKE_FUNCTION behavior (GH-93189)
* bpo-44530: Document the change in MAKE_FUNCTION behavior
Fixes dis module documentation for MAKE_FUNCTION due to 2f180ce2cb (bpo-44530, released as part of 3.11) removes the qualified name at TOS
(cherry picked from commit 486b52a315)
Co-authored-by: Alex Doe <alexdoesh@gmail.com>
Some parts of the implementation of `typing.Protocol` had poor test coverage
(cherry picked from commit 70c075c194)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
The syntax used in the current docs (a / before any args) is invalid.
I think the right approach is for the arguments to arbitrary
filter functions to be treated as positional-only, meaning that users
can supply filter functions with any names for the argument. tarfile.py
only calls the filter function with positional arguments.
(cherry picked from commit 5cdd5ba49d)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
gh-105821: Use a raw f-string in test_httpservers.py (GH-105822)
Use a raw f-string in test_httpservers.py
(cherry picked from commit 09ce8c3b48)
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
gh-105196: Fix indentations of section headings in C API docs (GH-105672)
(cherry picked from commit d32e8d6070)
Co-authored-by: TATHAGATA ROY <royzen9495@gmail.com>
gh-105587: Remove assertion from `_PyStaticObject_CheckRefcnt` (GH-105638)
(cherry picked from commit 6199fe3b32)
Co-authored-by: Eddie Elizondo <eduardo.elizondorueda@gmail.com>
This fixes a race during import. The existing _PyRuntimeState.imports.pkgcontext is shared between interpreters, and occasionally this would cause a crash when multiple interpreters were importing extensions modules at the same time. To solve this we add a thread-local variable for the value. We also leave the existing state (and infrequent race) in place for platforms that do not support thread-local variables.
(cherry picked from commit b87d288275)
Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
gh-105387: Limited C API implements Py_INCREF() as func (GH-105388)
In the limited C API version 3.12, Py_INCREF() and Py_DECREF()
functions are now implemented as opaque function calls to hide
implementation details.
(cherry picked from commit b542972dc1)
Co-authored-by: Victor Stinner <vstinner@python.org>
For a while now, pending calls only run in the main thread (in the main interpreter). This PR changes things to allow any thread run a pending call, unless the pending call was explicitly added for the main thread to run.
(cherry picked from commit 757b402)
gh-98040: Fix importbench: use types.ModuleType() (GH-105743)
Replace removed imp.new_module(name) with types.ModuleType(name).
(cherry picked from commit 457a459c78)
Co-authored-by: Victor Stinner <vstinner@python.org>
We are changing it to be more flexible that a strict bool can be for possible future expanded used cases.
(cherry picked from commit b97e14a806)
Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>