Writing out an object may involve a slot lookup, which is not safe to do with
an exception raised. In debug mode an assertion failure will occur if this
happens.
(cherry picked from commit ce8f5f98c6)
Co-authored-by: Duane Griffin <duaneg@dghda.com>
The forkserver was not passing sys.argv to its main() function, causing
sys.argv to be empty during `__main__` module import in child processes. This
fixes a non-obvious regression inadvertently introduced by the gh-126631 main
preloading fix.
(cherry picked from commit 298d5440eb)
gh-143249: Fix buffer leak when overlapped operation fails to start on windows (GH-143250)
(cherry picked from commit 103a384bfd)
Co-authored-by: Yongtao Huang <yongtaoh2022@gmail.com>
Copy net new text in idle.rst from main to 3.13.
Make 3.13 docs and copy-strip idle.html to idlelib/help.html.
See https://github.com/python/cpython/issues/139707#issuecomment-3737374788
and PR #143718 message for more.
* Revert url to 'main' from '3.13'
The branch in the source links in the revised help.html
become '3.13' instead of 'main' because the html
was generated from an edited 3.13 version of idle.rst
instead being backported from main. This reversion
avoids the possibility of future backport merge conflicts.
The version makes no difference to the Help/IDLE doc display as
the url is currently neither displayed nor linked to the link title
-- 'Lib/idlelib'. If we do make the links live, we can use
sys.version_info to replace 'main' when main is no longer the source branch.
It was incorrect in case of mixed tabs and spaces in indentation.
(cherry picked from commit 5f28aa2f37)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
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 6d54b6ac7d)
Co-authored-by: zhong <60600792+superboy-zjc@users.noreply.github.com>
These tests relied on a bug -- gh-84644, which is that singledispatch
doesn't verify the annotation is on the "first" parameter.
(cherry picked from commit 620a5b9269)
Co-authored-by: Bartosz Sławecki <bartosz@ilikepython.com>
Previously, this could cause crash or data corruption, now concurrent calls
of methods of the same object raise RuntimeError.
(cherry picked from commit d1282efb2b)
gh-143641: Make `ready_to_import` always remove tempdir from `sys.path` (GH-143642)
Make ready_to_import always remove tempdir from sys.path
(cherry picked from commit e7f5ffa0de)
Co-authored-by: Jeong, YunWon <69878+youknowone@users.noreply.github.com>
When comparing negative non-integer float and int with the same number
of bits in the integer part, __neg__() in the int subclass returning
not an int caused an assertion error.
Now the integer is no longer negated. Also, reduced the number of
temporary created Python objects.
(cherry picked from commit 66bca383bd)
[3.14] gh-143547: Fix PyErr_FormatUnraisable() fallback (GH-143557) (GH-143603)
gh-143547: Fix PyErr_FormatUnraisable() fallback (GH-143557)
Hold a strong reference to 'hook' while calling the default
unraisable took to log hook failure.
(cherry picked from commit 1d0baf1ae4)
(cherry picked from commit 39a2bcf949)
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 c07e5ec0a9)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
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 efaa56f73c)
Co-authored-by: Victor Stinner <vstinner@python.org>
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 8735daf3e8)
(cherry picked from commit ff0a8b7289)
Co-authored-by: Ken Jin <kenjin@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 522563549a)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
[3.13] gh-143309: fix UAF in `os.execve` when the environment is concurrently mutated (GH-143314) (#143431)
(cherry picked from commit 9609574e7f)
(cherry picked from commit c99f766743)
gh-140648: Make asyncio REPL respect the `-I` flag (isolated mode) (GH-143045)
(cherry picked from commit e7c542de5f)
Co-authored-by: Bartosz Sławecki <bartosz@ilikepython.com>
Update docstrings of `typing.Hashable`, `typing.List`, etc., to reflect their deprecation (GH-143295)
(cherry picked from commit 18f3c59e57)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
gh-143200: fix UAFs in `Element.__{set,get}item__` when the element is concurrently mutated (GH-143226)
(cherry picked from commit b6b0e14b3d)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
gh-142195: Fixed Popen.communicate indefinite loops (GH-143203)
Changed condition to evaluate if timeout is less than or equals to 0. This is needed for simulated time environments such as Shadow where the time will match exactly on the boundary.
---------
(cherry picked from commit fa9a4254e8)
Co-authored-by: Prithviraj Chaudhuri <p.chaudhuri1993@gmail.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
This happened when the Counter was mutated when incrementing
the value for an existing key.
(cherry picked from commit 86d904588e)
Co-authored-by: kaushal trivedi <155625932+Kaushalt2004@users.noreply.github.com>
The unknown-8bit trick was designed to deal with unknown bytes in an
ASCII message, and it works fine for that. However, I also tried to
extend it to handle bytes that can't be decoded using the charset
specified in an encoded word, and there it fails because there can be
other non-ASCII characters that were *successfully* decoded. The fix is
simple: do the unknown-8bit encoding using the utf-8 codec. This is
especially appropriate since anyone trying to do recovery on an unknown
byte string will probably attempt utf-8 first.
(cherry picked from commit 1e17ccd030)
Co-authored-by: R. David Murray <rdmurray@bitdance.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Count the number of Element attribute accesses as a proxy for work done.
With double the amount of work, a ratio of 2.0 indicates linear scaling
and 4.0 quadratic scaling. Use 3.2 as an intermediate threshold.
(cherry picked from commit 57937a8e5e)
Co-authored-by: Sam Gross <colesbury@gmail.com>
gh-109263: Start process from spawn context in multiprocessing no longer have side effect (GH-135813)
(cherry picked from commit c2202a7e66)
Co-authored-by: AN Long <aisk@users.noreply.github.com>