Commit graph

34551 commits

Author SHA1 Message Date
dbXD320
d7b9ea5cab
gh-138584: Increase test coverage for collections.UserList (#138590)
Some common tests in `test.list_tests.CommonTest` explicitly tested `list`
instead of testing the underlying list-like type defined in `type2test`.

---------

Co-authored-by: Devansh Baghla <devanshbaghla34@gmail.com>
2025-09-07 10:53:22 +02:00
Duane Griffin
0912b3a6db
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.

---------

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2025-09-07 07:49:54 +00:00
Zachary Ware
bbe00d53e9
gh-90548: Skip NODEV portion of test_makedev when linked to musl (GH-138593) 2025-09-06 14:01:26 -05:00
Zachary Ware
7d58461fdb
gh-90548: Skip ctypes test_null_dlsym when linked to musl (GH-138592)
The test relies on glibc-specific behavior.
2025-09-06 14:01:18 -05:00
R. David Murray
bcdac03670
gh-90548: Allow Alpine/MUSL to pass test_c_locale_coercion. (GH-134454)
Like cygwin, MUSL defaults to utf-8 if no variables are set.  I have no
idea if the existing tests pass on cygwin, but I made the modifications
such that I shouldn't break it if is.  The additional checks needed for
MUSL are guarded by DEFAULT_LOCALE_IS_C being False.  Based on this
flag, we expect utf-8 for the encodings and no coercion message, as
long as LC_ALL is not set to C.  (That looks like a bit of an issue with
the test structure, but I'm not going to attempt to "fix" that.)
DEFAULT_ENCODING is intentionally not given a default since it is only
used when DEFAULT_LOCALE_IS_C is False, and if you use the flag you'll
need to set it.

After reading through issue 30672, looking at the source, and running a
test on Android, I *think* the current situation is that coercion will
be done if the local is set to POSIX regardless of platform.  However,
if the platform doesn't make POSIX equivalent to C, the encodings when
coercion is disabled will not be the same as for C (it is utf-8 on
android, for example).  This means the tests would fail if POSIX were
added unconditionally to the EXPECTED_C_LOCALE_EQUIVALENTS as envisioned
in the issue.  This *could* be fixed with another flag, but I'm not sure
it is worth the effort.  I'm not even sure Python is behaving optimally
in this case (assuming my analysis is correct).  So I just altered the
comment and add POSIX if and only if the platform is linux.
2025-09-06 14:01:11 -05:00
AN Long
c919d02ede
gh-138205: Remove the resize method on mmap object on platforms don't support it (#138276)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-09-06 14:10:04 +05:30
Alper
8554c0917e
gh-116738: make cProfile module thread-safe (#138229)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-09-06 13:19:14 +05:30
David Ellis
7e652f402f
gh-137706: make typing._is_unpacked_typevartuple check for True instead of truthy (#137712) 2025-09-06 07:39:49 +00:00
Jacob Walls
92b2a8a04d
gh-93334: Fix homonym edge case in PathFinder.find_spec() (GH-98100) 2025-09-05 15:41:01 -07:00
Brian Schubert
e2c038f5be
gh-138010: Fix __init_subclass__ forwarding by warnings.deprecated (#138210) 2025-09-05 20:44:50 +00:00
Serhiy Storchaka
cb7ef18d70
gh-88375, gh-111788: Fix parsing errors and normalization in robotparser (GH-138502)
* 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.
2025-09-05 18:58:42 +03:00
AN Long
ed522ed211
gh-83424: Allow empty name if handle is non-null when create ctypes.CDLL on Windows (GH-136878) 2025-09-05 18:51:35 +03:00
Petr Viktorin
0c74fc8af0
gh-137210: Add a struct, slot & function for checking an extension's ABI (GH-137212)
Co-authored-by: Steve Dower <steve.dower@microsoft.com>
2025-09-05 16:23:18 +02:00
Christoph Walcher
c1a9c23195
gh-57911: Sanitize symlink targets in tarfile on win32 (GH-138309) 2025-09-05 16:19:47 +02:00
Semyon Moroz
e76464d161
gh-131178: Fix test_unknown_flag for platform CLI (#137816) 2025-09-05 16:59:46 +05:30
Christoph Walcher
ed53c63769
gh-138401: Check arg count>=0 in os.sendfile() (#138403)
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-09-05 09:16:55 +00:00
Donghee Na
f070f54c5f
gh-138192: Fix Context initialization so that all subinterpreters are assigned the MISSING value. (gh-138503)
---------

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-09-04 17:19:30 +00:00
Ken Jin
2402f84665
gh-138431: JIT Optimizer --- Fix round-tripping references for str and tuple (GH-138458)
Co-authored-by: Mark Shannon <9448417+markshannon@users.noreply.github.com>
2025-09-04 02:05:06 +08:00
Jakub Kulík
34ed03875a
gh-91214: Skip tests failing on Solaris (GH-31978) 2025-09-03 17:00:53 +03:00
Cody Maloney
6dd21e9f56
gh-138013: Remove test_io load_tests namespace manipulation (#138366)
Reduce what happens in `load_tests` so that the next change,
moving the `Buffered*` tests to `test_bufferdio` is purely mechanical
movement and updating imports.

This adds two classes, one per I/O implementation, to act as dispatch to
the implementation-specific mocks as well as module members. Previously
the mappings CTestCase and PyTestCase provide were injected directly
during `load_tests`.

CTestCase and PyTestCase inherit from `unittest.TestCase` so when the
split happens default test discovery will work for the classes in
`test_bufferedio`. `test_general` keeps a manual test list for this
refactoring; some of the tests (ex. `ProtocolsTest`) aren't currently
run and fixing that + helpers to not be picked up is out of my current
scope.

CTestCase and PyTestCase have an `io` class member which points to the
implementation meaning that can be removed from individual test cases
which now inherit from them.

This code is picking up `MockRawIO` which is defined globally in the
module but these should use the mock specific to the I/O implementation
being tested.

Co-authored-by: Victor Stinner <vstinner@python.org>
2025-09-03 11:49:59 +02:00
Cody Maloney
974532e758
gh-138013: Move I/O tests to test_io (#138365)
Centralize `io` tests into the `test_io` module so they are easier to
find and work on. This will make it easier to split `test_general` which
takes 30+ seconds in a debug build on my machine.

This renames `test_bufio` to be `test_bufferedio` so that it matches
the implementation file name (`bufferedio.c`).

Validation performed:
Tests are run in parallel after change:

```bash
./python.exe -m test test_io  -uall,largefile,extralargefile -M12G -j8
```

Docstring reformat in `test_io/__init__.py` looks reasonable:

```python
>>> import test.test_io
>>> help(test.test_io)
```

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-09-03 11:37:06 +02:00
Serhiy Storchaka
7274d07607
gh-78502: Add a trackfd parameter to mmap.mmap() on Windows (GH-138238)
If trackfd is False, the file handle corresponding to fileno
will not be duplicated.
2025-09-03 11:31:34 +03:00
Serhiy Storchaka
4a33077fdb
gh-138264: Fix gcc 14 compiler warnings (GH-138265) 2025-09-03 11:26:56 +03:00
Zackery Spytz
32032ee376
gh-87595: Support mmap.size() for anonymous mapping on Unix (GH-24781)
Previously, the size would be returned on Windows and an OSError would
be raised on Unix.

Also, raise ValueError instead of OSError for trackfd=False.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-09-02 23:24:06 +03:00
Brian Schubert
5493b46462
gh-138372: Fix SyntaxWarning for erroneous t-string subscription (#138375) 2025-09-02 18:13:12 +01:00
AN Long
b3e785c76c
gh-138314: Add winreg.DeleteTree (GH-138388) 2025-09-02 17:04:57 +00:00
Pieter Eendebak
2d3711dc06
gh-136599: Add tests for long_hash (#138335)
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
2025-09-02 18:42:12 +02:00
Serhiy Storchaka
33fcb0c4a0
gh-138204: Forbid expansion of a shared anonymous mmap on Linux (GH-138220)
This is a Linux kernel bug which caused a bus error.
https://bugzilla.kernel.org/show_bug.cgi?id=8691
2025-09-02 19:00:39 +03:00
jadonduff
c19db1d2b8
gh-138004: Fix setting a thread name on OpenIndiana (GH-138017)
Encode Solaris/Illumos thread names to ASCII, since
OpenIndiana does not support non-ASCII names.

Add tests for setting non-ASCII name for the main thread.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-09-02 15:26:25 +00:00
Sebastian Rittau
3f23888fd7
gh-127647: Fix and enable I/O protocol tests (#138369) 2025-09-02 06:45:29 -07:00
Serhiy Storchaka
cb18269e1b
gh-138253: Fix compatibility of sub-interpreters queues with queue.Queue (GH-138256)
Add the block parameter in the put() and get() methods of
the concurrent.interpreters queues for compatibility with the
queue.Queue interface.
2025-09-02 08:59:20 +03:00
Gregory P. Smith
a2ba0a7552
gh-61206: Support zstandard compression in the zipimport module (GH-138254)
* gh-61206: support zstd in zipimport

* NEWS entry

* versionchanged doc
2025-09-01 17:14:23 -07:00
Christoph Walcher
47bc10e6b3
gh-135763: AC: Implement `allow_negative for Py_ssize_t` (#138150)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-09-01 22:55:22 +01:00
Andrey
7c92497e5c
gh-138360: Fix test_free_threading for IO objects (#138359)
Fix typo in test_io.py
2025-09-01 19:53:13 +00:00
Tapeline
ea77feecbb
gh-138302: Specialize int ops only if ints are compact (GH-138347) 2025-09-02 01:33:15 +08:00
Marc Mueller
6528cf47a0
gh-90548: Fix musl version detection with --strip-all (#137864)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-09-01 18:58:45 +02:00
Pieter Eendebak
0d02e4d7d3
gh-116738: Fix test_json_mutating_exact_dict (#138339)
Fix test_json_mutating_exact_dic
2025-09-01 21:44:19 +05:30
Jason R. Coombs
9b38c6698a
Reapply "gh-132947: Apply changes from importlib_metadata 8.7 (#137885)" (#137924) (#137930)
* Reapply "gh-132947: Apply changes from importlib_metadata 8.7 (#137885)" (#137924)

This reverts commit 3706ef66ef.

* Skip the triggering test on buildbots only.
2025-09-01 11:27:01 -04:00
Hood Chatham
11a5fc8238
gh-138130: Fix return value of libc_ver() on Emscripten (#138132)
Emscripten's libc is a hybrid of musl and llvm libc; but it reports that it is
"glibc". This modifies the return value of `platform.libc_ver()` to return
something that is Emscripten-specific.
2025-09-01 06:50:29 +08:00
Cody Maloney
15e37ea6b7
gh-138013: Make `test.test_io` into a package (#138153) 2025-08-31 20:14:19 +01:00
Pieter Eendebak
43573028c6
gh-116738: Make _json module thread-safe in the free-threading (#119438)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-08-31 09:42:45 +05:30
Ron Frederick
bacb7771fb
gh-137197: Add SSLContext.set_ciphersuites to set TLSv1.3 ciphers (#137198)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-08-30 09:32:11 +00:00
Wulian233
5c6937ad20
gh-133656: Remove deprecated zipimport.zipimporter.load_module (GH-133662)
Remove deprecated `zipimport.zipimporter.load_module`.
2025-08-30 01:28:18 +00:00
Ju4tCode
025a2135ef
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.
2025-08-28 17:57:53 +03:00
Semyon Moroz
f914e0ab09
gh-136438: Make sure test_compile pass with all optimization levels (GH-136478) 2025-08-28 11:30:15 +02:00
Pablo Galindo Salgado
56eb6b64a0
gh-138122: Implement PEP 799 (#138142) 2025-08-27 17:52:50 +01:00
Serhiy Storchaka
0dbbf61cc2
gh-71679: Improve tests for repr() of bytes and bytearray (GH-138180)
* 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.
2025-08-27 13:24:28 +03:00
Rani Pinchuk
fd8f42d3d1
gh-135427: Fix DeprecationWarning for os.fork when run in threads with -Werror (GH-136796)
Don't ignore errors raised by `PyErr_WarnFormat` in `warn_about_fork_with_threads`
Instead, ignore the warnings in all test code that forks. (That's a lot of functions.)

In `test_support`, make `ignore_warnings` a context manager (as well as decorator),
and add a `message` argument to it.
Also add a `ignore_fork_in_thread_deprecation_warnings` helper for the deadlock-in-fork
warning.
2025-08-26 15:33:21 +02:00
Jakub Kulík
f60f8225ed
gh-137481: Fix test_calendar on Solaris and OpenIndiana (GH-138156)
In some locales (e.g. pt_PT.UTF-8), the abbreviated weekday names
are longer than three character.
2025-08-26 14:21:09 +03:00
Wulian233
81268a3e2a
gh-136507: Fix mimetypes CLI to handle multiple file parameters (GH-136508)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-08-25 16:38:43 +02:00