gh-136421: Load `_datetime` static types during interpreter initialization (GH-136583)
`_datetime` is a special module, because it's the only non-builtin C extension that contains static types. As such, it would initialize static types in the module's execution function, which can run concurrently. Since static type initialization is not thread-safe, this caused crashes. This fixes it by moving the initialization of `_datetime`'s static types to interpreter startup (where all other static types are initialized), which is already properly protected through other locks.
(cherry picked from commit a10960699a)
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
GH-136874: `url2pathname()`: discard query and fragment components (GH-136875)
In `urllib.request.url2pathname()`, ignore any query or fragment components
in the given URL.
(cherry picked from commit 80b2d60a51)
Co-authored-by: Barney Gale <barney.gale@gmail.com>
gh-136470: Correct InterpreterPoolExecutor's default thread name (GH-136472)
The OS thread name is now correctly prefixed with `InterpreterPoolExecutor` instead of `ThreadPoolExecutor`.
(cherry picked from commit 246be21de1)
Co-authored-by: AN Long <aisk@users.noreply.github.com>
GH-130645: Default to color help in argparse (GH-136809)
(cherry picked from commit acbe896cb1)
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
Clears the umask used during a test of pydoc.apropos when testing on
Emscripten. This is to work around a known issue in Emscripten; but it's not
clear if the chmod call that is causing the problem is actually testing
anything of significance.
(cherry picked from commit 22af5d35a6)
Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
This might have been fixed by gh-136624, or by some Emscripten change.
In any case, it no longer seems to be needed.
(cherry picked from commit dcd27aace1)
Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
Provide a stub implementation of umask that is enough to get some tests passing.
More work is needed upstream in Emscripten to make all umask tests to pass.
(cherry picked from commit 12e52cad71)
Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
Makes the Emscripten stack overflow skip message consistent with WASI,
and replaces some ad-hoc skips.
(cherry picked from commit c730952aa6)
Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
Previously, we assumed that instrumentation would happen for all copies of
the bytecode if the instrumentation version on the code object didn't match
the per-interpreter instrumentation version. That assumption was incorrect:
instrumentation will exit early if there are no new "events," even if there
is an instrumentation version mismatch.
To fix this, include the instrumented opcodes when creating new copies of
the bytecode, rather than replacing them with their uninstrumented variants.
I don't think we have to worry about races between instrumentation and creating
new copies of the bytecode: instrumentation and new bytecode creation cannot happen
concurrently. Instrumentation requires that either the world is stopped or the
code object's per-object lock is held and new bytecode creation requires holding
the code object's per-object lock.
(cherry picked from commit d995922198)
Co-authored-by: mpage <mpage@meta.com>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
gh-116738: Make grp module thread-safe (GH-135434)
Make grp module methods getgrgid() and getgrnam() thread-safe when the GIL is disabled and getgrgid_r()/getgrnam_r() C APIs are not available.
---------
(cherry picked from commit 9363703bd3)
Co-authored-by: Alper <alperyoney@fb.com>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
gh-127971: fix off-by-one read beyond the end of a string during search (GH-132574)
(cherry picked from commit 85ec3b3b50)
Co-authored-by: Duane Griffin <duaneg@dghda.com>
gh-91153: prevent a crash in `bytearray.__setitem__(ind, ...)` when `ind.__index__` has side-effects (GH-132379)
(cherry picked from commit 5e1e21dee3)
Co-authored-by: Bast <52266665+bast0006@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
gh-136517: Print uncollectable objects if DEBUG_UNCOLLECTABLE mode was set (GH-136518)
(cherry picked from commit c560df9658)
Co-authored-by: Sergey Miryanov <sergey.miryanov@gmail.com>
gh-136438: Make sure `test_builtins` pass with all optimization levels (GH-136474)
(cherry picked from commit c176543349)
Co-authored-by: sobolevn <mail@sobolevn.me>
gh-136476: Show the full stack in get_async_stack_trace in _remote_debugging (GH-136483)
(cherry picked from commit ea45a2f97c)
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
gh-136315: Fix skipped multithreading test in test_zstd (GH-136320)
Fix skipped test in test_zstd
(cherry picked from commit 5dac137b9f)
Co-authored-by: Emma Smith <emma@emmatyping.dev>
gh-136297: Test all `pickle` protocols in `test_zoneinfo_property.py` (GH-136298)
(cherry picked from commit 5de7e3f973)
Co-authored-by: sobolevn <mail@sobolevn.me>
gh-135773: have pyvenv.cfg without home key anchor a venv and deduce home (GH-135831)
This is still formally undefined behaviour, but we may as well
keep the *same* undefined behaviour as previous versions.
PEP 796 proposes a cleaner and more consistent replacement for 3.15+
(cherry picked from commit 93263d4314)
Co-authored-by: Richard Levasseur <rlevasseur@google.com>
* Whitespaces no longer accepted between `</` and the tag name.
E.g. `</ script>` does not end the script section.
* Vertical tabulation (`\v`) and non-ASCII whitespaces no longer recognized
as whitespaces. The only whitespaces are `\t\n\r\f `.
* Null character (U+0000) no longer ends the tag name.
* Attributes and slashes after the tag name in end tags are now ignored,
instead of terminating after the first `>` in quoted attribute value.
E.g. `</script/foo=">"/>`.
* Multiple slashes and whitespaces between the last attribute and closing `>`
are now ignored in both start and end tags. E.g. `<a foo=bar/ //>`.
* Multiple `=` between attribute name and value are no longer collapsed.
E.g. `<a foo==bar>` produces attribute "foo" with value "=bar".
* Whitespaces between the `=` separator and attribute name or value are no
longer ignored. E.g. `<a foo =bar>` produces two attributes "foo" and
"=bar", both with value None; `<a foo= bar>` produces two attributes:
"foo" with value "" and "bar" with value None.
---------
(cherry picked from commit 0243f97cba)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Ezio Melotti <ezio.melotti@gmail.com>