gh-143191: Use _PyOS_MIN_STACK_SIZE in _thread.stack_size() (GH-143601)
The stack size must be at least _PyOS_MIN_STACK_SIZE+SYSTEM_PAGE_SIZE
bytes.
(cherry picked from commit ba10100c3931b18812b82d7124e2238f01927910)
Co-authored-by: Victor Stinner <vstinner@python.org>
gh-143547: Fix PyErr_FormatUnraisable() fallback (#143557)
Hold a strong reference to 'hook' while calling the default
unraisable took to log hook failure.
(cherry picked from commit 39a2bcf949095bd603f7b73f15b5b478dbb49ba9)
PyObject_GetBuffer() can execute user code (e.g. via __buffer__), which may
close or otherwise mutate a BytesIO object while write() or writelines()
is in progress. This could invalidate the internal buffer and lead to a
use-after-free.
Ensure that PyObject_GetBuffer() is called before validation checks.
(cherry picked from commit 6d54b6ac7d5744e1f59d784c8e020d632d2959a3)
Co-authored-by: zhong <60600792+superboy-zjc@users.noreply.github.com>
gh-143429: Use compile-time NaN encoding detection for test_struct (GH-143432)
(cherry picked from commit dcdb23f9db2bd683e5d37558f09b458be25a9b4d)
Co-authored-by: Henry Chen <chenx97@aosc.io>
In optimized and `-Og` builds, arguments and local variables are frequently
unavailable in gdb. This makes `py-bt` fail to print anything useful. Use the
`PyThreadState*` pointers `_Py_tss_gilstate` and `Py_tss_tstate` to find the
interpreter frame if we can't get the frame from the
`_PyEval_EvalFrameDefault` call.
(cherry picked from commit 49c3b0a67a77bb42e736cea7dcbc1aa8fa704074)
Co-authored-by: Sam Gross <colesbury@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
For example, "-u xpickle=2.7" will run test_xpickle only against Python 2.7.
(cherry picked from commit c07e5ec0a9e5843fc39dec6aa94172faf6354858)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
gh-143513: Clarify changed argument name of `ResourceReader.is_resource` (GH-143523)
(cherry picked from commit 5462002bbefd6cb79716828051beae94de8f2529)
Co-authored-by: Alex Willmer <alex@moreati.org.uk>
gh-143528: Fix test_time.test_thread_time() (GH-143558)
Tolerate 100 ms instead of 20 ms to support slow CIs.
(cherry picked from commit efaa56f73cb1dc4863894444425e753afb7b997c)
Co-authored-by: Victor Stinner <vstinner@python.org>
gh-143517: Fix an edge case in rewriting stringified starred annotations (GH-143518)
(cherry picked from commit 6c9f7b4406d507625ff414cddc549d4c630c59c5)
Co-authored-by: Bartosz Sławecki <bartosz@ilikepython.com>
Fix a typo in STORE_SLICE docs (GH-143500)
(cherry picked from commit 228d95582e080c60335d5f0a229a6698eb69b11c)
Co-authored-by: Tomas R <tomas.roun8@gmail.com>
gh-133315: Document that compat32 should not be used with MIMEPart/EmailMessage (GH-143307)
(cherry picked from commit ff7d1cec41f391270560b9f4726791d8476c6eba)
Co-authored-by: Andrii Hrimov <andrew.hrimov@gmail.com>
Move data classes used in tests to separate file test_picklecommon.py,
so it can be imported in old Python versions.
(cherry picked from commit 8735daf3e82d50defd791e9be7b9ae6843bc4ed1)
Co-authored-by: Ken Jin <kenjin@python.org>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
gh-142302: Fix mkstemp() documentation: clarify file descriptor inheritance behavior (GH-142338)
The documentation incorrectly stated that the file descriptor is not
inherited by child processes. In reality, the close-on-exec flag (when
available) only prevents inheritance across exec() calls, not fork().
(cherry picked from commit e79c9b703117d8b0e7c4d86b704e2e7f120db883)
Co-authored-by: ADITYA RAI <adi.hack1234@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
When __length_hint__() returns 0 for non-empty iterator, the data can be
written past the shared 0-terminated buffer, corrupting it.
(cherry picked from commit 522563549a49d28e763635c58274a23a6055f041)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Loïc Simon <loic.simon@napta.io>
Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
Cherry picked from commits 7db209b5647b77e9d665830d522153ed891d2e12 and aed90508b3112aa5294c6d4ff6c2026e3c794129.
gh-143309: fix UAF in `os.execve` when the environment is concurrently mutated (GH-143314)
(cherry picked from commit 9609574e7fd36edfaa8b575558a82cc14e65bfbc)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
gh-140648: Make asyncio REPL respect the `-I` flag (isolated mode) (GH-143045)
(cherry picked from commit e7c542de5f069a4b83e8eded3067613e4d59a529)
Co-authored-by: Bartosz Sławecki <bartosz@ilikepython.com>
gh-76187: Document the `c` typecode for `multiprocessing.Array`. (GH-132504)
* Document the `c` typecode for `multiprocessing.Array`.
* Add quotes
* Mention that 'w' is not supported
(cherry picked from commit 136f6d835588e0f72cecdff855afc8f424381ed5)
Co-authored-by: Tomas R <tomas.roun8@gmail.com>
Co-authored-by: Johann Christensen <johannchristensen@outlook.de>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Update docstrings of `typing.Hashable`, `typing.List`, etc., to reflect their deprecation (GH-143295)
(cherry picked from commit 18f3c59e57e5d30218210136060310310b10ff72)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
gh-140920: remove incorrect mentions to `concurrent.futures.interpreter.ExecutionFailed` (GH-141723)
Remove documentation for inexistant `concurrent.futures.interpreter.ExecutionFailed`
and replace its occurrences by `concurrent.interpreters.ExecutionFailed` since this
is the documented exception.
(cherry picked from commit c5215978ebfea9471f313d5baa70a4e68bfb798b)
Co-authored-by: Lakshya Upadhyaya <lakshya.upadhyaya05@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>
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>
gh-69686: Remove untrue part of `__import__` replacement docs (GH-143261)
Remove untrue part of `__import__` replacement docs
The original statement effectively says that replacing `__import__` at global scope affects import statements, and not only that, but only import statements within the rest of the executing module. None of that has been true since at least Python 2.7, I think.
This was likely missed in python/cpython#69686.
(cherry picked from commit 79c03ac0015ccf1cbb759f870e2af9d68f60fe3a)
Co-authored-by: Thanos <111999343+Sachaa-Thanasius@users.noreply.github.com>