Commit Graph

14759 Commits

Author SHA1 Message Date
Max Bachmann f7ac656c8e
Remove vestigial code in socketmodule.c for Mac OS X 10.1 (#131090)
mypy / Run mypy on ${{ matrix.target }} (Tools/build) (push) Successful in 11s Details
mypy / Run mypy on ${{ matrix.target }} (Tools/cases_generator) (push) Successful in 11s Details
mypy / Run mypy on ${{ matrix.target }} (Tools/clinic) (push) Successful in 11s Details
mypy / Run mypy on ${{ matrix.target }} (Tools/jit) (push) Failing after 1m12s Details
mypy / Run mypy on ${{ matrix.target }} (Tools/peg_generator) (push) Failing after 31s Details
mypy / Run mypy on ${{ matrix.target }} (Tools/wasm) (push) Failing after 32s Details
Tests / Change detection (push) Successful in 27m38s Details
Tests / Docs (push) Has been skipped Details
Tests / Windows ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }} (Win32, false, windows-latest) (push) Has been skipped Details
Tests / Windows ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }} (arm64, false, windows-latest) (push) Has been skipped Details
Tests / Windows ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }} (arm64, true, windows-latest) (push) Has been skipped Details
Tests / Windows ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }} (x64, false, windows-latest) (push) Has been skipped Details
Tests / Windows ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }} (x64, true, windows-latest) (push) Has been skipped Details
Tests / Windows MSI${{ '' }} (arm64) (push) Has been skipped Details
Tests / Windows MSI${{ '' }} (x64) (push) Has been skipped Details
Tests / Windows MSI${{ '' }} (x86) (push) Has been skipped Details
Tests / macOS ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }} (false, ${{ github.repository_owner != 'python' }}, ghcr.io/cirruslabs/macos-runner:sonoma) (push) Failing after 33m6s Details
Tests / macOS ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }} (false, ${{ github.repository_owner != 'python' }}, macos-13) (push) Failing after 33m5s Details
Tests / macOS ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }} (true, ${{ github.repository_owner != 'python' }}, ghcr.io/cirruslabs/macos-runner:sonoma) (push) Failing after 28m22s Details
Tests / macOS ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }} (false, ${{ github.repository_owner != 'python' }}, macos-14) (push) Failing after 39m39s Details
Tests / macOS ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }} (true, ${{ github.repository_owner != 'python' }}, macos-14) (push) Failing after 25m4s Details
Tests / Ubuntu ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }} ${{ fromJSON(matrix.bolt) && '(bolt)' || '' }} (false, false, ubuntu-24.04) (push) Failing after 28m47s Details
Tests / Ubuntu ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }} ${{ fromJSON(matrix.bolt) && '(bolt)' || '' }} (false, false, ubuntu-24.04-arm) (push) Failing after 28m45s Details
Tests / Ubuntu ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }} ${{ fromJSON(matrix.bolt) && '(bolt)' || '' }} (false, true, ubuntu-24.04) (push) Failing after 28m23s Details
Tests / Ubuntu ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }} ${{ fromJSON(matrix.bolt) && '(bolt)' || '' }} (true, false, ubuntu-24.04) (push) Failing after 26m42s Details
Tests / Cross build Linux (push) Successful in 3m6s Details
Tests / CIFuzz (address) (push) Has been skipped Details
Tests / CIFuzz (memory) (push) Has been skipped Details
Tests / CIFuzz (undefined) (push) Has been skipped Details
Tests / WASI (push) Failing after 28m30s Details
Tests / Ubuntu ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }} ${{ fromJSON(matrix.bolt) && '(bolt)' || '' }} (false, true, ubuntu-24.04-arm) (push) Failing after 38m36s Details
Tests / Thread sanitizer ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }} (false) (push) Failing after 27m52s Details
Tests / Thread sanitizer ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }} (true) (push) Successful in 50m36s Details
Mark stale pull requests / stale (push) Has been skipped Details
JIT / Interpreter (Debug) (push) Has been cancelled Details
JIT / ${{ matrix.target }} (${{ matrix.debug && 'Debug' || 'Release' }}) (ARM64, false, 19, windows-latest, aarch64-pc-windows-msvc/msvc) (push) Has been cancelled Details
JIT / ${{ matrix.target }} (${{ matrix.debug && 'Debug' || 'Release' }}) (ARM64, true, 19, windows-latest, aarch64-pc-windows-msvc/msvc) (push) Has been cancelled Details
JIT / ${{ matrix.target }} (${{ matrix.debug && 'Debug' || 'Release' }}) (Win32, false, 19, windows-latest, i686-pc-windows-msvc/msvc) (push) Has been cancelled Details
JIT / ${{ matrix.target }} (${{ matrix.debug && 'Debug' || 'Release' }}) (Win32, true, 19, windows-latest, i686-pc-windows-msvc/msvc) (push) Has been cancelled Details
JIT / ${{ matrix.target }} (${{ matrix.debug && 'Debug' || 'Release' }}) (aarch64, false, 19, macos-14, aarch64-apple-darwin/clang) (push) Has been cancelled Details
JIT / ${{ matrix.target }} (${{ matrix.debug && 'Debug' || 'Release' }}) (aarch64, false, 19, ubuntu-24.04-arm, aarch64-unknown-linux-gnu/gcc) (push) Has been cancelled Details
JIT / ${{ matrix.target }} (${{ matrix.debug && 'Debug' || 'Release' }}) (aarch64, true, 19, macos-14, aarch64-apple-darwin/clang) (push) Has been cancelled Details
JIT / ${{ matrix.target }} (${{ matrix.debug && 'Debug' || 'Release' }}) (aarch64, true, 19, ubuntu-24.04-arm, aarch64-unknown-linux-gnu/gcc) (push) Has been cancelled Details
JIT / ${{ matrix.target }} (${{ matrix.debug && 'Debug' || 'Release' }}) (x64, false, 19, windows-latest, x86_64-pc-windows-msvc/msvc) (push) Has been cancelled Details
JIT / ${{ matrix.target }} (${{ matrix.debug && 'Debug' || 'Release' }}) (x64, true, 19, windows-latest, x86_64-pc-windows-msvc/msvc) (push) Has been cancelled Details
JIT / ${{ matrix.target }} (${{ matrix.debug && 'Debug' || 'Release' }}) (x86_64, false, 19, macos-13, x86_64-apple-darwin/clang) (push) Has been cancelled Details
JIT / ${{ matrix.target }} (${{ matrix.debug && 'Debug' || 'Release' }}) (x86_64, false, 19, ubuntu-24.04, x86_64-unknown-linux-gnu/gcc) (push) Has been cancelled Details
JIT / ${{ matrix.target }} (${{ matrix.debug && 'Debug' || 'Release' }}) (x86_64, true, 19, macos-13, x86_64-apple-darwin/clang) (push) Has been cancelled Details
JIT / ${{ matrix.target }} (${{ matrix.debug && 'Debug' || 'Release' }}) (x86_64, true, 19, ubuntu-24.04, x86_64-unknown-linux-gnu/gcc) (push) Has been cancelled Details
JIT / Free-Threaded (Debug) (19) (push) Has been cancelled Details
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
Bénédikt Tran 4f07fd59cb
gh-111178: fix UBSan failures in `Modules/_functoolsmodule.c` (GH-129778)
Fix UBSan failures for `keyobject`, `lru_list_elem`, `lru_cache_object`.
Suppress unused return values.
Change `_PyPartialObject_CAST` (from #124733) to `partialobject_CAST`
for consistency with the current style for these macros
2025-02-21 15:08:56 +01:00
Hizuru c359fcd2f5
gh-129569: The function unicodedata.normalize() always returns built-in str (#129570)
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-02-21 14:51:13 +01:00
Sergey Miryanov 69426fcee7
gh-130052: Fix some exceptions on error paths in _testexternalinspection (#130053)
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-02-20 17:05:39 +00:00
Collin Funk 568db400ff
gh-129838: Don't redefine _Py_NO_SANITIZE_UNDEFINED (#129839)
Newer GCC versions accept both __attribute__((no_sanitize("undefined")))
and __attribute__((no_sanitize_undefined)) so check that the macro is
not already defined.
2025-02-20 17:02:33 +01:00
Bénédikt Tran 5a13faa1b7
gh-111178: fix UBSan failures in `Modules/_pickle.c` (#129787)
Fix UBSan failures for `Pdata`, `PicklerObject`, `UnpicklerObject`, `PicklerMemoProxyObject`, `UnpicklerMemoProxyObject`

Indicate safe fast cast to avoid redundant future checks

Use semantically correct parameter names
2025-02-20 14:27:35 +01:00
Bénédikt Tran deac31d214
gh-111178: fix UBSan failures in `Modules/overlapped.c` (GH-129786)
Fix UBSan failures for `OverlappedObject`
2025-02-20 14:24:24 +01:00
Bénédikt Tran 4466e91360
gh-111178: fix UBSan failures in `Modules/_operator.c` (GH-129785)
Fix UBSan failures for `itemgetterobject`, `attrgetterobject`, `methodcallerobject`

Suppress unused return values
2025-02-20 14:21:55 +01:00
Kumar Aditya 5f00501a94
gh-130221: fix crash when accessing module state while interp is finalizing in asyncio (#130245) 2025-02-19 22:07:56 +05:30
Kumar Aditya 660f126f87
gh-129898: per-thread current task implementation in asyncio (#129899)
Store the current running task on the thread state, it makes it thread safe for the free-threading build and while improving performance as there is no lock contention, this effectively makes it lock free.
When accessing the current task of the current running loop in current thread, no locking is required and can be acessed without locking.
In the rare case of accessing current task of a loop running in a different thread, the stop the world pauses is used in free-threading builds to stop all other running threads and find the task for the specified loop.

This also makes it easier for external introspection to find the current task, and now it will be always correct.
2025-02-19 16:34:49 +00:00