End-of-file errors are now handled according to the HTML5 specs --
comments and declarations are automatically closed, tags are ignored.
(cherry picked from commit 6eb6c5dbfb)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
gh-132969: Fix error/hang when shutdown(wait=False) and task exited abnormally (GH-133222)
When shutdown is called with wait=False, the executor thread keeps running
even after the ProcessPoolExecutor's state is reset. The executor then tries
to replenish the worker processes pool resulting in an error and a potential hang
when it comes across a worker that has died. Fixed the issue by having
_adjust_process_count() return without doing anything if the ProcessPoolExecutor's
state has been reset.
Added unit tests to validate two scenarios:
max_workers < num_tasks (exception)
max_workers > num_tasks (exception + hang)
(cherry picked from commit 598aa7cc98)
Co-authored-by: Ajay Kamdar <140011370+ogbiggles@users.noreply.github.com>
Revert "gh-135410: use a critical section around `StringIO.__next__` (GH-135412)" (GH-135439)
This reverts commit e6c3039cb3.
(cherry picked from commit 73431356d3)
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
PEP-734 has been accepted (for 3.14).
(FTR, I'm opposed to putting this under the concurrent package, but
doing so is the SC condition under which the module can land in 3.14.)
(cherry picked from commit 62143736b, AKA gh-133958)
gh-135410: use a critical section around `StringIO.__next__` (GH-135412)
(cherry picked from commit e6c3039cb3)
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
gh-135326: Test support of __index__ in random.getrandbits() (GH-135356)
(cherry picked from commit 5ae669fc4e)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* gh-91048: Reorder result tuple of parse_code_object (GH-134898)
Reorder result tuple of parse_code_object
The standard followed by APIs like pstat.Stats is to take a file, line,
function triplet. The parse_code_object function (and callers exposing
this in Python like RemoteUnwinder.get_stack_trace) return function,
file, line triplets which requires the caller to reorder these when
using it in classes like pstat.Stats.
(cherry picked from commit 8e8786f898)
Co-authored-by: László Kiss Kollár <kiss.kollar.laszlo@gmail.com>
* Reorder asyncio
---------
Co-authored-by: László Kiss Kollár <kiss.kollar.laszlo@gmail.com>
Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
gh-130077: Properly match full soft keywords in the parser (GH-135317)
(cherry picked from commit ff2b5f40c2)
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
gh-133968: Add PyUnicodeWriter_WriteASCII() function (#133973)
Replace most PyUnicodeWriter_WriteUTF8() calls with
PyUnicodeWriter_WriteASCII().
(cherry picked from commit f49a07b531)
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
* gh-135276: Refresh `zipfile.Path` from zipp 3.23 (GH-135277)
Apply changes from zipp 3.23
(cherry picked from commit 8d6eb0c262)
Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
* Removed features slated for Python 3.15 only.
---------
Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
gh-134155: fix AttributeError in email._header_value_parser.get_address (GH-134194)
Append the defect to defects instead of to the parse tree.
(cherry picked from commit d9cad074d5)
Co-authored-by: Sergey Miryanov <sergey.miryanov@gmail.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>
We were incorrectly handling a few opcodes that leave their operands on the stack. Treat all of these conservatively; assume that they always leave operands on the stack.
(cherry picked from commit 6b77af257c)
gh-135166: Fix exception type expected by test.test_zstd (GH-135167)
(cherry picked from commit 1b55e12766)
Co-authored-by: Weipeng Hong <hongweichen8888@sina.com>
gh-135124: Change stdout errors in regrtest worker process (GH-135138)
Set sys.stdout encoder error handler to backslashreplace in regrtest
workers to avoid UnicodeEncodeError when printing a traceback
or any other non-encodable character.
Move the code from the Regrtest class to setup_process().
Call setup_process() earlier, before displaying regrtest headers.
(cherry picked from commit 3d396ab759)
Co-authored-by: Victor Stinner <vstinner@python.org>
The `test_ssl_in_multiple_threads` test failed because `test_check_hostname_idn()`
modified the global warnings filters via `warnings_helper.check_no_resource_warning()`.
Only check for warnings when the context aware warnings feature is enabled, which makes
the warnings filter context-local and thread-safe.
(cherry picked from commit 40c8be0008)
Co-authored-by: Thomas Grainger <tagrain@gmail.com>
gh-134248 test_getallocatedblocks pre-check to ignore immortalized strings (GH-134871)
When sanity checking against gettotalrefcount(), we exclude the blocks for
immortalized strings since their references are not tracked/reported. This
now matches refleak.py's book-keeping using the same functions.
(cherry picked from commit 54ca55978e)
Co-authored-by: tpburns <trevorpburns@gmail.com>
Make them similar to PyArg_Parse error messages, mention None as
a possible value, show a wrong type and the string length.
(cherry picked from commit df98a47a61)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
50 producer and 50 consumer threads need more than 5GB of memory.
(cherry picked from commit 7a79f52d83)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
The `textiowrapper_iternext` function called `_textiowrapper_writeflush`, but did not
use a critical section, making it racy in free-threaded builds.
(cherry picked from commit 44fb7c361c)
Co-authored-by: Duane Griffin <duaneg@dghda.com>
OpenSSL and HACL*-based hash functions constructors now support both `data` and `string` parameters.
Previously these constructor functions inconsistently supported sometimes `data` and sometimes `string`,
while the documentation expected `data` to be given in all cases.
(cherry picked from commit c6e63d9d35)
(cherry picked from commit 379d0bc956)
gh-133489: Remove size restrictions on getrandbits() and randbytes() (GH-133658)
random.getrandbits() can now generate more that 2**31 bits.
random.randbytes() can now generate more that 256 MiB.
(cherry picked from commit 68784fed78)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
gh-134954: Hard-cap max file descriptors in subprocess test fd_status (GH-134955)
* Hard-cap max file descriptors in subprocess test fd_status
On some systems, `SC_OPEN_MAX` may return a very large value (i.e. 10**30), leading to the subprocess test timing out (or run forever).
Prevent this situation by applying a hard cap on how many file descriptors are checked.
* Fix typo in usage docstring
s/fd_stats/fd_status/
(cherry picked from commit f58873e4b2)
Co-authored-by: Itamar Oren <itamarost@gmail.com>
It now supports most callables, full args, and return values.
(cherry picked from commit 52deabe, AKA gh-133484)
Co-authored-by: Eric Snow ericsnowcurrently@gmail.com
Remove doctest module frames from tracebacks and redundant newline
character from a failure message.
(cherry picked from commit cb8a72b301)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
gh-133711: Fix test_readline.test_nonascii() for UTF-8 Mode (GH-134841)
Skip the test if the Python UTF-8 Mode is enabled and the LC_CTYPE
encoding is not UTF-8.
(cherry picked from commit 4635115c3f)
Co-authored-by: Victor Stinner <vstinner@python.org>
gh-133711: Fix test_regrtest for PYTHONUTF8=1 (GH-134839)
Use "backslashreplace" error handler to decode stdout and stderr.
Example:
vstinner@WIN C:\victor\python\main\build\test_python_worker_8360\x91>
"C:\victor\python\main\PCbuild\amd64\python_d.exe" -m test
--fast-ci --slow-ci --testdir
C:\Users\vstinner\AppData\Local\Temp\tmp0t59e8da
test_regrtest_noop1 test_regrtest_noop2 test_regrtest_noop3
test_regrtest_noop4
Notice the "\x91" byte at the end of the first line: it's the
non-ASCII U+00E6 character encoded to the OEM cp437 code page.
(cherry picked from commit 91618278e7)
Co-authored-by: Victor Stinner <vstinner@python.org>
gh-62824: Adjust test_alias_modules_exist test to use imports instead of file checks (GH-134777)
(cherry picked from commit 8704d6b391)
Co-authored-by: Miro Hrončok <miro@hroncok.cz>
gh-134752: Improve speed of test_tokenize.StringPrefixTest.test_prefixes. (GH-134766)
(cherry picked from commit 579686d9fb)
Co-authored-by: Eric V. Smith <ericvsmith@users.noreply.github.com>