gh-118658: Return consistent types from `get_un/verified_chain` in `SSLObject` and `SSLSocket` (GH-118669)
(cherry picked from commit 8ef358dae1)
Co-authored-by: Mateusz Nowak <nowak.mateusz@hotmail.com>
Co-authored-by: Gregory P. Smith [Google LLC] <greg@krypto.org>
Check that the current default heap is initialized in
`_mi_os_get_aligned_hint` and `mi_os_claim_huge_pages`.
The mimalloc function `_mi_os_get_aligned_hint` assumes that there is an
initialized default heap. This is true for our main thread, but not for
background threads. The problematic code path is usually called during
initialization (i.e., `Py_Initialize`), but it may also be called if the
program allocates large amounts of memory in total.
The crash only affected the free-threaded build.
(cherry picked from commit d061ffea7b)
Co-authored-by: Sam Gross <colesbury@gmail.com>
gh-116622: Add Android test script (GH-121595)
Adds a script for running the test suite on Android emulator devices. Starting
with a fresh install of the Android Commandline tools; the script manages
installing other requirements, starting the emulator (if required), and
retrieving results from that emulator.
(cherry picked from commit f84cce6f25)
Co-authored-by: Malcolm Smith <smith@chaquo.com>
gh-116622: Android logging fixes (GH-122698)
Modifies the handling of stdout/stderr redirection on Android to accomodate
the rate and buffer size limits imposed by Android's logging infrastructure.
(cherry picked from commit b0c48b8fd8)
Co-authored-by: Malcolm Smith <smith@chaquo.com>
gh-123046: Fix regexp to catch cases where the module name is omitted from the weakref repr (GH-123047)
(cherry picked from commit 786cac0c64)
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
Co-authored-by: sobolevn <mail@sobolevn.me>
gh-116608: Apply style and compatibility changes from importlib_metadata. (GH-123028)
(cherry picked from commit e913d2c87f)
Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
GH-85633: Fix pathlib test failures on filesystems without world-write. (GH-122883)
Replace `umask(0)` with `umask(0o002)` so the created files are not
world-writable, and replace `umask(0o022)` with `umask(0o026)` to check
that permissions for 'others' can still be set.
(cherry picked from commit 5f68511522)
Co-authored-by: Barney Gale <barney.gale@gmail.com>
gh-122255: Add black box tests in test_warnings (GH-122227)
They are similar to white box tests for gh-86298 in test_importlib.
(cherry picked from commit fe13c9baf4)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
gh-105376: Restore deprecated logging warn() method (GH-122775)
This reverts commit dcc028d924 and
commit 6c54e5d721.
Keep the deprecated logging warn() method in Python 3.13.
(cherry picked from commit d3239976a8)
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
* Share common classes.
* Use exactly representable floats and exact tests.
* Check the sign of zero components.
* Remove duplicated tests (mostly left after merging int and long).
* Reorder tests in more consistent way.
* Test more error messages.
* Add tests for missed cases.
(cherry picked from commit bf098d4157)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Before, the exception caused by calling non-default sys.excepthook
in code.InteractiveInterpreter bubbled up to the caller, ending the REPL.
(cherry picked from commit bd3d31f380)
Co-authored-by: CF Bolz-Tereick <cfbolz@gmx.de>
Fix _PyArg_UnpackKeywordsWithVararg for the case when argument for
positional-or-keyword parameter is passed by keyword.
There was only one such case in the stdlib -- the TypeVar constructor.
(cherry picked from commit 540fcc62f5)
gh-122728: Fix SystemError in PyEval_GetLocals() (GH-122735)
Fix PyEval_GetLocals() to avoid SystemError ("bad argument to
internal function"). Don't redefine the 'ret' variable in the if
block.
Add an unit test on PyEval_GetLocals().
(cherry picked from commit 4767a6e31c)
Co-authored-by: Victor Stinner <vstinner@python.org>
gh-121650: Encode newlines in headers, and verify headers are sound (GH-122233)
GH-GH- Encode header parts that contain newlines
Per RFC 2047:
> [...] these encoding schemes allow the
> encoding of arbitrary octet values, mail readers that implement this
> decoding should also ensure that display of the decoded data on the
> recipient's terminal will not cause unwanted side-effects
It seems that the "quoted-word" scheme is a valid way to include
a newline character in a header value, just like we already allow
undecodable bytes or control characters.
They do need to be properly quoted when serialized to text, though.
GH-GH- Verify that email headers are well-formed
This should fail for custom fold() implementations that aren't careful
about newlines.
(cherry picked from commit 0976339818)
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Bas Bloemsaat <bas@bloemsaat.org>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
gh-122334: Fix crash when importing ssl after re-initialization (GH-122481)
* Fix crash when importing ssl after re-initialization
(cherry picked from commit 9fc1c992d6)
Co-authored-by: neonene <53406459+neonene@users.noreply.github.com>
gh-122133: Rework pure Python socketpair tests to avoid use of importlib.reload. (GH-122493)
(cherry picked from commit f071f01b7b)
Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
Currently, idle-dev@python.org and idle-dev mailing list
serve to collect spam (90+%). Change About IDLE to direct
discussions to discuss.python.org. Users are already
doing so.
(cherry picked from commit 29c04dfa27)
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
gh-119896: Fix CTRL-Z behavior in the new REPL on Windows (GH-122217)
(cherry picked from commit d1a1bca1f0)
Co-authored-by: Dino Viehland <dinoviehland@meta.com>
gh-105733: Soft-deprecate ctypes.ARRAY, rather than hard-deprecating it. (GH-122281)
Soft-deprecate ctypes.ARRAY, rather than hard-deprecating it.
Partially reverts 2211454fe2
(cherry picked from commit 3833d27f98)
Co-authored-by: Petr Viktorin <encukou@gmail.com>
The `_PyUnicode_Intern*` functions already adjust the total refcount, so
we don't want to readjust it in refleak.py.
(cherry picked from commit ac8da34621)
Co-authored-by: Sam Gross <colesbury@gmail.com>
Authenticate socket connection for `socket.socketpair()` fallback when the platform does not have a native `socketpair` C API. We authenticate in-process using `getsocketname` and `getpeername` (thanks to Nathaniel J Smith for that suggestion).
(cherry picked from commit 78df1043db)
Co-authored-by: Seth Michael Larson <seth@python.org>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
The tests were only checking cases where the slot wrapper was present in the initial case. They were missing when the slot wrapper was added in the additional initializations. This fixes that.
(cherry-picked from commit 490e0ad83a, AKA gh-122248)
Update datetime module and test_type_cache.py to not call PyType_Modified.
(cherry picked from commit e55b05f29e, AKA gh--122182)
Co-authored-by: Mark Shannon <mark@hotpy.org>
gh-121913: Use str(exc) instead of exc.strerror in `asyncio.base_events` (GH-122269)
(cherry picked from commit 070f1e2e5b)
Co-authored-by: AN Long <aisk@users.noreply.github.com>
Serializing objects with complex __qualname__ (such as unbound methods and
nested classes) by name no longer involves serializing parent objects by value
in pickle protocols < 4.
(cherry picked from commit dc07f65a53)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
gh-122187: Avoid TSan reported race in `run_udp_echo_server` (GH-122189)
TSan doesn't fully recognize the synchronization via I/O, so ensure that
socket name is retrieved earlier and use a different socket for sending
the "STOP" message.
(cherry picked from commit 2f74b709b6)
Co-authored-by: Sam Gross <colesbury@gmail.com>
__spec__.loader is now required in the module globals (see gh-86298).
(cherry picked from commit 9b4fe9b718)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
GH-120754: Add more tests around seek + readall (GH-122103)
In the process of speeding up readall, A number of related tests
(ex. large file tests in test_zipfile) found problems with the
change I was making. This adds I/O tests to specifically test these
cases to help ensure they don't regress and hopefully make debugging
easier.
This is part of the improvements from
https://github.com/python/cpython/pull/121593GH-issuecomment-2222261986
(cherry picked from commit 9eb734111b)
Co-authored-by: Cody Maloney <cmaloney@users.noreply.github.com>
gh-122029: Log call events in sys.setprofile when it's a method with c function (GH-122072)
Log call events in sys.setprofile when it is a method with a C function.
(cherry picked from commit e91ef13861)
Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
gh-121832: Skip subinterpreter static type check on iOS to restore test suite. (GH-122150)
(cherry picked from commit 1bcc9eb862)
Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
These tests fail when run under thread sanitizer due to the use of fork
and threads.
(cherry picked from commit 64e221d7ad)
Co-authored-by: Sam Gross <colesbury@gmail.com>
This fixes the flakiness in:
* test_inspect_keeps_globals_from_inspected_file
* test_inspect_keeps_globals_from_inspected_module
The output already includes newlines. Adding newlines for every entry in
the output list introduces non-determinism because it added '\n' in
places where stdout is flushed or some buffer becomes full.
The regex also needed to be updated because pyrepl includes control
characters -- the visible output on each line doesn't immediately follow
a newline character.
(cherry picked from commit 2c1b1e7a07)
Co-authored-by: Sam Gross <colesbury@gmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Share common code for tests for PyLong_As*() functions.
(cherry picked from commit 69f2dc5c06)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
Relatedly, emit the `cpython.run_startup` event from the Python version of
`PYTHONSTARTUP` handling.
(cherry picked from commit dc93d1125f)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
gh-121988: Fix test hang when pyrepl is not available (GH-121990)
Also explicitly fail the test if we timeout while waiting for output so
that this failure mode is caught earlier.
(cherry picked from commit a09e215abf)
Co-authored-by: Sam Gross <colesbury@gmail.com>
gh-120930: Remove extra blank occuring in wrapped encoded words in email headers (GH-121747)
(cherry picked from commit cecaceea31)
Co-authored-by: Matthieu Caneill <matthieucan@users.noreply.github.com>
This adds tests for the documented behaviour of `pkgutil.extend_path`
regarding different argument types as well as for `*.pkg` files.
(cherry picked from commit 8f2532168b)
Co-authored-by: Andreas Stocker <andreas@stocker.co.it>
gh-78889: Stop IDLE Shell freezes from sys.stdout.shell.xyz (GH-121876)
Problem occurred when attribute xyz could not be pickled.
Since this is not trivial to selectively fix, block all
attributes (other than 'width'). IDLE does not access them
and they are private implementation details.
(cherry picked from commit 58753f33e4)
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
The object's inline values may be marked invalid if the materialized
dict was already initialized and then deleted.
(cherry picked from commit 162b41f577)
Co-authored-by: Sam Gross <colesbury@gmail.com>
When using the ** operator or pow() with Fraction as the base
and an exponent that is not rational, a float, or a complex, the
fraction is no longer converted to a float.
(cherry picked from commit b9965ef282)
Co-authored-by: Joshua Herman <30265+zitterbewegung@users.noreply.github.com>
console.compile with the "single" param throws an exception when
there are multiple statements, never allowing to adding newlines
to a pasted code block (gh-121610)
This adds a few extra checks to allow extending when in an indented
block, and tests for a few examples.
(cherry picked from commit 7d111dac16)
Co-authored-by: saucoide <32314353+saucoide@users.noreply.github.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
The fallback repl does not support "exit" without parentheses, so the
test would hang until the timeout expired.
(cherry picked from commit 4134261ab8)
Co-authored-by: Sam Gross <colesbury@gmail.com>
This avoids messages like:
ThreadSanitizer: starting new threads after multi-threaded fork is not
supported. Dying (set die_after_fork=0 to override)
(cherry picked from commit 82a4dac9f6)
Co-authored-by: Sam Gross <colesbury@gmail.com>