gh-83424: Allow empty name if handle is non-null when create ctypes.CDLL on Windows (GH-136878)
(cherry picked from commit ed522ed211)
Co-authored-by: AN Long <aisk@users.noreply.github.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
gh-137317: Fix inspect.signature() for class with wrapped __init__ or __new__ (GH-137862)
Fixed several cases where __init__, __new__ or metaclass` __call__ is a descriptor
that returns a wrapped function.
(cherry picked from commit 025a2135ef)
Co-authored-by: Ju4tCode <42488585+yanyongyu@users.noreply.github.com>
It should interpret the result of wcsxfrm() as a sequence of abstract
integers, not a sequence of Unicode code points or using other encoding
scheme that does not preserve ordering.
(cherry picked from commit 482fd0c811)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Handle ECANCELED in the same way as EINTR to work around the Posix
violation in the NetBSD's implementation.
(cherry picked from commit 07d0b95b05)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Update `validate_abstract_methods` in `test_collections.py`
The test for missing abstract methods in `validate_abstract_methods` incorrectly attempted to instantiate the generated class `C` with an argument (`C(name)`), which always raises a `TypeError: C() takes no arguments`. Although the test originally passes, it passes for the wrong reason.
This change makes the test correctly validate the enforcement of abstract methods in ABCs.
(cherry picked from commit 5be872350d)
Co-authored-by: Guilherme Leobas <guilhermeleobas@gmail.com>
Both modules should use the Python implementation in that case.
(cherry picked from commit 6620ef0ff6)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
The csv.register_dialect() docstring no longer imply that it returns a dialect.
All functions have now signatures.
(cherry picked from commit aa1dbd4dde)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: maurycy <5383+maurycy@users.noreply.github.com>
* Merge existing tests test_repr_str and test_to_str.
* Add more tests for non-printable and non-ASCII bytes.
* Add tests for special escape sequences ('\t\n\r').
* Add tests for slashes.
* Add more tests for quotes.
* Add tests for subclasses.
* Add test for non-ASCII class name.
* Only apply @check_bytes_warnings for str() tests.
(cherry picked from commit 0dbbf61cc2)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* Don't fail trying to parse weird patterns.
* Don't fail trying to decode non-UTF-8 "robots.txt" files.
* No longer ignore trailing "?" in patterns and URLs.
* Distinguish raw special characters "?", "=" and "&" from the
percent-encoded ones.
* Remove tests that do nothing.
(cherry picked from commit cb7ef18d70)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
fix potential hang.
It can happen that the child crashes right in the beginning for whatever reason. In this case, the parent will hang when writing into the pipe, because the child fd is not closed yet.
The normal pattern is to close the child fds right after the child proc is forked/executed/spawned, so when the child dies, then also the pipes will be closed, and there will be no hang (the parent gets SIGPIPE instead).
(cherry picked from commit 8ed5a2b56c)
Co-authored-by: Albert Zeyer <albzey@gmail.com>
The OpenSSL and HACL* implementations of HMAC single-shot
digest computation reject keys whose length exceeds `INT_MAX`
and `UINT32_MAX` respectively. The OpenSSL implementation
also rejects messages whose length exceed `INT_MAX`.
Using such keys in `hmac.digest` previously raised an `OverflowError`
which was propagated to the caller. This commit mitigates this case by
making `hmac.digest` fall back to HMAC's pure Python implementation
which accepts arbitrary large keys or messages.
This change only affects the top-level entrypoint `hmac.digest`, leaving
`_hashopenssl.hmac_digest` and `_hmac.compute_digest` untouched.
(cherry picked from commit d658b9053b)
Add immutable=1 flag for read-only SQLite access to avoid WAL/SHM errors on readonly DB.
(cherry picked from commit c0ae92b7c0)
Co-authored-by: General_K1ng <generak1ng0@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
gh-137706: make typing._is_unpacked_typevartuple check for `True` instead of truthy (GH-137712)
(cherry picked from commit 7e652f402f)
Co-authored-by: David Ellis <ducksual@gmail.com>
gh-138558: Improve handling of Template annotations in annotationlib (GH-139072)
(cherry picked from commit 6ec058a1f7)
Co-authored-by: Dave Peck <davepeck@gmail.com>
GH-137484: Have `Tools/wasm/wasi` use the build triple instead of "build" (GH-37485)
This should help prevent issuse where something like a container is used to do one build and then someone tries to build again locally.
(cherry picked from commit 0953200b13)
Co-authored-by: Brett Cannon <brett@python.org>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
gh-138813: Fix mutable default kwargs={} in multiprocessing BaseProcess and DummyProcess to use None (GH-138814)
* gh-138813: Default `BaseProcess` `kwargs` to `None` (GH-138814)
Set `BaseProcess.__init__(..., kwargs=None)` and initialize `kwargs` with
`dict(kwargs) if kwargs else {}`. This avoids a shared mutable default and
matches threading.Thread behavior.
* DummyProcess kwargs=None (which threading.Thread accepts properly)
(cherry picked from commit 5a15e73789)
Co-authored-by: Denis Sergeev <newjimbatler00@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
gh-126631: gh-137996: fix pre-loading of `__main__` (GH-135295)
gh-126631: gh-137996: fix pre-loading of `__main__`
The `main_path` parameter was renamed `init_main_from_name`, update the
forkserver code accordingly. This was leading to slower startup times when people
were trying to preload the main module.
---------
(cherry picked from commit 0912b3a6db)
Co-authored-by: Duane Griffin <duaneg@dghda.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
GH-137243: Have `Tools/wasm/wasi` detect WASI SDK installs in `/opt` when the release tarball is extracted (GH-137244)
(cherry picked from commit 2f1a9f2ed4)
Co-authored-by: Brett Cannon <brett@python.org>
Drop explicit tool installation in the dev container (GH-138211)
This is now handled upstream in the dev container image itself.
(cherry picked from commit d910b93f78)
Co-authored-by: Brett Cannon <brett@python.org>
Support records with "zip64 extensible data" if there are no bytes
prepended to the ZIP file.
(cherry picked from commit 162997bb70)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* Improve error messages for path-like relative paths and path-like bytes paths.
* TZPATH is now always a tuple of strings.
(cherry picked from commit 859aecc33b)
Co-authored-by: Stephen Morton <git@tungol.org>
Touch up `Setup.local` handling in `Tools/wasm/wasi` (GH-137051)
The comment in the generated file is now more self-explanatory. The checks for unexpected file contents are also strengthened.
(cherry picked from commit ec7fad79d2)
Co-authored-by: Brett Cannon <brett@python.org>
Co-authored-by: Zachary Ware <zach@python.org>