Commit Graph

14930 Commits

Author SHA1 Message Date
Bénédikt Tran 04bc681e7c
gh-131938: Update exception message for `Element.remove()` when an element is not found (#131972)
The exception message for `xml.etree.ElementTree.Element.remove` when an element is not found
has been updated from "list.remove(x): x not in list" to "Element.remove(x): element not found".
2025-04-04 15:04:07 +00:00
Serhiy Storchaka 345baa77ba
gh-132075: Fix possible use of sockaddr structures with uninitialized members (GH-132076)
Now all structure members are initialized with zeroes by default.
2025-04-04 17:09:58 +03:00
Peter Bierma 6e91d1f9aa
gh-131974: Fix usages of `locked_deref` in `ctypes` (#131975) 2025-04-02 17:04:25 +02:00
Chris Eibl e9556e1004
GH-131296: Disable MSVC-specific optimization in sre.c when compiling with clang-cl (GH-131593) 2025-04-01 17:29:45 +01:00
Bénédikt Tran edbf7fb129
gh-111178: remove redundant casts for functions with correct signatures (#131673) 2025-04-01 17:18:11 +02:00
Victor Stinner 8cd29c2b53
gh-111178: Fix getsockaddrarg() undefined behavior (#131668)
Don't pass direct references to sockaddr members since their type may
not match PyArg_ParseTuple() types. Instead, use temporary 'int' and
'unsigned char' variables, and update sockaddr members afterwards.

On FreeBSD, treat BTPROTO_HCI node name as a bytes string,
not as an integer.
2025-04-01 13:54:27 +00:00
Peter Bierma 511d3440a0
gh-131936: Strengthen check in `_suggestions._generate_suggestions` (#131945) 2025-03-31 19:30:29 +02:00
Chris Eibl 9127b4602e
GH-131296: Fix incompatible pointer type warning in _winapi.c (GH-131600) 2025-03-31 17:33:55 +01:00
Chris Eibl 7cbcb6efd9
GH-131296: Fix parenthesis warnings on Windows-specific code (GH-131905) 2025-03-31 15:54:30 +01:00
Bénédikt Tran bab1398a47
gh-126033: fix UAF in `xml.etree.ElementTree.Element.remove` when concurrent mutations happen (#126124) 2025-03-31 12:31:26 +02:00
Bénédikt Tran c57623c221
gh-126037: fix UAF in `xml.etree.ElementTree.Element.find*` when concurrent mutations happen (#127964)
We fix a use-after-free in the `find`, `findtext` and `findall` methods of `xml.etree.ElementTree.Element`
objects that can be triggered when the tag to find implements an `__eq__` method that mutates the
element being queried.
2025-03-31 12:26:52 +02:00
Kumar Aditya 46ada1e5e0
gh-127945: acquire critical section around `PyCFuncPtr_call` (#131898) 2025-03-30 11:01:12 +00:00
Kumar Aditya 28e476f6a2
gh-127945: make initialization of `error_object_name` thread safe in ctypes (#131896) 2025-03-30 10:50:35 +00:00
Kumar Aditya bc5a028c13
gh-127945: fix thread safety of creating instances of ctypes structures (#131716) 2025-03-30 15:22:30 +05:30
Steve Dower d260631be0
gh-131423: Update to OpenSSL 3.0.16. (GH-131839)
The bin tag is 3.0.16.1 because we rebuilt without uplink support to fix gh-131804.
This PR also prevents making calls that are now unsafe without uplink, and updates
the tests to property interpret these failures as unsupported.
2025-03-28 15:07:57 +00:00
Michael Droettboom 8614f86b71
gh-131525: Cache the result of tuple_hash (#131529)
* gh-131525: Cache the result of tuple_hash

* Fix debug builds

* Add blurb

* Fix formatting

* Pre-compute empty tuple singleton

* Mostly set the cache within tuple_alloc

* Fixes for TSAN

* Pre-compute empty tuple singleton

* Fix for 32-bit platforms

* Assert that op != NULL in _PyTuple_RESET_HASH_CACHE

* Use FT_ATOMIC_STORE_SSIZE_RELAXED macro

* Update Include/internal/pycore_tuple.h

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>

* Fix alignment

* atomic load

* Update Objects/tupleobject.c

Co-authored-by: Chris Eibl <138194463+chris-eibl@users.noreply.github.com>

---------

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Chris Eibl <138194463+chris-eibl@users.noreply.github.com>
2025-03-27 09:57:06 -04:00
Sam Gross 67fbfb42bd
gh-131586: Avoid refcount contention in some "special" calls (#131588)
In the free threaded build, the `_PyObject_LookupSpecial()` call can lead to
reference count contention on the returned function object becuase it
doesn't use stackrefs. Refactor some of the callers to use
`_PyObject_MaybeCallSpecialNoArgs`, which uses stackrefs internally.

This fixes the scaling bottleneck in the "lookup_special" microbenchmark
in `ftscalingbench.py`. However, the are still some uses of
`_PyObject_LookupSpecial()` that need to be addressed in future PRs.
2025-03-26 14:38:47 -04:00
Peter Bierma 90b82f2b61
gh-129900: Fix `SystemExit` return codes when the REPL is started from the command line (#129901) 2025-03-25 19:48:46 +00:00
Kumar Aditya f1967e7249
gh-127945: fix thread safety of ctypes state (#131710)
This fixes thread safety of `array_cache` and `swapped_suffix` by initializing them in module exec to make it thread safety.
2025-03-25 17:03:05 +05:30
Kumar Aditya 96ef4c511f
gh-127945: add locking to malloc closure in free-threading (#131662)
The freelist is not thread safe in free-threading so this adds lock around it make it thread safe in free-threading.
2025-03-25 16:48:46 +05:30
Victor Stinner 5fef4ff9ed
gh-111178: Fix function signature in pyexpat.c (#131674)
Move _Py_NO_SANITIZE_UNDEFINED macro from faulthandler.c to pyport.h.
2025-03-24 17:22:45 +00:00
Victor Stinner 69e94e0a1b
gh-111178: Fix function signatures for test_socket (#131667)
Add unicode_fsdecode() wrapper for PyUnicode_DecodeFSDefault() to use
the correct API for Py_BuildValue() converter API.
2025-03-24 14:51:32 +00:00
Victor Stinner 6226edc48b
gh-111178: Fix function signatures for test_capi (#131659)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-03-24 14:04:45 +00:00
Victor Stinner 78f1bac7f2
gh-111178: Fix function signature for test_threading (#131663) 2025-03-24 13:56:45 +00:00
Victor Stinner 4596666a9f
gh-111178: Fix function signatures for test_zoneinfo (#131664) 2025-03-24 14:32:46 +01:00
Victor Stinner abcd9d4f7d
gh-111178: Fix function signatures for test_ctypes (#131660) 2025-03-24 14:30:13 +01:00
Petr Viktorin 0e53038ea8
gh-128715: Expose ctypes.CField, with info attributes (GH-128950)
- Restore max field size to sys.maxsize, as in Python 3.13 & below
- PyCField: Split out bit/byte sizes/offsets.
- Expose CField's size/offset data to Python code
- Add generic checks for all the test structs/unions, using the newly exposed attrs
2025-03-24 14:18:34 +01:00
Sergey Miryanov 62fb15d866
gh-131311: Extract _replace_array_elements from PyCStructUnionType_update_stginfo (GH-131504) 2025-03-24 13:55:09 +01:00
Kumar Aditya 04d4aacaac
gh-128485: ensure that dlmalloc initializes itself at import time in ctypes (#131633) 2025-03-24 18:14:25 +05:30
Sergey Miryanov 9c4fb92e12
gh-131311: Fix additional memory leaks in ctypes (GH-131429)
* Visit keep in StructParam_traverse
* Decref swapped in PyCSimpleType_init
* Decref ob in make_funcptrtype_dict
* Check Pointer_item result while constructing result list in Pointer_subscript

* Fix align and size naming in PyCStructUnionType_update_stginfo
  - as discussed in previous PR
2025-03-24 13:42:10 +01:00
Bénédikt Tran af29d5cfd1
gh-111178: fix UBSan failures for `Modules/_testcapimodule.c` (#131614)
Fix UBSan failures for various classes in `Modules/_testcapimodule.c`,
remove some redundant casts and add some `Py_UNUSED()` usages.
2025-03-24 10:14:22 +00:00
Bénédikt Tran 491b8141f5
gh-111178: fix UBSan failures for `Modules/_testcapi/{buffer,monitoring}.c` (#131613) 2025-03-24 11:06:37 +01:00
Bénédikt Tran 45191797d8
gh-111178: fix UBSan failures for `Modules/_testmultiphase.c` (#131615) 2025-03-24 10:59:30 +01:00
Bénédikt Tran 82e541bf91
gh-111178: fix UBSan failures for `Modules/_testbuffer.c` (#131612) 2025-03-24 10:46:25 +01:00
Bénédikt Tran ef06508f8e
gh-111178: fix UBSan failures for `TaskStepMethWrapper` (#131602) 2025-03-23 19:56:03 +05:30
Bénédikt Tran a9a399f0ec
gh-131418: remove unused legacy typedefs in `{md5,sha1}module.c` (#131420)
- Remove legacy typedefs `MD5_INT32` and `MD5_INT64` in `Modules/md5module.c`
- Remove legacy typedefs `SHA1_INT32` and `SHA1_INT64` in `Modules/sha1module.c`.

Those legacy typedefs were used to detect whether the host platform could
correctly implement MD5 and SHA-1, but this is no longer needed as we now
fallback to HACL* implementations.
2025-03-23 12:19:26 +01:00
Chris Eibl bc26f95e8f
GH-131296: fix clang-cl warning on Windows in semaphore.c (GH-131595)
fix clangcl warning
2025-03-22 15:44:56 -07:00
Victor Stinner 1a082085ae
gh-131238: Remove pycore_object_deferred.h from pycore_object.h (#131549)
Remove also pycore_function.h from pycore_typeobject.h.
2025-03-21 16:44:10 +00:00
Xavier G. b70d45ab22
gh-131268: Implement thread names on OpenBSD (#131528) 2025-03-21 11:12:35 +01:00
Stan Ulbrych e0fda794fa
gh-70647: Raise a more informative error for when date is out of range (GH-131335)
More informative error messages mean less debugging what went wrong.
2025-03-20 20:47:09 -07:00
Mark Shannon 7ebd71ee14
GH-131498: Remove conditional stack effects (GH-131499)
* Adds some missing #includes
2025-03-20 15:39:38 +00:00
Victor Stinner b69da006a4
gh-131238: Remove includes from pycore_interp.h (#131495)
Remove also now unused includes in C files.
2025-03-20 11:35:23 +00:00
Victor Stinner 34c1ea3109
gh-111178: Fix function signatures for multiple tests (#131496) 2025-03-20 12:27:03 +01:00
Victor Stinner 486d537065
Fix Windows build warnings (#131487)
Fix the following warnings:

* Modules\_io\fileio.c(1296,13): unused variable 'self'
* Modules\_io\winconsoleio.c(334,9): unused variable 'fd_is_own'
* Modules\faulthandler.c(409,11): unused variable 'flags'
* Modules\posixmodule.c(5699,9): unused variable 'pathError'
* PC\winreg.c(2077,5): suggest braces around initialization of
  subobject
* PC\winreg.c(34,13): unused variable 'errNotAHandle'
* Python\fileutils.c(132,12): result of comparison of constant
  1114111 with expression of type 'wchar_t' (aka 'unsigned short') is
  always false
* Python\fileutils.c(58,21): unused variable 'INCOMPLETE_CHARACTER'
* Python\sysmodule.c(2534,21): unused variable 'perf_map_state'
2025-03-20 12:03:20 +01:00
Victor Stinner 20c5f969dd
gh-131238: Remove more includes from pycore_interp.h (#131480) 2025-03-19 23:01:32 +01:00
Steve Dower 63a638c43f
gh-91349: Replace zlib with zlib-ng in Windows build (GH-131438) 2025-03-19 19:03:25 +00:00
Victor Stinner 5c44d7d99c
gh-130931: Add pycore_interpframe.h internal header (#131249)
Move _PyInterpreterFrame and associated functions
to a new pycore_interpframe.h header.
2025-03-19 18:17:44 +01:00
Victor Stinner 4b54031323
gh-131238: Remove pycore_runtime.h from pycore_pystate.h (#131356)
* Remove includes from pycore_pystate.h:

  * pycore_runtime_structs.h
  * pycore_runtime.h
  * pycore_tstate.h
  * pycore_interp.h

* Reorganize internal headers. Move _gc_thread_state from
  pycore_interp_structs.h to pycore_tstate.h.
* Add 3 new header files to PCbuild/pythoncore.vcxproj.
2025-03-19 17:33:24 +01:00
Victor Stinner 6935d96e9c
gh-111178: Fix function signatures in _testbuffer.c (#131463) 2025-03-19 16:54:18 +01:00
Victor Stinner f5e4c2955b
gh-111178: Fix function signatures for test_iter (#131456) 2025-03-19 14:42:51 +01:00
Max Bachmann 49234c065c
gh-114917: Fix typo in getaddrinfo emulation (#131413) 2025-03-18 14:31:13 +01:00
Petr Viktorin 51d309988b
gh-131261: expat/refresh.sh: Expand list of manual steps (GH-131359) 2025-03-18 13:17:43 +01:00
Sergey Miryanov 812074e291
gh-131311: Consolidate reference handling in PyCStructUnionType_update_stginfo to fix memory leak (GH-131312) 2025-03-18 11:50:22 +01:00
Max Bachmann 3453b5c1d6
gh-114917: add support for AI_NUMERICSERV in getaddrinfo emulation (#114918) 2025-03-18 11:26:51 +01:00
Tomasz Pytel 863d54cbaf
gh-126895: Fix readline module in free-threaded build (#131208)
The underlying readline library is not thread-safe so this adds `@critical_section` to functions that use it.
2025-03-17 11:57:11 -04:00
Bénédikt Tran e708ac8dd4
gh-111178: fix UBSan failures in `Modules/_ssl.c` (GH-130719)
* fix UBSan failures for `PySSLContext`, `PySSLSocket`, `PySSLMemoryBIO`, `PySSLSession`
2025-03-17 16:25:28 +01:00
Mark Shannon a45f25361d
GH-131238: More refactoring of core header files (GH-131351)
Adds new pycore_stats.h header file to help break dependencies involving the pycore_code.h header.
2025-03-17 14:41:05 +00:00
Gregory P. Smith bb0268f60d
gh-131261: Update libexpat to 2.7.0 (CVE-2024-8176) (#131272) 2025-03-17 14:55:02 +01:00
Victor Stinner 978e37bb5f
gh-131238: Add explicit includes to pycore headers (#131257) 2025-03-17 12:32:43 +01:00
Bénédikt Tran ac50ece6ce
gh-127667: refactor and improve `_hashopenssl.c` error branches (#131145)
Refactor `_setException()` into different helpers that can be used separately:

- set_ssl_exception_from_errcode(): set an exception from an explicit SSL error code.
- raise_ssl_error(): set an exception from the last SSL error code or use a user-defined message.
- notify_ssl_error_occurred(): same as raise_ssl_error() but with a generic default message.
2025-03-17 11:12:55 +01:00
Bénédikt Tran 261633bd3f
gh-131316: handle NULL values returned by HACL* functions (#131324)
- Handle NULL returned by allocation functions.
- Handle NULL returned by copy functions.
- Suppress unused impossible return codes.
2025-03-17 11:10:39 +01:00
Mark Shannon a1aeec61c4
GH-131238: Core header refactor (GH-131250)
* Moves most structs in pycore_ header files into pycore_structs.h and pycore_runtime_structs.h

* Removes many cross-header dependencies
2025-03-17 09:19:04 +00:00
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)
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
Mark Shannon 2498c22fa0
GH-91079: Implement C stack limits using addresses, not counters. (GH-130007)
* Implement C recursion protection with limit pointers

* 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-19 11:44:57 +00:00
Bénédikt Tran c637bce20a
gh-111178: fix UBSan failures in `Modules/_datetimemodule.c` (GH-129774)
Add cast macros for date and time objects

Fix UBSan failures for `PyDateTime_Delta`, `PyDateTime_Date`, `PyDateTime_TZInfo`, `PyDateTime_TimeZone`, `PyDateTime_Time`, `PyDateTime_DateTime`, `PyDateTime_IsoCalendarDate`

Fix up naming
2025-02-19 11:18:37 +00:00
Bénédikt Tran 0d0be7f7f1
gh-111178: fix UBSan failures in `Modules/mmapmodule.c` (GH-129784)
Fix UBSan failures for `mmap_object`

Use 'ignored' for NOARGS method and 'args' for others
2025-02-19 12:02:32 +01:00
Bénédikt Tran f8c041bff9
gh-111178: fix UBSan failures in `Modules/itertoolsmodule.c` (GH-129780) 2025-02-19 11:58:47 +01:00
Pablo Galindo Salgado 51d4bf1e0e
bpo-45325: Add a new 'p' parameter to Py_BuildValue to convert an integer into a Python bool (#28634) 2025-02-18 17:14:11 +00:00
donBarbos 427dd10250
gh-127260: Improve error consistency in both `fromisoformat` implementations (#130134)
In the Python implementation, "Z" was allowed where only "+" or "-" should be allowed in time zone specifiers. In the C implementation, ":" was allowed as a separator between the whole and fractional portion of times (seconds). These have both been forbidden and the error messages harmonized.
2025-02-18 15:49:28 +00:00
Bénédikt Tran 185ac5adaf
gh-111178: fix UBSan failures in `Modules/_lzmamodule.c` (GH-129783)
fix UBSan failures for LZMA objects

suppress unused return values
2025-02-18 14:48:21 +01:00
Serhiy Storchaka b93b7e566e
gh-130230: Fix crash in pow() with only Decimal third argument (GH-130237) 2025-02-18 09:46:48 +02:00
Bénédikt Tran a1d4b1c447
gh-111178: fix UBSan failures in `Modules/_lsprof.c` (GH-129782)
Fix UBSan failures for `ProfilerObject`

Suppress unused return value
2025-02-17 14:53:03 +01:00
Bénédikt Tran 31ad8b6d08
gh-111178: fix UBSan failures in `Modules/_jsonmodule.c` (GH-129781)
Fix UBSan failures for `PyScannerObject`, fix UBSan failures for `PyEncoderObject`
2025-02-17 14:51:18 +01:00
Bénédikt Tran f55d0b66be
gh-111178: fix UBSan failures in `Modules/_collectionsmodule.c` (#129773)
Fix some UBSan failures for `dequeobject`, `dequeiterobject`, `defdictobject` and `tuplegetterobject`.

We also perform some cleanup by suppressing unused return values and renaming the
unused argument in `METH_NOARGS` methods to `dummy` for semantic purposes.
2025-02-17 12:12:03 +00:00
Bénédikt Tran 6669905723
gh-111178: fix UBSan failures in `Modules/_interp*module.c` (GH-129779)
Fix UBSan failures for `XIBufferViewObject`

Remove redundant casts, suppress unused return values
2025-02-17 11:34:14 +01:00
Sergey Miryanov e7f00cd14f
gh-130179: Fix `persistent_{id,load}_attr` reference leaks in `_pickle` (#130180)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-02-16 17:00:03 +03:00
Bartosz Sławecki 07f5e33f2e
Fix a typo in `_localemodule.c` (GH-130085) 2025-02-13 17:29:26 +00:00
Sam Gross 451f291baa
gh-128130: Fix unhandled keyboard interrupt data race (gh-129975)
Use an atomic operation when setting
`_PyRuntime.signals.unhandled_keyboard_interrupt`. We now only clear the
variable at the start of `_PyRun_Main`, which is the same function where
we check it.

This avoids race conditions where previously another thread might call
`run_eval_code_obj()` and erroneously clear the unhandled keyboard
interrupt.
2025-02-13 12:29:03 -05:00
Kumar Aditya c7a9d06e06
gh-128002: optimistically remove tasks from linked list when finished (#129995) 2025-02-13 13:19:53 +05:30
Pablo Galindo Salgado 49b11033bd
GH-91048: Correct error path in testexternalinspection (#129557) 2025-02-13 01:07:01 +00:00
Sergey Miryanov 633853004c
gh-130050: Fix memory leaks in _testexternalinspection (#130051) 2025-02-12 21:12:07 +00:00
donBarbos 3e222e3a15
gh-109798: Normalize `_datetime` and `datetime` error messages (#127345)
Updates error messages in datetime and makes them consistent between Python and C.

---------

Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Paul Ganssle <1377457+pganssle@users.noreply.github.com>
2025-02-12 09:54:22 -05:00
Tomasz Pytel 3cf68cdd3e
gh-129983: fix data race in compile_template in sre.c (#130015) 2025-02-12 18:34:44 +05:30
Erlend E. Aasland 3b366a4a4b
gh-129928: Rework sqlite3 error helpers (#129929)
Add a helper for raising DB-API compatible exceptions based on the
result code of SQLite C APIs. Some APIs do not store the error indicator
on the database pointer, so we need to be able to deduce the DB-API
compatible exception directly from the error code.

- rename _pysqlite_seterror() as set_error_from_db()
- introduce set_error_from_code()
2025-02-11 07:49:25 +00:00
Erlend E. Aasland 3a2e7aacf6
gh-129928: Raise more accurate exception for incorrect sqlite3 UDF creation (#129941)
Consistently raise ProgrammingError if the user tries to create an UDF
with an invalid number of parameters.
2025-02-11 08:26:01 +01:00
Kumar Aditya 94cd2e0dde
gh-129289: fix crash when task finalizer is not called in asyncio (#129840) 2025-02-10 17:03:59 +05:30
Bénédikt Tran a1a6df282d
gh-111178: fix UBSan failures in `Modules/_dbmmodule.c` (#129775)
This fixes UBSan failures for `dbmobject`.

In addition, we perform some minor cleanup changes such as renaming
some `args` parameter to `dummy` in some `METH_NOARGS` methods and
suppressing an unused return value in `_dbm_module_free`.
2025-02-10 11:02:47 +01:00
Kumar Aditya bff4bfeae1
gh-128002: add fast path for native tasks in `asyncio.all_tasks` (#129943) 2025-02-10 15:04:33 +05:30
Kumar Aditya 7246b9124c
gh-128002: simplify `asyncio.all_tasks` to use `PyList_Extend` instead of manual iteration (#129942) 2025-02-10 14:26:32 +05:30
Erlend E. Aasland 7e6ee50b6b
gh-129603: Don't segfault if sqlite3.Row description is None (#129604) 2025-02-10 00:27:28 +01:00
Bénédikt Tran 624b93ed67
gh-111178: fix UBSan failures in `Modules/arraymodule.c` (GH-129772)
* fix UBSan failures for `arrayobject`, `arrayiterobject`
* suppress unused return values
2025-02-08 14:26:14 +01:00
Bénédikt Tran 1988003625
gh-111178: fix UBSan failures in `Modules/_io/*.c` (GH-129083)
* fix UBSan failures for `buffered`, `rwpair`, `bytesio`, `bytesiobuf`, `iobase`, `stringio`, `nldecoder_object`, `textio`, `winconsoleio`

* arg names: use 'dummy' for NOARGS method and 'args' for others
2025-02-08 14:21:32 +01:00