Commit Graph

33606 Commits

Author SHA1 Message Date
Tomas R. 5e96e4fca8
gh-131798: JIT: Propagate the result in `_BINARY_OP_SUBSCR_TUPLE_INT` (GH-133003) 2025-04-27 02:47:55 +08:00
Stan Ulbrych 56c88e4e8d
gh-63882: Use `self.assert*` methods in `test_minidom` (#133000) 2025-04-26 18:24:54 +00:00
Tian Gao 0eb0e70ca0
gh-133006: Add subprocess check for remote pdb test (#133014) 2025-04-26 19:09:09 +01:00
Serhiy Storchaka 632524a5cb
gh-132987: Support __index__() for "k" and "K" formats in PyArg_Parse (GH-132988) 2025-04-26 17:14:18 +03:00
Bénédikt Tran e714ead7a2
gh-132388: remove outdated TODO comment in `test_hmac.py` (#133008) 2025-04-26 13:17:03 +00:00
Bénédikt Tran 7f02ded29f
gh-91221: fix `test_curses.test_use_default_colors` for xterm-256color (#132990)
Terminals with `xterm-256color` Xterm support may use 15 (bright white) as their default foreground color.
2025-04-26 10:38:27 +00:00
Eric Snow cd9536a087
gh-132781: Cleanup Code Related to NotShareableError (gh-132782)
The following are added to the internal C-API:

* _PyErr_FormatV()
* _PyErr_SetModuleNotFoundError()
* _PyXIData_GetNotShareableErrorType()
* _PyXIData_FormatNotShareableError()

We also drop _PyXIData_lookup_context_t and _PyXIData_GetLookupContext().
2025-04-25 14:43:38 -06:00
Diego Russo 4c20f46fa0
gh-131798: JIT: Narrow the return type of _CALL_LEN to int (#132940)
Reduce unnecessary guards whenever `len()` is called and used
after.

Co-authored-by: Max Bernstein <tekknolagi@gmail.com>
2025-04-26 02:57:42 +08:00
Victor Stinner f0485de43a
gh-132950: Log is_remote_debug_enabled() in pythoninfo (#132965)
Log also the Py_REMOTE_DEBUG macro.
2025-04-25 18:13:47 +00:00
Tian Gao a1f4a6b246
gh-132912: Use readline to synchronize between procs in remote pdb test (#132949) 2025-04-25 18:40:18 +01:00
Victor Stinner 947c4f19d9
gh-132950: Skip test_remote_pdb if remote exec is disabled (#132951) 2025-04-25 17:28:25 +00:00
Victor Stinner 070d866567
gh-107954: Allow setting cpu_count in PyConfig_Set() (#132954)
* gh-107954: Allow setting cpu_count in PyConfig_Set()

* Update the doc
2025-04-25 18:29:55 +02:00
Victor Stinner 670b6cc096
gh-132912: Use SHORT_TIMEOUT in test_remote_pdb (#132939)
Replace hardcoded timeout of 5 seconds with SHORT_TIMEOUT.
2025-04-25 14:00:26 +00:00
Pablo Galindo Salgado 6cbeb6ab91
gh-132912: Account for race in test_keyboard_interrupt in test_remote_pdb (#132929) 2025-04-25 14:46:44 +01:00
Pablo Galindo Salgado e8cf3a1a64
gh-91048: Refactor _testexternalinspection and add Windows support (#132852) 2025-04-25 14:12:16 +01:00
Srinivas Reddy Thatiparthy (తాటిపర్తి శ్రీనివాస్ రెడ్డి) 8783cec9b6
gh-129027: Raise DeprecationWarning for sys._clear_type_cache (#129043)
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>
2025-04-25 15:01:48 +03:00
Victor Stinner b402a4889b
gh-132912: Skip flaky test in test_remote_pdb (#132924) 2025-04-25 11:46:43 +00:00
Victor Stinner 79ba56433e
gh-132912: Kill the process on error in test_remote_pdb (#132920)
If a test fails (such as an assertion error), kill the child process.
2025-04-25 13:14:59 +02:00
Victor Stinner de6482eda3
gh-132415: Use shutil.which() in missing_compiler_executable() (#132906)
Replace deprecated distutils.spawn.find_executable() with
shutil.which() in missing_compiler_executable() of test.support.
2025-04-25 11:50:55 +02:00
Victor Stinner 9cba14881b
gh-127906: Add missing sys import to test_cppext (#132902) 2025-04-25 10:19:26 +02:00
Bénédikt Tran 9888f175de
gh-131652: remove duplicated bits in `Lib/test/clinic.test.c` (#131653) 2025-04-25 10:19:12 +02:00
Ethan Furman 22bc953aa9
gh-132684: [Enum] only call _missing_ in __contains__ for Flags (GH-132790)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-04-24 23:13:54 -07:00
Steele Farnsworth 99b71efe8e
gh-129858: Special syntax error for `elif` block after `else` (#129902) 2025-04-25 01:25:48 +00:00
Tomas R. c3a7118065
gh-69605: Add module autocomplete to PyREPL (#129329) 2025-04-25 02:24:26 +01:00
Matt Wozniski 797b29b1b5
gh-131591: Allow pdb to attach to a running process (#132451)
Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
2025-04-25 01:43:23 +01:00
Adam Turner c9f3f5b4ed
gh-132415: Update vendored setuptools in ``Lib/test/wheeldata`` (#132887) 2025-04-25 00:46:20 +01:00
Tomas R. 08e3389e8c
GH-131798: Split up and optimize CALL_TUPLE_1 in the JIT (GH-132851) 2025-04-24 15:55:03 -07:00
Tian Gao eef49c3595
gh-93696: Fixed the breakpoint display error for frozen modules (#132862) 2025-04-24 16:07:27 -04:00
Tomas R. 0a387b311e
GH-131798: Split up and optimize CALL_STR_1 in the JIT (GH-132849) 2025-04-24 12:54:46 -07:00
Aneesh Durg c7a7aa9a57
gh-132737: Support profiling modules that require __main___ (#132738) 2025-04-24 14:41:01 -04:00
Jelle Zijlstra e1c09fff05
gh-132882: Fix copying of unions with members that do not support __or__ (#132883) 2025-04-24 16:49:09 +00:00
Serhiy Storchaka 8c975b0fdd
Use os.openpty() instead of pty.openpty() in test_ioctl (GH-132880)
pty.openpty() does not work on Android, and it is easier to check
availability of os.openpty.
2025-04-24 16:07:00 +00:00
alexey semenyuk d7365e6050
gh-132162: Add tests for Py_UniversalNewlineFgets() (#132164) 2025-04-24 17:43:48 +02:00
Adam Turner 06a26fda60
gh-118761: Optimise import time for ``shlex`` (#132036) 2025-04-24 16:10:46 +01:00
Stan Ulbrych 4924bcf0e4
gh-89157: Make C and Python implementation of `datetime.date.fromisoformat` consistent (#131007) 2025-04-24 17:16:07 +03:00
Matt Wozniski a94c7528b5
gh-132859: Run debugger scripts in their own namespaces (#132860)
Run debugger scripts in their own namespaces

Previously scripts injected by `sys.remote_exec` were run with the
globals of the `__main__` module. Instead, run each injected script
with an empty set of globals. If someone really wants to use the
`__main__` module's namespace, they can always `import __main__`.
2025-04-23 23:40:24 +00:00
Serhiy Storchaka 4b4b9fbb06
gh-83994, gh-132843: Fix and improve test_ioctl (GH-132848)
* Skip test_ioctl_tcflush if termios.TCFLSH is not available.
* Do not skip ALL ioctl() tests when /dev/tty is not available.
2025-04-23 21:45:55 +03:00
Victor Stinner e2c69d36d1
gh-132719: Skip multiprocessing test if missing ctypes (#132846)
Skip test_rlock_locked_2processes() if multiprocessing.sharedctypes
is missing (need ctypes).
2025-04-23 20:33:15 +02:00
Łukasz Langa c9bc458d30
gh-91048: Add ability to list all pending asyncio tasks in a process remotely (#132807) 2025-04-23 18:22:29 +01:00
Victor Stinner 426449d983
gh-132825: Enhance unhashable error messages for dict and set (#132828) 2025-04-23 17:10:09 +02:00
Victor Stinner b2e666f30a
gh-132719: Skip multiprocessing test if missing ctypes (#132842)
Skip test_lock_locked_2processes() if multiprocessing.sharedctypes is
missing (need ctypes).
2025-04-23 14:36:25 +00:00
Pablo Galindo Salgado 32c4bbe834
gh-132449: Improve the algorithm to detect typos in keywords (#132837) 2025-04-23 14:45:18 +01:00
Sergey B Kirpichev 85f89cb3e6
gh-121249: adjust formatting codes for complex types in struct/ctypes (#132827)
* F - for float _Complex
* D - for double _Complex
* G - for long double _Complex (not supported by the struct module)
2025-04-23 15:38:24 +02:00
Serhiy Storchaka d7be26a71e
gh-132734: Fix build on FreeBSD and old Linux (GH-132829) 2025-04-23 14:08:30 +03:00
pulkin 77605fa3bb
gh-131913: multiprocessing: add interrupt for POSIX (GH-132453)
* multiprocessing: interrupt

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-04-22 23:55:24 -07:00
John 862fd89036
gh-109981: Resolve situation on iOS regarding fd_count. (#132823)
Modifies the test helper that counts the list of open file descriptors to use
the optimised ``/dev/fd`` approach on all Apple platforms, not just macOS. This
avoids crashes caused by guarded file descriptors.
2025-04-23 03:22:57 +00:00
Victor Stinner a4ea80d523
gh-132713: Fix repr(list) race condition (#132801)
Hold a strong reference to the item while calling repr(item).
2025-04-22 22:09:35 +02:00
Tomas R. a6a3dbb7db
GH-131798: JIT: Split CALL_TYPE_1 into several uops (GH-132419) 2025-04-22 09:30:38 -07:00
dura0ok 3b4b56f46d
gh-132470: Prevent crash in ctypes.CField when `byte_size` is incorrect (#132475)
Fix: Prevent crash in ctypes.CField when byte_size does not match type size  (gh-132470)

When creating a ctypes.CField with an incorrect byte_size (e.g., using `byte_size=2` for `ctypes.c_byte`), the code would previously abort due to the failed assertion `byte_size == info->size`.

This commit replaces the assertion with a proper error handling mechanism that raises a `ValueError` when `byte_size` does not match the expected type size. This prevents the crash and provides a more informative error message to the us

Co-authored-by: sobolevn <mail@sobolevn.me>
2025-04-22 16:13:00 +03:00
Sergey B Kirpichev 79f7c67bf6
gh-128813: hide mixed-mode functions for complex arithmetic from C-API (#131703) 2025-04-22 14:18:18 +02:00
Serhiy Storchaka e84624450d
gh-132734: Add new constants for Bluetooth sockets (GH-132735) 2025-04-22 11:02:13 +00:00
Sergey B Kirpichev d0660a9a40
gh-101410: Customize error messages for 1-arg math functions (#129497)
This also reverts loghelper() change in 75f59bb629 for integer
input.  The error message shouldn't include argument value here.

Co-authored-by: Victor Stinner <vstinner@python.org>
2025-04-22 11:29:20 +02:00
Pablo Galindo Salgado bf3a0a1c0f
gh-132449: Improve syntax error messages for keywords with typos (#132450)
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2025-04-22 11:01:55 +02:00
Sebastian Rittau 2b47f46d7d
gh-122179: Fix hashlib.file_digest and non-blocking I/O (GH-122183)
* Fix hashlib.file_digest and non-blocking I/O
* Add documentation around this behavior
* Add versionchanged
2025-04-21 14:15:05 -07:00
Peter Bierma fa70bf8593
gh-132747: Fix `NULL` dereference when calling a method's `__get__` manually (#132772) 2025-04-21 14:09:34 -07:00
Duprat c8e0b6e684
gh-132719: Fix AMD64 FreeBSD14/15 3.x failures - `test_rlock_locked_2processes` used an unknown `Value` (GH-132774)
* Fix creation of resvariable
2025-04-21 13:59:15 -07:00
Jelle Zijlstra 01317bb449
gh-132479: Fix crash with multiple comprehensions in annotations (#132778) 2025-04-21 13:49:59 -07:00
Peter Bierma 8dfa840773
gh-127604: Add C stack dumps to `faulthandler` (#128159) 2025-04-21 20:48:02 +01:00
Kumar Aditya 8516343d3a
gh-127945: add `test_ctypes` to free-threading TSAN CI (#132727) 2025-04-21 22:56:56 +05:30
Brandt Bucher 4f7f72ce34
GH-130415: Improve the JIT's unneeded uop removal pass (GH-132333) 2025-04-21 09:58:55 -07:00
Steve Dower 09b624b80f
gh-132639: Adds PyLong_AsNativeBytes, PyLong_FromNativeBytes and PyLong_FromUnsignedNativeBytes to the limited API (GH-132640) 2025-04-21 15:59:03 +01:00
Jelle Zijlstra 70b322d313
annotations: Add tests to check that async comprehensions produce errors (#132513)
This already works correctly but I forgot to test for it.
2025-04-21 07:06:33 -07:00
Саша Черных 132b6bc98f
gh-132054: Add ``application/yaml`` to ``mimetypes`` (#132056)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-04-21 12:05:37 +03:00
Serhiy Storchaka a04390b4da
gh-132742: Add more tests for fcntl.ioctl() (GH-132756)
Test with different types of argument: integer, mutable and immutable
buffers, immutable buffer with mutable_flag set to false.
2025-04-21 09:26:06 +03:00
Serhiy Storchaka 78cfee6f09
gh-132753: Argument Clinic: Fix support of c_default for the bool converter (GH-132754) 2025-04-20 23:21:29 +00:00
Bénédikt Tran 492e3e6976
gh-129098: avoid using content of `_pyrepl/__main__.py` when reporting tracebacks (#130721) 2025-04-20 18:24:30 +01:00
Tomas R. 71da68d588
gh-131952: Add colour to the ``json`` module CLI (#132126)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.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>
2025-04-19 18:11:21 +00:00
Adam Turner e7c5f60efc
gh-130167: Improve the error case for ``textwrap.dedent`` (#132666) 2025-04-19 16:18:03 +01:00
Duprat 69cda31261
gh-132308: prevent `TracebackException` swallowing attributes of a falsey `Exception` or `ExceptionGroup` (#132363) 2025-04-19 09:49:18 +00:00
Bénédikt Tran 8a9c6c4d16
gh-128398: improve error messages when incorrectly using `with` and `async with` (#132218)
Improve the error message with a suggestion when an object supporting the synchronous
(resp. asynchronous) context manager protocol is entered using `async with` (resp. `with`)
instead of `with` (resp. `async with`).
2025-04-19 10:44:01 +02:00
Chris Eibl 815061cbab
speedup test_pyrepl (#132688)
speedup test_unix_console.py and test_windows_console.py
2025-04-19 02:12:40 +01:00
Bénédikt Tran 1d5dc5f1c3
gh-132396: Resolve 'redefinition of unused name' errors in ``Lib/test/`` (#132397)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-04-18 18:14:54 +01:00
sobolevn 678b8e1656
gh-132673: Fix `ctypes.Structure` with `_align_=0` (#132676)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-04-18 17:32:28 +03:00
Łukasz Langa a594008d9e
gh-132678: Add --prioritize to regrtest (GH-132679)
This is an option that allows the user to specify, which selected tests should
execute first, even if the order is otherwise randomized.  This is particularly
useful for tests that run the longest.
2025-04-18 15:56:44 +02:00
Kumar Aditya b9f0943c1e
gh-127945: skip more tests in ctypes when using parallel threads (#132682) 2025-04-18 13:12:45 +00:00
Pablo Galindo Salgado 2f8b08da47
gh-129958: Properly disallow newlines in format specs in single-quoted f-strings (GH-130063) 2025-04-18 14:30:04 +02:00
Pablo Galindo Salgado e01e582902
gh-132553: Build the perf tool without buildid cache (GH-132663) 2025-04-18 14:26:59 +02:00
Jon Crall fc0ec29889
gh-103997: Automatically dedent the argument to "-c" (#103998)
Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
Co-authored-by: Kirill Podoprigora <80244920+Eclips4@users.noreply.github.com>
Co-authored-by: Inada Naoki <songofacandy@gmail.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-04-18 17:39:30 +09:00
Kumar Aditya cf59bc3ae7
gh-127945: fix critical sections around ctypes array (#132646) 2025-04-17 18:44:14 +00:00
Tomasz Pytel a23ed8b379
gh-132284: Don't wrap base PyCFunction slots on class creation if not overridden (#132329) 2025-04-17 18:08:59 +01:00
Jelle Zijlstra 5707837049
gh-132493: Avoid eager import of annotationlib in typing (again) (#132596)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2025-04-17 16:03:53 +00:00
Duprat 15c75d7a8b
gh-132561: Fix the public `multiprocessing.SemLock.locked` method (#132586)
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-04-17 11:41:30 +02:00
Sergey B Kirpichev 0c356c865a
gh-101410: Revert loghelper() change in 75f59bb for integer input (GH-132625) 2025-04-17 10:55:00 +03:00
Bartosz Sławecki 954b2cf031
gh-130070: Fix `exec(<string>, closure=<non-None>)` unexpected path (#130071)
Fixed an assertion error (so, it could be reproduced only in builds with assertions enabled)
for `exec` when the `source` argument is a string and the `closure` argument is not `None`.

Co-authored-by: sobolevn <mail@sobolevn.me>
2025-04-17 10:14:55 +03:00
Jelle Zijlstra 39ee468e09
gh-118761: Add helper to ensure that lazy imports are actually lazy (#132614)
This ensures that if we jump through some hoops to make sure something is imported
lazily, we don't regress on importing it.

I recently already accidentally made typing import warnings and annotationlib eagerly.

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-04-17 03:46:36 +00:00
Neil Schemenauer 591c982c6e
gh-128384: Fix for unreliable warnings unit tests. (gh-132611)
When the `showwarning()` function is replaced, make sure to restore
it after the test finishes.  Add a timeout for `Barrier()` so we
don't hang for a long time if something goes wrong.
2025-04-16 13:13:23 -07:00
Tian Gao 62173cc02c
Clean up pdb state after each pdb doctest (#132577) 2025-04-16 13:44:33 -04:00
Kumar Aditya 2925462411
gh-127945: change `_ctypes_test.c` static globals to thread local (#132575) 2025-04-16 23:11:27 +05:30
Nadeshiko Manju b9e88ff4cb
gh-131798: Use `sym_new_type` instead of `sym_new_not_null` for `_BUILD_LIST`, `_BUILD_SLICE`, and `_BUILD_MAP` (GH-132434)
---------

Signed-off-by: Manjusaka <me@manjusaka.me>
2025-04-17 01:17:48 +08:00
Serhiy Storchaka 62ff86fa55
gh-130104: Call __rpow__ in ternary pow() if necessary (GH-130251)
Previously it was only called in binary pow() and the binary
power operator.
2025-04-16 18:32:41 +03:00
Jelle Zijlstra 72da4a4458
typing: Add missing test case for Protocol inheritance (#132597) 2025-04-16 08:21:27 -07:00
Felix Scherz 71af090e24
gh-132493: lazy evaluation of annotations in `typing._proto_hook` (#132534)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: sobolevn <mail@sobolevn.me>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2025-04-16 08:20:35 -07:00
Jelle Zijlstra 7dcaebfb21
annotationlib: Move ForwardRef tests to test_annotationlib (#132571)
I started with just moving ForwardRefTests to test_annotationlib,
but found that it contained a number of tests for no_type_check, which
I moved to a new class in test_typing, as well as a number of tests that
are more appropriately classified as tests for get_type_hints().

One test, test_forward_equality_namespace(), was somewhat accidentally
depending on a global class A in test_typing. I added a class A in the
annotationlib tests instead.

Also add a useful comment in annotationlib.
2025-04-16 13:40:29 +00:00
sobolevn c35c7353eb
gh-130941: Fix `configparser` parsing values with `allow_no_value` and `interpolation` set (GH-130949) 2025-04-16 12:39:11 +02:00
Serhiy Storchaka 8b7cb947c5
gh-127591: Fix altering environment in test_urllib2 (unsetting no_proxy) (GH-132584) 2025-04-16 13:05:54 +03:00
Serhiy Storchaka 8cb177d09b
gh-132099: Accept an integer as the address for BTPROTO_HCI on Linux (GH-132525)
Previously only an integer packed in a tuple was accepted, while
getsockname() could return a raw integer.
Now the result of getsockname() is always acceptable as an address.
2025-04-16 13:02:51 +03:00
Serhiy Storchaka 82f74eb234
gh-132535: Fix resource warnings in test_timeout (GH-132572)
They were emitted if internet connection was not available.
2025-04-16 10:20:07 +03:00
Tian Gao d19af00b90
gh-132536: Do not disable PY_THROW event in bdb (#132537) 2025-04-15 18:31:52 -04:00
Jelle Zijlstra 11f6603845
gh-132491: Rename annotationlib.value_to_string to type_repr (#132492) 2025-04-15 20:10:53 +00:00
Jelle Zijlstra 5e80fee41a
gh-129463: Remove two attributes from ForwardRef equality (#132283) 2025-04-15 12:58:21 -07:00