Commit Graph

54831 Commits

Author SHA1 Message Date
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
mpage 3cfab449ab
gh-132578: Rename the `threading.Thread._handle` field (#132696)
Commit `0e9c364f` introduced the `_handle` field on instances of
`threading.Thread`. Unfortunately it's fairly common for subclasses
of `threading.Thread` to define a `_handle()` method, which is shadowed
by the new field.
2025-04-21 16:07:54 -07: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
Jelle Zijlstra a8ca26d250
annotationlib: Remove some unnecessary dict copies (#132495) 2025-04-16 06:16:13 -07: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
Bogdan Romanyuk 884df116d7
gh-114713: Handle case of an empty string passed to `zoneinfo.ZoneInfo` (#114731)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
2025-04-15 18:41:52 +00:00
Barney Gale f3192dac66
GH-90812: Add test for `urlopen()` of file URI for UNC path (#132489) 2025-04-15 19:16:34 +01:00
Jelle Zijlstra 666eeda13d
gh-132493: Support deferred annotations in Protocols (#132494) 2025-04-15 10:14:27 -07:00
sobolevn b6c552f9e6
gh-132176: Fix crash on `type()` when `tuple` subclass passed as `bases` (#132212)
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-04-15 14:13:51 +03:00
Sergey B Kirpichev e10fe81cc6
gh-130664: support '_' (just as ',') in Decimal's formatting (#132155) 2025-04-15 12:38:03 +02:00
Barney Gale 0879ebc953
GH-123599: Match `file:` URL hostname against machine hostname in urllib (#132523)
In `_is_local_authority()`, return early if the authority matches the
machine hostname from `socket.gethostname()`, rather than resolving the
names and matching IP addresses.
2025-04-15 01:05:06 +01:00
Serhiy Storchaka 61638418a7
gh-70145: Add support for channels in Bluetooth HCI protocol (GH-132481) 2025-04-14 20:09:16 +03:00
Stan Ulbrych d22604a6d1
gh-85702: Catch IsADirectoryError in zoneinfo (#131333)
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-04-14 17:07:51 +00:00
Bénédikt Tran 45c447bf91
gh-132515: de-duplicate `test_dataclass_derived_generic_from_slotted_base` (#132516) 2025-04-14 15:06:38 +00:00
Mark Shannon 844596c09f
GH-131498: Cases generator: Allow input and 'peek' variables to be modified (GH-132506) 2025-04-14 12:19:53 +01:00
Serhiy Storchaka 522766aa23
gh-71339: Use new assertion methods in the email tests (GH-129055) 2025-04-14 09:25:58 +03:00
Serhiy Storchaka 7076d076c2
gh-71339: Use new assertion methods in the http tests (GH-129058) 2025-04-14 09:24:54 +03:00
Serhiy Storchaka f98b9b4cbb
gh-71339: Use new assertion methods in the urllib tests (GH-129056) 2025-04-14 09:24:41 +03:00
Gregory P. Smith 7a29c9883f
GH-115322: fix ctypes call_function audit hook on 32-bit platforms (GH-132496)
* GH-115322: fix ctypes call_function audit hook on 32-bit platforms.

It was using a signed conversion to communicate the function id (pointer) value.
2025-04-14 06:22:29 +00:00
Serhiy Storchaka f7b24ffefd
gh-124986: Fix test_no_leaking in test_subprocess on NetBSD and FreeBSD (GH-132476)
On platforms where the file descriptor limit is larger than FD_SETSIZE
that test was always skipped (FreeBSD) or always failing (NetBSD).
2025-04-14 09:15:12 +03:00
Serhiy Storchaka 1fc1df8dcc
gh-132099: Harmonize Bluetooth address handling (GH-132486)
Now all protocols always accept the Bluetooth address as string and
getsockname() always returns the Bluetooth address as string.

* BTPROTO_SCO now accepts not only bytes, but str.
* BTPROTO_SCO now checks address for embedded null.
* On *BSD, BTPROTO_HCI now accepts str instead of bytes.
* On FreeBSD, getsockname() for BTPROTO_HCI now returns str instead of bytes.
* On NetBSD and DragonFly BDS, BTPROTO_HCI now checks address for embedded null.
2025-04-14 08:58:56 +03:00
Barney Gale ccad61e35d
GH-125866: Support complete "file:" URLs in urllib (#132378)
Add optional *add_scheme* argument to `urllib.request.pathname2url()`; when
set to true, a complete URL is returned. Likewise add optional
*require_scheme* argument to `url2pathname()`; when set to true, a complete
URL is accepted.

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-04-14 01:49:02 +01:00
Jelle Zijlstra 4d3ad0467e
gh-132064: Make annotationlib use __annotate__ if only it is present (#132195) 2025-04-13 16:32:44 -07:00
abhi-jha a1cd4ca7f4
gh-132388: fix typos in `Lib/test/test_hmac.py` (#132480)
Fix typos that slipped in GH-132389 (commit 9634085af3).
2025-04-13 22:26:58 +00:00
Tian Gao 084d6dc122
gh-120144: Refactor bdb monitoring backend to match settrace behavior (#132484) 2025-04-13 17:49:35 -04:00
Robin Jadoul 2666a06d33
GH-115322: Add missing audit hooks (GH-115624)
Add extra audit hooks to catch C function calling from ctypes,
reading/writing files through readline and executing external
programs through _posixsubprocess.

* Make audit-tests for open pass when readline.append_history_file is unavailable
* Less direct testing of _posixsubprocess for audit hooks
* Also remove the audit hook from call_cdeclfunction now that _ctypes_callproc does it instead.
* reword the NEWS entry.
* mention readline in NEWS
* add versionchanged markers
* fix audit_events.rst versionadded
* doc lint

---------

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2025-04-13 21:46:20 +00:00
Kumar Aditya ce753517a8
gh-86513: improve docs of loop.call_exception_handler (#132466) 2025-04-13 21:39:24 +00:00
Tomas R. 887eabc5a7
gh-132435: Test syntax warnings in a finally block (GH-132436) 2025-04-13 20:44:00 +00:00
Charles Machalow 5863cd70b8
gh-132106: Ensure that running `logging.handlers.QueueListener` cannot be started again (GH-132444)
Prevents a thread leak
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-04-13 08:53:13 +01:00
Serhiy Storchaka 718d234e40
gh-132429: Remove not working test for Bluetooth socket (GH-132459) 2025-04-12 22:35:28 +00:00
Serhiy Storchaka f2f86d3f45
gh-132429: Fix support of Bluetooth sockets on NetBSD and DragonFly BSD (GH-132431)
* Also add support for cid and bdaddr_type in the BTPROTO_L2CAP address on FreeBSD.
* Return cid in getsockname() for BTPROTO_L2CAP if it is not zero.
* Fix a compiler warning on FreeBSD.
2025-04-12 23:57:34 +03:00
Bénédikt Tran 9634085af3
gh-132388: Increase test coverage for HMAC (#132389)
- Correctly test missing `digestmod` and `digest` parameters.
- Test when chunks of length > 2048 are passed to `update()`.
- Test one-shot HMAC-BLAKE2.
2025-04-12 17:43:11 +00:00
Serhiy Storchaka 842ab81517
gh-132185: Speed up expanduser() test with large password database (GH-132231)
Use only a limited number of randomly selected entries.
2025-04-12 16:17:52 +00:00
Adorilson Bezerra 891465fc7a
gh-58211: Add tests for the `__self__` attribute of builtins functions (#113575)
---------

Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-04-12 12:02:43 +00:00
Charles Machalow 517e96b9ed
gh-132106: Allow `logging.handlers.QueueListener` to be used as a context manager (#132107) 2025-04-12 12:00:04 +00:00
Tomas R. 3d08c8ad20
gh-131927: Prevent emitting optimizer warnings twice in the REPL (#131993) 2025-04-12 11:34:36 +01:00
Maksim 292a7248cd
gh-131290: ensure that test files can be executed as standalone scripts (#131371)
---------

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-04-12 07:46:19 +00:00
Nicolas Trangez 2aab2db146
GH-132417: ctypes: Fix potential `Py_DECREF(NULL)` when handling functions returning `PyObject *` (#132418)
Some functions (such as `PyErr_Occurred`) with a `restype` set to `ctypes.py_object` may return NULL without setting an exception.
2025-04-12 07:40:34 +00:00
Bénédikt Tran e1f93ff484
gh-132097: skip tests raising an explicit SIGSEV when UB sanitizer is on (#132398) 2025-04-12 09:18:58 +02:00
Kumar Aditya 05d27a84f4
gh-130322: drop deprecation of `asyncio.set_event_loop` (#132349) 2025-04-12 12:03:52 +05:30
Tomas R. e6ef47ac22
gh-132386: Fix a crash when passing a dict subclass to `exec` (GH-132412)
* Fix crash when passing a dict subclass to exec

* Add news entry
2025-04-12 05:05:03 +08:00
Serhiy Storchaka e5f8b2c703
gh-85302: Add support for BTPROTO_SCO on FreeBSD (GH-131981)
BTPROTO_SCO has been supported on FreeBSD since 2008.
2025-04-11 19:38:17 +03:00
Xuehai Pan 26ae05e95c
gh-127405: Add ABIFLAGS to sysconfig variables on Windows (GH-131799) 2025-04-11 16:19:03 +01:00
Karolina Surma 3e1a47bdb4
gh-132356: Find the correct group name in test_group_no_follow_symlinks (#132357)
Find the correct group name in test_group_no_follow_symlinks
2025-04-11 15:58:39 +01:00
Mark Shannon d87e7f3529
GH-127682: Only call `__iter__` once in generator expressions. (GH-132351) 2025-04-11 09:37:22 +01:00
Jelle Zijlstra 07b8d3117f
gh-132261: Store annotations at hidden internal keys in the class dict (#132345) 2025-04-10 21:13:26 -07:00
Barney Gale 66cdb2bd8a
GH-123599: `url2pathname()`: handle authority section in file URL (#126844)
In `urllib.request.url2pathname()`, if the authority resolves to the
current host, discard it. If an authority is present but resolves somewhere
else, then on Windows we return a UNC path (as before), and on other
platforms we raise `URLError`.

Affects `pathlib.Path.from_uri()` in the same way.

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-10 19:58:04 +00:00
Stan Ulbrych a214db0c54
gh-132307: Remove unnecessary check in `asyncio/base_events.py` (#132324) 2025-04-10 15:41:32 +00:00
Tomas R. 4d58c8cb24
gh-130320: gettext: Test fallback translations (GH-130321) 2025-04-10 14:56:21 +03:00
sobolevn fcf2d07228
gh-132316: Require `socket` and `GITHUB_TOKEN` env to use `GitHubArtifactDatabase` (#132348)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-04-10 14:30:58 +03:00
Tomas R. b6760b7fa5
gh-130453: pygettext: Allow specifying multiple keywords with the same function name (GH-131380) 2025-04-10 11:06:40 +00:00
Neil Schemenauer d687900f98
gh-128384: Use a context variable for warnings.catch_warnings (gh-130010)
Make `warnings.catch_warnings()` use a context variable for holding
the warning filtering state if the `sys.flags.context_aware_warnings`
flag is set to true.  This makes using the context manager thread-safe in
multi-threaded programs.

Add the `sys.flags.thread_inherit_context` flag.  If true, starting a new
thread with `threading.Thread` will use a copy of the context
from the caller of `Thread.start()`.

Both these flags are set to true by default for the free-threaded build
and false for the default build.

Move the Python implementation of warnings.py into _py_warnings.py.

Make _contextvars a builtin module.

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-04-09 16:18:54 -07:00
Brandt Bucher 20926c73b5
GH-131798: Remove JIT guards for dict, frozenset, list, set, and tuple (GH-132289) 2025-04-09 14:32:21 -07:00
sobolevn 254110356d
gh-132285: Fix that `__annotate__` is not deleted when `__annotations__` is deleted (#132286) 2025-04-09 10:36:08 -07:00
Serhiy Storchaka 3feac7a093
gh-131434: Improve error reporting for incorrect format in strptime() (GH-131568)
In particularly, fix regression in detecting stray % at the end of the
format string.
2025-04-09 13:26:50 +03:00
Serhiy Storchaka 7ebbd27144
gh-130631: Make join_header_words() more similar to the original Perl version (GH-130632)
* Always quote strings with non-ASCII characters.
* Allow some non-separator and non-control characters (like "." or "-")
  be unquoted.
* Always quote strings that end with "\n".
* Use the fullmatch() method for clarity and optimization.
2025-04-09 11:08:04 +03:00
Serhiy Storchaka f5f1ac84b3
gh-112068: C API: Add support of nullable arguments in PyArg_Parse (GH-121303) 2025-04-08 22:08:00 +03:00
Tian Gao ab64130b57
gh-132250: Clear error in lsprof callback when method descriptor raises an excep… (#132251) 2025-04-08 13:36:47 -04:00
Nadeshiko Manju d753d8aed7
GH-131798: Narrow the result of _CONTAINS_OP_DICT to bool in the JIT (GH-132269)
Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
2025-04-08 09:12:09 -07:00
Tomas R. 71009cb835
GH-131798: Narrow the result type of _BINARY_OP_SUBSCR_STR_INT to str in the JIT (GH-132153) 2025-04-08 08:22:54 -07:00
Duprat 933c6653cb
gh-132063: ensure that `ProcessPoolExecutor` does not swallow falsey exceptions (#132129) 2025-04-08 15:11:13 +00:00
Hugo van Kemenade c5e856a5dc Merge branch 'main' of https://github.com/python/cpython 2025-04-08 17:08:21 +03:00
Bénédikt Tran f5a7037c32
gh-93096: fix `test_mimetypes.test_invocation_error` tests on iOS ARM64 (#132266) 2025-04-08 15:03:43 +02:00
Serhiy Storchaka 0e4cf9ce7c
gh-50333: Deprecate support of non-tuple sequences in PyArg_ParseTuple() (GH-128374)
Non-tuple sequences are deprecated as argument for the "(items)" format unit
in PyArg_ParseTuple() and other argument parsing functions if items contains
format units which store borrowed buffer or reference (e.g. "s" and "O").

str and bytearray are no longer accepted as valid sequences.
2025-04-08 14:26:32 +03:00
Hugo van Kemenade 29af6cee02 Python 3.14.0a7 2025-04-08 14:20:51 +03:00
Serhiy Storchaka 0f04f2456a
gh-117779: Fix reading duplicated entries in zipfile by name (GH-129254) 2025-04-08 13:56:42 +03:00
Peter Bierma ac3c439cdf
gh-131998: Fix `NULL` dereference when using an unbound method descriptor in a specialized code path (#132000)
Co-authored-by: sobolevn <mail@sobolevn.me>
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Mark Shannon <mark@hotpy.org>
2025-04-08 10:31:43 +00:00
Bénédikt Tran 3eda146035
gh-74598: add `fnmatch.filterfalse` for excluding names matching a patern (#121185) 2025-04-08 10:11:25 +00:00
Adam Turner ee3657209b
gh-118761: Optimise import time for ``string`` (#132037)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-04-08 10:05:48 +00:00
Bénédikt Tran 53908bd790
gh-93096: fix `test_mimetypes.test_guess_type_conflicting_with_mimetypes` (#131408) 2025-04-08 09:08:59 +00:00
Srinivas Reddy Thatiparthy (తాటిపర్తి శ్రీనివాస్ రెడ్డి) 403886c28d
gh-132021: Add bool type to the list of allowed JSON key types (#132048)
Co-authored-by: Eric V. Smith <ericvsmith@users.noreply.github.com>
2025-04-08 11:25:46 +03:00
sobolevn f7305a06c7
gh-115942: Add `locked` to several multiprocessing locks (#115944)
Co-authored-by: mpage <mpage@cs.stanford.edu>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-04-08 11:14:12 +03:00
Emma Smith 6cd1d6c6b1
gh-84481: Make ZipFile.data_offset more robust (#132178) 2025-04-08 10:43:14 +03:00
Inada Naoki e2b35ee229
enum: remove unused function (#132044) 2025-04-08 09:23:48 +09:00
sobolevn bc5233b6a5
gh-130775: Allow negative locations in `ast` (#130795)
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-04-07 19:35:17 +03:00
sobolevn 3980718710
gh-132171: Fix `_interpreters.run_string` crash on string subclass (#132173) 2025-04-07 14:59:44 +03:00
btwood 895d983b5c
gh-61456: Add Thai language codec aliases (#15079)
Adding aliases for Thai language support. The current code page is an implementation of the windows code page.
This will alias '874', 'ms874', and 'windows_874' to cp874, adding Thai language support for those users.

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2025-04-07 13:06:32 +02:00
Vincent Fazio 4c5dcc6d82
gh-129204: Add _PYTHON_SUBPROCESS_USE_POSIX_SPAWN environment knob (GH-132184)
* Add _PYTHON_SUBPROCESS_USE_POSIX_SPAWN environment knob

Add support for disabling the use of `posix_spawn` via a variable in
the process environment.

While it was previously possible to toggle this by modifying the value
of `subprocess._USE_POSIX_SPAWN`, this required either patching CPython
or modifying it within the interpreter instance which is not always
possible, such as when running applications or scripts not under a
user's control.

Signed-off-by: Vincent Fazio <vfazio@gmail.com>

* fixup NEWS entry

---------

Signed-off-by: Vincent Fazio <vfazio@gmail.com>
2025-04-06 20:53:02 -07:00
Brian Schubert e2476398ee
gh-132168: Add `__class_getitem__` to `ctypes.py_object` (#132169) 2025-04-06 22:05:19 +01:00
Emma Smith 0788948dcb
gh-84481: Add ZipFile.data_offset attribute (#132165)
* Add ZipFile.data_offset attribute

This attribute provides the offset to zip data from the start of the file, when available.

* Add blurb-it

* Try fixing class ref in NEWS
2025-04-06 13:51:42 -07:00
Tomas R. a693eaa710
gh-132121: Always escape non-printable characters in pygettext (GH-132122) 2025-04-06 23:15:17 +03:00
Xuehai Pan 7bb1e1a236
gh-132159: Do not shadow user arguments in generated `__new__` by `@warnings.deprecated` (#132160) 2025-04-06 16:37:37 +00:00
sobolevn c0661df42a
gh-132011: Fix crash on invalid `CALL_LIST_APPEND` deoptimization (#132018)
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-04-06 19:10:39 +03:00
Semyon Moroz f247e1d04c
gh-131178: Add tests for `pickle` command-line interface (#131275)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-04-06 11:50:32 -04:00
Srinivas Reddy Thatiparthy (తాటిపర్తి శ్రీనివాస్ రెడ్డి) 0a10b45dd1
Docs: Replace dead hyperlink for CGI environment variables (#132137) 2025-04-06 10:12:48 +02:00
Tomas R. 85bc489b64
GH-131798: Narrow the result of _CONTAINS_OP_SET to bool in the JIT (GH-132057) 2025-04-05 15:56:01 -07:00
Stan Ulbrych ad6a032ceb
gh-131852: Filter out POT-Creation-Date in msgfmt (GH-131880)
Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
2025-04-05 22:38:39 +03:00
Adam Turner 1755157207
GH-118761: Expose more core interpreter types in ``_types`` (#132103)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-04-05 18:11:07 +00:00
Serhiy Storchaka ef70f02925
Skip a test for Bluetooth HCI socket (added in GH-132023) if it fails (GH-132072) 2025-04-05 16:41:57 +03:00
Semyon Moroz 37bc3865c8
gh-85162: Add `HTTPSServer` to `http.server` to serve files over HTTPS (#129607)
The `http.server` module now supports serving over HTTPS using the `http.server.HTTPSServer` class.
This functionality is also exposed by the command-line interface (`python -m http.server`) through the
`--tls-cert`, `--tls-key` and `--tls-password-file` options.
2025-04-05 08:49:48 +00:00
Ageev Maxim 05557788f3
gh-131015: Add test for bytes formatting errors (#131881)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-04-05 10:30:16 +02:00
Jelle Zijlstra ac14d4a23f
gh-129463, gh-128593: Simplify ForwardRef (#129465) 2025-04-05 04:36:34 +00:00
Adam Turner 231a50fa9a
gh-109599: Expose `CapsuleType` via the `_types` module (#131969) 2025-04-04 23:37:41 +01:00
Victorien ac3a7bfecc
Fix typo in `template_replace()` test helper docstring (#132094) 2025-04-04 17:38:09 +00:00