Commit graph

15017 commits

Author SHA1 Message Date
Eric Snow
bdd23c0bb9
gh-132775: Add _PyMarshal_GetXIData() (gh-133108)
Note that the bulk of this change is tests.
2025-04-28 17:23:46 -06:00
Neil Schemenauer
22f0730d40
gh-122320: Limit dict key versions used by test_opcache. (gh-132961)
The `test_load_global_module()` test consumes a lot of dict key versions.
Skip the test if we have consumed half of the available versions that can be
used for the "load global" cache.
2025-04-28 12:54:55 -07:00
Eric Snow
6f04325992
gh-132775: Cleanup Related to crossinterp.c Before Further Changes (gh-132974)
This change consists of adding tests and moving code around, with some renaming thrown in.
2025-04-28 11:55:15 -06:00
Jelle Zijlstra
58567cc18c
gh-132952: Speed up startup by importing _io instead of io (#132957) 2025-04-28 08:38:56 -07:00
Serhiy Storchaka
c2eaeee3dc
gh-132915: Try to detect a buffer overflow in fcntl() and ioctl() (GH-132919)
SystemError is raised when buffer overflow is detected.
The stack and memory can already be corrupted, so treat this error as fatal.
2025-04-28 17:56:10 +03:00
Petr Viktorin
4ebbfcf30e
gh-87135: Raise PythonFinalizationError when joining a blocked daemon thread (gh-130402)
If `Py_IsFinalizing()` is true, non-daemon threads (other than the current one)
are done, and daemon threads are prevented from running, so they
cannot finalize themselves and become done. Joining them (without timeout)
would block forever.

Raise PythonFinalizationError instead of hanging.

Raise even when a timeout is given, for consistency with trying to join your own thread.

See gh-123940 for a use case: calling `join()` from `__del__`. This is
ill-advised, but an exception should at least make it easier to diagnose.
2025-04-28 15:48:48 +02:00
Sergey B Kirpichev
6157135a8d
gh-130317: Fix PyFloat_Pack/Unpack[24] for NaN's with payload (#130452)
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-04-28 15:23:26 +02:00
Sergey B Kirpichev
5bf0f3666e
gh-53032: support IEEE 754 contexts in the decimal module (#122003)
This was in C version from beginning, but available only
on conditional compilation (EXTRA_FUNCTIONALITY).  Current
patch adds function to create IEEE contexts to the
pure-python module as well.

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-04-28 15:05:56 +02:00
Bénédikt Tran
1b7470f8cb
gh-133061: do not mention UINT32_MAX in HMAC user-facing messages (#133062) 2025-04-28 01:14:12 +02:00
Bénédikt Tran
3695ba93d5
gh-132993: expose HASHLIB_GIL_MINSIZE to private extension modules (#132999) 2025-04-27 22:20:15 +00:00
Alyssa Ross
314f4b9716
gh-132991: Add socket.IP_FREEBIND constant (GH-132998) 2025-04-26 20:54:12 +03:00
Anthony Sottile
bd2e5f044c
gh-131298: update Modules/Setup after HACL* static linking changes (#133012)
This was overlooked in 5f2ba152a0.
2025-04-26 18:44:19 +02: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
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
Pablo Galindo Salgado
a5e628beb8
gh-91048: Prevent optimizing away the asyncio debug offsets structure on Windows (#132963)
To avoid having the debug sections being optimised away by the compiler
we use  __attribute__((used)) on gcc and clang but in Windows this is
not supported by the Microsoft compiler and there is no equivalent flag.
Unfortunately Windows offers almost no alternative other than exporting
the symbol in the dynamic table or using it somehow.
2025-04-25 17:43:32 +00:00
Eric Snow
2a28b21a51
gh-132776: Revert Moving memoryview XIData Code to memoryobject.c (gh-132960)
This is a partial revert of gh-132821.  It resolves the refleak introduced by that PR.
2025-04-25 16:43:50 +00:00
Victor Stinner
17718b0503
gh-91048: Fix _testexternalinspection.c on FreeBSD (#132945) 2025-04-25 14:57:01 +00:00
Christian Veenhuis
52454c5d59
gh-132527: Added missing w typecode to array() error message (#132529)
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
2025-04-25 16:31:05 +03:00
Pablo Galindo Salgado
e8cf3a1a64
gh-91048: Refactor _testexternalinspection and add Windows support (#132852) 2025-04-25 14:12:16 +01:00
Bénédikt Tran
6a9bfee4fa
gh-131423: Update OpenSSL data to 3.4.1 on Linux (#131618)
OpenSSL 3.4.1 mnemonics are not compatible with OpenSSL 3.4.0 ones since
they were renumbered [1, 2]. Consequently, `_ssl_data_34.h` is renamed to
`_ssl_data_340.h` and `_ssl_data_34.h` now contains OpenSSL 3.4.1 mnemonics.

We also refine the mnemonics that are selected, discarding those that are
mnemonic-like but should not be used as such. More precisely, we remove
the ERR_LIB_MASK and ERR_LIB_OFFSET entries from OpenSSL 1.1.1 data.

[1]: https://github.com/openssl/openssl/issues/26316
[2]: https://github.com/openssl/openssl/issues/26388
2025-04-25 10:26:58 +02:00
Sergey B Kirpichev
ecd03739f8
gh-132868: use _Alignof() C11 operator in the struct module (#132872) 2025-04-25 09:57:22 +02:00
Nadeshiko Manju
3a39e33ee4
gh-131591: Reset RemoteDebuggerSuupport state after fork (#132793)
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2025-04-25 01:40:01 +01:00
Eric Snow
e54e828852
gh-132776: Cleanup for XIBufferViewType (gh-132821)
* add notes
* rename XIBufferViewObject to xibufferview
* move memoryview XIData code to memoryobject.c
2025-04-24 18:25:29 -06:00
RUANG (James Roy)
8e18a9dce2
gh-127385: Add F_DUPFD_QUERY to fcntl (GH-127386) 2025-04-25 00:06:42 +03:00
Serhiy Storchaka
9f5994b94c
gh-132742: Refactor fcntl.fcntl() and fcntl.ioctl() (GH-132768)
* Support arbitrary bytes-like objects, not only bytes, in fcntl().
* The fcntl() buffer argument is now null-terminated.
* Automatically retry an ioctl() system calls failing with EINTR.
* Release the GIL for an ioctl() system call even for large bytes-like object.
* Do not silence arbitrary errors whet try to get a buffer.
* Optimize argument parsing, check the argument type before trying to get
  a buffer or convert it to integer.
* Fix some error messages.
2025-04-24 19:17:11 +03:00
alexey semenyuk
d7365e6050
gh-132162: Add tests for Py_UniversalNewlineFgets() (#132164) 2025-04-24 17:43:48 +02:00
Sergey B Kirpichev
580888927c
gh-121249: fix naming of struct tagPyCArgObject members (#132863)
It seems, no code actually uses these names, only sizes of the unnamed
union members are important.  Though, I think it's good to be here
consistent wrt type codes ('g' for long double, etc).

This amends 85f89cb3e6.
2025-04-24 11:50:47 +02:00
Pablo Galindo Salgado
99b13775da
gh-131591: Check for remote debug in PyErr_CheckSignals (#132853)
For the same reasons as running the GC, this will allow sections that
run in native code for long periods without executing bytecode to also
run the remote debugger protocol without having to wait until bytecode
is executed

Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
2025-04-23 20:59:41 +01: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
1aaca7ab48
gh-127604: Fix refleak in faulthandler_dump_c_stack_py() (#132840) 2025-04-23 14:29:31 +00: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
Eric Snow
b5bf8c80a9
gh-132776: Minor Fixes for XIBufferViewType (gh-132779)
This change covers the following:

* dealloc: no cleanup if no buffer set
* dealloc: handle already-destroyed interpreter correctly
* handle errors in _memoryview_from_xid() correctly
* clean up the buffer if the xidata is never used
2025-04-22 17:37:20 -06: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
Chris Eibl
f663b2c56a
GH-131296: Avoid invalid signed char comparison in getpath.c assertion (GH-131594) 2025-04-22 14:06:30 +01: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
Peter Bierma
8dfa840773
gh-127604: Add C stack dumps to faulthandler (#128159) 2025-04-21 20:48:02 +01: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
5f2ba152a0
gh-131298: eliminate HACL* static libraries for cryptographic modules (GH-132438)
* simplify HACL* build for MD5, SHA1, SHA2 and SHA3 modules

* remove statically linked libraries for HACL* implementation

* is it better now?

* is it better now?

* fixup

* Present HACL* as a static or shared library.

On WASI, extension modules based on HACL* require the HACL*
library to be linked statically. On other platforms, it can
be built dynamically.

* amend whitespace

* remove temporary .so file as it requires more symlinks

* avoid smelly symbols

* fixup checksums

* regen sbom

* fixup shell warnings and comments

* it *should* work
2025-04-20 17:40:17 +00:00
Kumar Aditya
5b06d2ceca
gh-127945: add lock held assertions in ctypes arrays (#132720) 2025-04-19 18:27:10 +05:30
Rami
9752c84022
gh-89562: Remove hostflags from PySSLContext (GH-28602)
Remove hostflags from PySSLContext as that was only needed for OpenSSL versions prior to 1.1.1
2025-04-18 15:27:32 -07:00
Jeroen Bogers
ce31ae5209
gh-129719: Restore missing socket.CAN_RAW_ERR_FILTER on Linux (#129721)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-04-18 22:59:37 +03:00
Bénédikt Tran
2df0f88047
gh-132674: fix _hashopenssl.c compiler warnings on free-threaded build (#132675) 2025-04-18 13:52:17 +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
Bénédikt Tran
50e518e886
gh-132097: allow AC to disable fastcall convention to avoid UBSan failures (#131605) 2025-04-18 10:15:40 +02:00
Kumar Aditya
cf59bc3ae7
gh-127945: fix critical sections around ctypes array (#132646) 2025-04-17 18:44:14 +00: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
Chris Eibl
b530e174a3
GH-131296: Remove unused variable from overlapped.c (GH-131590) 2025-04-16 22:44:57 +01:00