Commit graph

14768 commits

Author SHA1 Message Date
Chris Eibl
faa80fcf46
GH-131296: fix clang-cl warnings on Windows in blake2module.c (#131299)
work around unimportant clang-cl warnings in blake2module.c
2025-03-15 11:37:53 -07:00
Chris Eibl
0ce056d265
gh-130213: update hacl_star_rev to 322f6d58290e0ed7f4ecb84fcce12917aa0f594b (GH-130960)
Updates the HACL* implementation used by hashlib from upstream sources.
2025-03-15 10:42:27 -07:00
Victor Stinner
db62557e3d
gh-111178: Fix function signatures for test_os (#131227) 2025-03-14 13:53:06 +00:00
Victor Stinner
ca7fd814e4
gh-111178: Fix function signatures in _asynciomodule.c (#131228) 2025-03-14 13:37:39 +00:00
Victor Stinner
a5776639c8
gh-111178: Fix function signatures to fix undefined behavior (#131191) 2025-03-14 09:52:15 +00:00
Tomasz Pytel
c5abded099
gh-130382: add missing _PyReftracerTrack to ceval Py_DECREF (#130689) 2025-03-13 12:31:49 -04:00
Victor Stinner
9a63138e09
gh-111178: Fix function signatures in misc files (#131180) 2025-03-13 16:55:08 +01:00
Victor Stinner
10cbd1fe88
gh-130947: Add again PySequence_Fast() to the limited C API (#130948)
Add again PySequence_Fast() to the limited C API.

Add unit tests.
2025-03-13 13:00:57 +01:00
Furkan Onder
e98d321bef
gh-130099: Fix CAN socket fallthrough annotation for NetBSD compatibility (#131026) 2025-03-13 11:25:43 +01:00
Max Bachmann
f7ac656c8e
Remove vestigial code in socketmodule.c for Mac OS X 10.1 (#131090) 2025-03-13 00:13:07 -04:00
Victor Stinner
061da44bac
gh-111178: Change Argument Clinic signature for @classmethod (#131157)
Use "PyObject*", instead of "PyTypeObject*", for `@classmethod`
functions to fix an undefined behavior.
2025-03-12 17:42:07 +01:00
Pieter Eendebak
405a2d74cb
gh-123471: make itertools.batched thread-safe (#129416) 2025-03-12 15:30:33 +05:30
Victor Stinner
9d759b63d8
gh-111178: Change Argument Clinic signature for METH_O (#130682)
Use "PyObject*" for METH_O functions to fix an undefined behavior.
2025-03-11 16:33:36 +01:00
Max Bachmann
44c55c2356
Replace K&R function declarations with ANSI declarations (#114818) 2025-03-11 13:06:36 +01:00
Max Bachmann
de8818ae23
gh-131082: Add missing guards for WIN32_LEAN_AND_MEAN (#131044)
* Add missing guards for WIN32_LEAN_AND_MEAN

* add missing whitespaces
2025-03-11 12:33:01 +01:00
morotti
b1b4f9625c
gh-117151: IO performance improvement, increase io.DEFAULT_BUFFER_SIZE to 128k (GH-118144)
Co-authored-by: rmorotti <romain.morotti@man.com>
2025-03-07 11:36:12 -08:00
Cody Maloney
886a4d74ee
gh-129011: Update comments in FileIO to match current code (#129012) 2025-03-06 17:18:22 -08:00
Sam Gross
052cb717f5
gh-124878: Fix race conditions during interpreter finalization (#130649)
The PyThreadState field gains a reference count field to avoid
issues with PyThreadState being a dangling pointer to freed memory.
The refcount starts with a value of two: one reference is owned by the
interpreter's linked list of thread states and one reference is owned by
the OS thread. The reference count is decremented when the thread state
is removed from the interpreter's linked list and before the OS thread
calls `PyThread_hang_thread()`. The thread that decrements it to zero
frees the `PyThreadState` memory.

The `holds_gil` field is moved out of the `_status` bit field, to avoid
a data race where on thread calls `PyThreadState_Clear()`, modifying the
`_status` bit field while the OS thread reads `holds_gil` when
attempting to acquire the GIL.

The `PyThreadState.state` field now has `_Py_THREAD_SHUTTING_DOWN` as a
possible value. This corresponds to the `_PyThreadState_MustExit()`
check. This avoids race conditions in the free threading build when
checking `_PyThreadState_MustExit()`.
2025-03-06 10:38:34 -05:00
Serhiy Storchaka
63d25f8d0c
gh-130824: Clean up test wrappers for PyLong_*AndOverflow functions (GH-130871) 2025-03-05 11:50:53 +01:00
Peter Bierma
90130807d9
gh-130824: Add tests for NULL in PyLong_*AndOverflow functions (GH-130828)
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
2025-03-05 09:58:39 +01:00
Jelle Zijlstra
dc6d66f44c
gh-105499: Merge typing.Union and types.UnionType (#105511)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Ken Jin <kenjin@python.org>
Co-authored-by: Carl Meyer <carl@oddbird.net>
2025-03-04 11:44:19 -08:00
Sergey Miryanov
3a7f17c7e2
gh-130790: Remove references about unicode's readiness from comments (#130801) 2025-03-03 19:18:09 +00:00
Samuel Tyler
4f14b7e30c
gh-100388: Change undefined __DATE__ to the Unix epoch (#100389) 2025-03-03 14:59:46 +01:00
Bénédikt Tran
097846502b
gh-127667: fix memory leaks in hashlib (#127668)
- Correctly handle `NULL` values returned by `EVP_MD_CTX_md`.
- Correctly free resources in error branches.
- Consistently suppress `_setException()` return value when needed.
- Collapse `_setException() + return NULL` into a single statement.
2025-03-03 09:20:33 +01:00
Kumar Aditya
7e3b788e8f
gh-128002: use efficient linked list implementation for eager tasks in asyncio (#130518) 2025-03-03 06:36:43 +00:00
Hugo Beauzée-Luyssen
214562ed4d
gh-130740: Move some stdbool.h includes after Python.h (#130738)
Move some `#include <stdbool.h>` after `#include "Python.h"` when `pyconfig.h` is not
included first and when we are in a platform-agnostic context. This is to avoid having
features defined by `stdbool.h` before those decided by `Python.h`.
2025-03-02 09:56:49 +00:00
Sam Gross
75f38af781
Revert "gh-128942: make array module thread safe (#128943)" (#130707)
The change regressed performance on scimark benchmarks from the
pyperformance benchmark suite.

This reverts commit 8ba0d7bbc2.
2025-02-28 16:57:48 -05:00
leleliu008
e41981704f
gh-130617 : fix time_clockid_converter on DragonFlyBSD (#130634)
Signed-off-by: leleliu008 <leleliu008@gmail.com>
2025-02-28 08:56:00 +01:00
Tomasz Pytel
8ba0d7bbc2
gh-128942: make array module thread safe (#128943)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-02-27 14:00:14 +00:00
Fredrik Ahlberg
45a24f54af
gh-129288: Add optional l2_cid and l2_bdaddr_type in BTPROTO_L2CAP socket address tuple (#129293)
Add two optional, traling elements in the AF_BLUETOOTH socket address tuple:

- l2_cid, to allow e.g raw LE ATT connections
- l2_bdaddr_type. To be able to connect L2CAP sockets to Bluetooth LE devices,
  the l2_bdaddr_type must be set to BDADDR_LE_PUBLIC or BDADDR_LE_RANDOM.
2025-02-27 12:51:47 +00:00
Sam Gross
45bc120d45
gh-130519: Fix crash in QSBR when destructor reenters QSBR (gh-130553)
The `free_work_item()` function in QSBR may call arbitrary code via
Python object destructors, which may reenter the QSBR code. Reorder
the processing of work items to be robust to reentrancy.

Also fix the TODO for the out of memory situation.
2025-02-26 14:55:15 -05:00
Bénédikt Tran
f976892b7d
gh-111178: fix UBSan failures in Modules/_hashopenssl.c (GH-129802)
Fix UBSan failures for `EVPobject`, `HMACobject`
2025-02-26 09:24:44 +00:00
Bénédikt Tran
59d3ad0c62
gh-111178: fix UBSan failures in Modules/_tkinter.c (GH-129795)
Fix UBSan failures for `TkappObject`, `PyTclObject`, `TkttObject`

Implement CHECK_TCL_APPARTMENT as a static inline function
2025-02-26 09:40:48 +01:00
Bénédikt Tran
18bc5b7839
gh-111178: fix UBSan failures in Modules/_zoneinfo.c (GH-129798)
Fix UBSan failures for `PyZoneInfo_ZoneInfo`

Fix semantic naming
2025-02-26 09:36:59 +01:00
Serhiy Storchaka
0ef4ffeefd
gh-130163: Fix crashes related to PySys_GetObject() (GH-130503)
The use of PySys_GetObject() and _PySys_GetAttr(), which return a borrowed
reference, has been replaced by using one of the following functions, which
return a strong reference and distinguish a missing attribute from an error:
_PySys_GetOptionalAttr(), _PySys_GetOptionalAttrString(),
_PySys_GetRequiredAttr(), and _PySys_GetRequiredAttrString().
2025-02-25 23:04:27 +02:00
Bénédikt Tran
c1478d1ebb
gh-111178: fix UBSan failures in Modules/unicodedata.c (GH-129801)
fix UBSan failures for `PreviousDBVersion`
2025-02-25 13:13:47 +01:00
Bénédikt Tran
ead091357d
gh-111178: fix UBSan failures in Modules/xx*.c (GH-129797)
Fix UBSan failures in `Modules/xxlimited.c`, `Modules/xxlimited_35.c`, `Modules/xxsubtype.c`, `Modules/xxmodule.c`
2025-02-25 13:02:32 +01:00
Mark Shannon
014223649c
GH-130396: Use computed stack limits on linux (GH-130398)
* Implement C recursion protection with limit pointers for Linux, MacOS and Windows

* Remove calls to PyOS_CheckStack

* Add stack protection to parser

* Make tests more robust to low stacks

* Improve error messages for stack overflow
2025-02-25 09:24:48 +00:00
Petr Viktorin
fc8d2cba54
gh-129405: Fix doc for Py_mod_multiple_interpreters default, and add test (GH-129406) 2025-02-24 14:59:19 +01:00
Bénédikt Tran
805839021b
gh-111178: fix UBSan failures in Modules/_winapi.c (GH-129796)
Fix UBSan failures for `OverlappedObject`

Suppress unused return values
2025-02-24 14:06:13 +01:00
Bénédikt Tran
f8eefc2f35
gh-111178: fix UBSan failures in Modules/_threadmodule.c (GH-129794)
Fix UBSan failures for `PyThreadHandleObject`, `lockobject`, `rlockobject`, `localdummyobject`, `localobject`

Add safe casts

Clean up module functions

Use semantically correct parameter names
2025-02-24 13:42:39 +01:00
Bénédikt Tran
73bbaf33ae
gh-111178: fix UBSan failures in Modules/selectmodule.c (GH-129792)
Fix some UBSan failures for `pollObject`, `devpollObject`, `pyEpoll_Object` as well as
for `kqueue_event_Object`, `kqueue_queue_Object` and `kqueue_tracking_after_fork`.

Suppress unused return values.

Rename the unused parameter in `METH_NOARGS` and getter/setter methods to
`dummy` and `closure` respectively for semantic purposes.

Explicitly declare `_select_exec` as a `static` function.
2025-02-24 13:38:18 +01:00
Bénédikt Tran
de13293d26
gh-111178: fix UBSan failures in Modules/posixmodule.c (GH-129788)
Fix UBSan failures for `DirEntry`, `ScandirIterator`
Use better semantic naming
2025-02-24 13:20:49 +01:00
Bénédikt Tran
c070abadb2
gh-111178: fix UBSan failures in Modules/pyexpat.c (GH-129789)
Fix UBSan failures for `xmlparseobject`, XML handler setters
Suppress unused return values

Rewrite `RC_HANDLER` with better semantics
2025-02-24 11:56:32 +01:00
Petr Viktorin
ef29104f7d
GH-91079: Revert "GH-91079: Implement C stack limits using addresses, not counters. (GH-130007)" for now (GH130413)
Revert "GH-91079: Implement C stack limits using addresses, not counters. (GH-130007)" for now

Unfortunatlely, the change broke some buildbots.

This reverts commit 2498c22fa0.
2025-02-24 11:16:08 +01:00
Bénédikt Tran
071820113f
gh-130151: Fix reference leaks in _hashlib.hmac_{new,digest} (GH-130152)
* fix leak in `_hashlib.hmac_new`
* fix leak in `hmac_digest`
* fix exception type in `_hashlib.HMAC.copy`
2025-02-24 00:09:14 +00:00
Bénédikt Tran
1e4a4344af
gh-111178: fix UBSan failures in Modules/_struct.c (#129793)
Fix some UBSan failures for `PyStructObject` and `unpackiterobject`.

We also perform some cleanup by suppressing unused return values and renaming the
unused parameter in `METH_NOARGS` and getter methods to `dummy` and `closure`
respectively for semantic purposes.
2025-02-23 10:34:11 +00:00
Chris Eibl
65b339c5ca
gh-111178: fix clang-cl compilation of Modules/mmapmodule.c post gh-129784 (#130446)
The `PyCFunction` cast on `mmap__sizeof__method` was removed but the method was not updated accordingly.
2025-02-22 12:36:38 +01:00
Bénédikt Tran
2922429538
gh-111178: fix UBSan failures in Modules/_randommodule.c (GH-129791)
Fix UBSan failures for `RandomObject`
Suppress unused return values
2025-02-21 14:59:04 +00:00
Bénédikt Tran
55f8bac208
gh-111178: fix UBSan failures in Modules/_queuemodule.c (GH-129790)
Fix UBSan failures for `simplequeueobject`

Suppress unused return values
2025-02-21 14:37:32 +00:00