The 5th element of the __reduce__ tuple should be an iterator.
(cherry picked from commit 41b9ad5b38)
Co-authored-by: Arseny Boykov <36469655+Bobronium@users.noreply.github.com>
gh-141004: Document `Py_LOCAL` and `Py_LOCAL_INLINE` (GH-141725)
(cherry picked from commit 3149d64c93)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
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
(cherry picked from commit 96f496a949)
Co-authored-by: Miro Hrončok <miro@hroncok.cz>
Co-authored-by: Cody Maloney <cmaloney@users.noreply.github.com>
(cherry picked from commit 630cd37bfa)
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
[3.14] gh-137109: refactor warning about threads when forking (GH-141438) (GH-141614)
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.
Note: This is a simplified backport that maintains the void return type
for warn_about_fork_with_threads() and keeps PyErr_Clear() in the warning path,
as the error handling changes from fd8f42d3d1 are not needed in 3.14.
(cherry picked from commit 0d8fb0b852)
Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
gh-141004: Document the `PyPickleBuffer_*` C API (GH-141630)
(cherry picked from commit e33afa7ddb)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
gh-140938: Raise ValueError for infinite inputs to stdev/pstdev (GH-141531)
Raise ValueError for infinite inputs to stdev/pstdev
---
(cherry picked from commit f0a8bc737a)
Co-authored-by: Raymond Hettinger <rhettinger@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
gh-141004: Document C APIs for dictionary keys, values, and items (GH-141009)
(cherry picked from commit f72768f30e)
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
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.
(cherry picked from commit 2fbd396666)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Xcode concatenates the test argument array, losing quoting in the process.
(cherry picked from commit 558936bec1)
Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
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.
(cherry picked from commit 7d54374f9c)
The endpoint used for demonstrating reading URLs is no longer
stable. This change substitutes a target over which we have more
control.
(cherry picked from commit fbcac79951)
Co-authored-by: Bob Kline <bkline@users.noreply.github.com>
gh-132657: add regression test for `PySet_Contains` with unhashable type (GH-141411)
(cherry picked from commit 2ac738d325)
Co-authored-by: M Bussonnier <bussonniermatthias@gmail.com>
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.
---------
(cherry picked from commit 0d7b48a8f5)
Co-authored-by: Maurycy Pawłowski-Wieroński <maurycy@maurycy.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
gh-141004: Document `PyFile_OpenCode` and `PyFile_OpenCodeObject` (GH-141413)
(cherry picked from commit 2befce86e6)
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
gh-139533: fix refs to code without proper markups on turtledemo doc (GH-139534)
(cherry picked from commit c903d76832)
gh-139533: fix refs to code without proper markups on turtledemo documentation
Co-authored-by: Marco Barbosa <aureliobarbosa@gmail.com>