gh-127734: improve signature of `urllib.request.HTTPPasswordMgrWithPriorAuth.__init__` (GH-127735)
improve signature of urllib.request.HTTPPasswordMgrWithPriorAuth.__init__
(cherry picked from commit a03efb533a)
Co-authored-by: Stephen Morton <git@tungol.org>
Give `poplib.POP3.rpop` a proper docstring (GH-127370)
Previously `poplib.POP3.rpop` had a "Not sure what this does" docstring, now it has been fixed.
(cherry picked from commit 27d0d21413)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Fix typo in `Lib/_android_support.py` (GH-127699)
(cherry picked from commit e59caf67cd)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
gh-127552: Remove comment questioning 4-digit restriction for ‘Y’ in datetime.strptime patterns (GH-127590)
The code has required 4 digits for the year since its inclusion in the stdlib in 2002 (over 22 years ago as of this commit).
(cherry picked from commit 51cfa569e3)
Co-authored-by: Beomsoo Kim <beoms424@gmail.com>
The `STORE_ATTR_INSTANCE_VALUE` opcode doesn't support objects with
non-NULL managed dictionaries, so don't specialize to that op in that case.
(cherry picked from commit a353455fca)
Co-authored-by: Sam Gross <colesbury@gmail.com>
gh-127655: Ensure `_SelectorSocketTransport.writelines` pauses the protocol if needed (GH-127656)
Ensure `_SelectorSocketTransport.writelines` pauses the protocol if it reaches the high water mark as needed.
(cherry picked from commit e991ac8f20)
Co-authored-by: J. Nick Koston <nick@koston.org>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Objects may be temporarily "resurrected" in destructors when calling
finalizers or watcher callbacks. We previously undid the resurrection
by decrementing the reference count using `Py_SET_REFCNT`. This was not
thread-safe because other threads might be accessing the object
(modifying its reference count) if it was exposed by the finalizer,
watcher callback, or temporarily accessed by a racy dictionary or list
access.
This adds internal-only thread-safe functions for temporary object
resurrection during destructors.
(cherry picked from commit f4f530804b)
[Docs] GDB howto: Fix block type of a cast example (GH-127621)
(cherry picked from commit 657d0e99aa)
Co-authored-by: Maciej Olko <maciej.olko@affirm.com>
gh-122431: Disallow negative values in `readline.append_history_file` (GH-122469)
(cherry picked from commit 208b0fb645)
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
gh-93312: Include <sys/pidfd.h> to get PIDFD_NONBLOCK (GH-127593)
(cherry picked from commit fcbe6ecdb6)
Co-authored-by: Victor Stinner <vstinner@python.org>
gh-127421: Fix race in test_start_new_thread_failed (GH-127549)
Fix race in test_start_new_thread_failed
When we succeed in starting a new thread, for example if setrlimit
was ineffective, we must wait for the newly spawned thread to exit.
Otherwise, we run the risk that the newly spawned thread will race
with runtime finalization and access memory that has already been
clobbered/freed.
`_thread.start_new_thread()` only spawns daemon threads, which the runtime
does not wait for at shutdown, and does not return a handle. Use
`_thread.start_joinable_thread()` and join the resulting handle when
the thread is started successfully.
(cherry picked from commit 13b68e1a61)
Co-authored-by: mpage <mpage@meta.com>
gh-122907: Fix Builds Without HAVE_DYNAMIC_LOADING Set (gh-122952)
As of 529a160 (gh-118204), building with HAVE_DYNAMIC_LOADING stopped working. This is a minimal fix just to get builds working again. There are actually a number of long-standing deficiencies with HAVE_DYNAMIC_LOADING builds that need to be resolved separately.
(cherry picked from commit ee1b8ce26e)
Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
Make IPv4-mapped IPv6 address properties consistent with IPv4.
(cherry picked from commit 76a1c5d183)
Co-authored-by: Seth Michael Larson <seth@python.org>
In the free threading build, if a non-owning thread resizes a list,
it must use QSBR to free the old list array because there may be a
concurrent access (without a lock) from the owning thread.
To match the pattern in dictobject.c, we just mark the list as "shared"
before resizing if it's from a non-owning thread and not already marked
as shared.
(cherry picked from commit c7dec02de2)
Co-authored-by: Sam Gross <colesbury@gmail.com>
This approach eliminates the originally reported race. It also gets rid of the deadlock reported in gh-96071, so we can remove the workaround added then.
This is mostly a cherry-pick of 1c0a104 (AKA gh-126989). The difference is we add PyInterpreterState.threads_preallocated at the end of PyInterpreterState, instead of adding PyInterpreterState.threads.preallocated. That avoids ABI disruption.
gh-126876: Fix socket internal_select() for large timeout (GH-126968)
If the timeout is larger than INT_MAX, replace it with INT_MAX, in
the poll() code path.
Add an unit test.
(cherry picked from commit b3687ad454)
Co-authored-by: Victor Stinner <vstinner@python.org>
Note, that transformed expression is not an equivalent for original one (1/exp(-x) != exp(x) in general for floating-point numbers). Though, the difference seems to be ~1ULP for good libm implementations.
It's more interesting why division was used from beginning. Closest algorithm I've found (no error checks, of course;)) - it's Algorithm 190 from ACM: https://dl.acm.org/doi/10.1145/366663.366679. It uses subtraction in the exponent.
(cherry picked from commit f7bb658124)
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Docs: Miscellaneous corrections to simple statements in the language reference (GH-126720)
* Replace: The :keyword:`global` -> The :keyword:`global` statement
Add :keyword: when it's needed
* Replace repeated links with duoble backticks
(cherry picked from commit 94a7a4e22f)
Co-authored-by: Beomsoo Kim <beoms424@gmail.com>
gh-126699: allow AsyncIterator to be used as a base for Protocols (GH-126702)
(cherry picked from commit feb3e0b19c)
Co-authored-by: Stephen Morton <github@tungol.org>
The CPython uses _Py_dg_dtoa(), which does rounding to nearest with half
to even tie-breaking rule.
If that functions is unavailable, PyOS_double_to_string() fallbacks to
system snprintf(). Since CPython 3.12, build requirements include C11
compiler *and* support for IEEE 754 floating point numbers (Annex F).
This means that FE_TONEAREST macro is available and, per default,
printf-like functions should use same rounding mode as _Py_dg_dtoa().
(cherry picked from commit 7d7d56d8b1)
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
gh-125666: Avoid PyREPL exiting when a null byte is in input (GH-125732)
(cherry picked from commit 44becb8cba)
Co-authored-by: devdanzin <74280297+devdanzin@users.noreply.github.com>
Make SSL objects thread safe in Free Theaded build by
using critical sections.
(cherry picked from commit 4c53b25775)
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Add the missing `f` on an f-string error message in multiprocessing. (GH-127462)
(cherry picked from commit 11c01092d5)
Co-authored-by: Gregory P. Smith <greg@krypto.org>
gh-127190: Fix local_setattro() error handling (GH-127366)
Don't make the assumption that the 'name' argument is a string. Use
repr() to format the 'name' argument instead.
(cherry picked from commit 20657fbdb1)
Co-authored-by: Victor Stinner <vstinner@python.org>