Commit Graph

15368 Commits

Author SHA1 Message Date
Victor Stinner 5d2edf72d2 gh-83714: Set os.statx().stx_mode to None if missing from stx_mask (#140484)
* Set stx_mode to None if STATX_TYPE|STATX_MODE is missing from
  stx_mask.
* Enhance os.statx() tests.
* statx_result structure: remove atime_sec, btime_sec, ctime_sec and
  mtime_sec members. Compute them on demand when stx_atime,
  stx_btime, stx_ctime and stx_mtime are read.
* Doc: fix statx members sorting.
2025-10-23 22:35:17 +02:00
Abhishek Tiwari f0291c3f2d gh-140443: Use fma in loghelper to improve accuracy of log for very large integers (#140469)
* gh-140443:use fma in loghelper to improve accuracy of log for very large integers

Use fused multiply-add in log_helper() for huge ints.

Saving a rounding here is remarkably effective. Across some millions
of randomized test cases with ints up to a billion bits, on Windows
and using log10, the ULP error distribution was dramatically
flattened, and its range was nearly cut in half. In fact, the largest
error Tim saw was under 0.6 ULP.

---------

Co-authored-by: abhi210 <27881020+Abhi210@users.noreply.github.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2025-10-23 12:05:12 -05:00
Stan Ulbrych aa9d0a61d5 gh-140474: Fix memory leak in array.array (GH-140478) 2025-10-23 05:49:27 -04:00
Alper d51be28876 gh-116738: Add critical section to dbm/gdbm context manager (gh-140391) 2025-10-22 11:16:28 -04:00
Petr Viktorin e53e9eb2f1 gh-83714: Only use STATX_MNT_ID & STATX_SUBVOL if they're defined (GH-140446) 2025-10-22 12:42:51 +02:00
Victor Stinner 7339cf7899 gh-83714: Use "stx_" prefix for all os.statx_result members (#140432)
Rename stx_birthtime to stx_btime, and rename stx_birthtime_ns to
stx_btime_ns.
2025-10-22 11:48:37 +02:00
Alper b3a38438d8 gh-116738: Make _suggestions module thread-safe (gh-140321) 2025-10-22 09:14:48 +09:00
Stan Ulbrych 02c1abfc54 gh-69528: Distinguish between file modes "wb+" and "rb+" (GH-137834)
Co-authored-by: Xiang Zhang <angwerzx@126.com>
2025-10-21 20:33:30 +03:00
Jeffrey Bosboom 60df1d7e0c gh-83714: Check for struct statx members in configure (#140402)
Some systems have the definitions of the mask bits without having the
corresponding members in struct statx.  Add configure checks for members
added after Linux 4.11 (when statx itself was added).
2025-10-21 18:13:14 +02:00
Shamil e8e0f411ba gh-140398: fix memory leaks in readline module when PySys_Audit fails (#140400) 2025-10-21 13:24:34 +05:30
Victor Stinner 3222ea0f14 gh-83714: Set os.statx() members to None if missing from stx_mask (#140216) 2025-10-20 17:59:12 +02:00
Sam Gross f11ec6e643 gh-140263: Fix data race in test_lock_two_threads (gh-140264)
Clang-20 detects a data race between the unlock and the non-atomic
read of the lock state. Use a relaxed load for the assertion to avoid
the race.
2025-10-20 09:58:05 -04:00
mdehoon baf45159e5 fix typo in comments PyOS_CallInputHook -> PyOS_InputHook (#140237) 2025-10-20 14:25:57 +05:30
Shamil f9323213c9 gh-140306: Fix memory leaks in cross-interpreter data handling (GH-140307) 2025-10-19 22:24:28 +03:00
Shamil f937468e7c gh-140272: Fix memory leak in _gdbm.gdbm.clear() (GH-140274) 2025-10-18 09:27:58 +00:00
Jeffrey Bosboom 5a31024da4 gh-83714: Check for struct statx.stx_atomic_write_unit_max_opt in configure (#140185)
stx_atomic_write_unit_max_opt was added in Linux 6.16, but is controlled
by the STATX_WRITE_ATOMIC mask bit added in Linux 6.11.  That's safe at
runtime because all kernels clear the reserved space in struct statx and
zero is a valid value for stx_atomic_write_unit_max_opt, and it avoids
allocating another mask bit, which are a limited resource.  But it also
means the kernel headers don't provide a way to check whether
stx_atomic_write_unit_max_opt exists, so add a configure check.
2025-10-16 13:40:47 +02:00
Victor Stinner 4641925bf2 Set type names earlier in posixmodule.c (#140168) 2025-10-16 12:54:57 +02:00
Serhiy Storchaka 2a2bc82cef gh-130567: Remove optimistic allocation in locale.strxfrm() (GH-137143)
On modern systems, the result of wcsxfrm() is much larger the size of
the input string (from 4+2*n on Windows to 4+5*n on Linux for simple
ASCII strings), so optimistic allocation of the buffer of the same size
never works.

The exception is if the locale is "C" (or unset), but in that case the `wcsxfrm`
call should be fast (and calling `locale.strxfrm()` doesn't make too much
sense in the first place).
2025-10-16 09:54:41 +02:00
Jonathan Protzenko 3a81313019 gh-140120: Refresh HACL* to fix an hmac memory leak (GH-140188)
This pulls an updated version of HACL* that fixes the memory leak reported in #140120, via an upstream fix.
2025-10-16 05:25:51 +00:00
Victor Stinner 5213f1b684 gh-83714: Disable os.statx_result.stx_atomic_write_unit_max_opt (#140162)
Fix building on Centos 9 x86-64 buildbot.
2025-10-15 17:38:34 +02:00
Maurycy Pawłowski-Wieroński d301587369 gh-140135: Use PyBytesWriter in io.RawIOBase.readall(); 4x faster (#140139) 2025-10-15 14:04:17 +00:00
yihong a05aece543 gh-140080: Clear atexit callbacks when memory allocation fails during finalization (GH-140103)
This fixes a regression introduced by GH-136004, in which finalization would hang while executing atexit handlers if the system was out of memory.

---------

Signed-off-by: yihong0618 <zouzou0208@gmail.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-10-15 09:49:55 -04:00
Sergey Miryanov 32c264982e gh-140061: Use _PyObject_IsUniquelyReferenced() to check if objects are uniquely referenced (gh-140062)
The previous `Py_REFCNT(x) == 1` checks can have data races in the free
threaded build. `_PyObject_IsUniquelyReferenced(x)` is a more conservative
check that is safe in the free threaded build and is identical to
`Py_REFCNT(x) == 1` in the default GIL-enabled build.
2025-10-15 09:48:21 -04:00
Jeffrey Bosboom fe9ac7fc8c gh-83714: Implement os.statx() function (#139178)
Co-authored-by: Cody Maloney <cmaloney@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-10-15 13:44:08 +00:00
Bénédikt Tran 27acaf1cb7 gh-139327: consolidate sqlite3_finalize and sqlite3_reset usages (GH-139329) 2025-10-15 15:18:07 +02:00
Stan Ulbrych 46f11b36ad gh-76007: Deprecate zlib.__version__ attribute (#140130) 2025-10-15 13:18:48 +02:00
Emma Smith f262297d52 gh-139877: Use PyBytesWriter in pycore_blocks_output_buffer.h (#139976)
Previously, the _BlocksOutputBuffer code creates a list of bytes objects to handle the output data from compression libraries. This ends up being slow due to the output buffer code needing to copy each bytes element of the list into the final bytes object buffer at the end of compression.

The new PyBytesWriter API introduced in PEP 782 is an ergonomic and fast method of writing data into a buffer that will later turn into a bytes object. Benchmarks show that using the PyBytesWriter API is 10-30% faster for decompression across a variety of settings. The performance gains are greatest when the decompressor is very performant, such as for Zstandard (and likely zlib-ng). Otherwise the decompressor can bottleneck decompression and the gains are more modest, but still sizable (e.g. 10% faster for zlib)!

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-10-14 10:03:55 -07:00
Stan Ulbrych 87eadce3e0 gh-101828: Fix jisx0213 codecs removing null characters (gh-139340) 2025-10-14 22:55:00 +09:00
Sergey B Kirpichev 6ecf77dbde gh-102431: Clarify constraints on operands of Decimal logical operations (GH-102836)
Sync C/Python implementation of the decimal: logical_ops for contexts.
2025-10-14 11:02:02 +00:00
mdehoon a00655b877 gh-140001: Remove obsolete TCL_WIN_SOCKET macro (from Tcl 7.x) from _tkinter.c (GH-139998)
Co-authored-by: Michiel Jan Laurens de Hoon <mdehoon@Michiels-MacBook-Air.local>
2025-10-13 13:29:42 +03:00
Victor Stinner 35e9d41a9c gh-139482: Add posix._clearenv() function (#139965) 2025-10-11 22:58:43 +02:00
Victor Stinner 166cdaa6fb gh-111489: Remove _PyTuple_FromArray() alias (#139973)
Replace _PyTuple_FromArray() with PyTuple_FromArray().
Remove pycore_tuple.h includes.
2025-10-11 22:58:14 +02:00
Bénédikt Tran cdd3eee7fc gh-139929: fix incorrect OpenSSL version-based guard in _ssl.c (GH-139945)
fix OpenSSL version-based guards
2025-10-11 10:34:08 -07:00
Kumar Aditya b881df47ff gh-139894: fix incorrect sharing of current task while forking in asyncio (#139897)
Fix incorrect sharing of current task with the forked child process by clearing thread state's current task and current loop in `PyOS_AfterFork_Child`.
2025-10-10 21:58:23 +05:30
Victor Stinner d0b18b19fa gh-129813: Fix PyBytesWriter tests (#139892) 2025-10-10 13:01:06 +02:00
Nadeshiko Manju 7cafd76a7f gh-139184: Set O_CLOEXEC for master_fd when calling os.forkpty() (#139408)
Signed-off-by: Manjusaka <me@manjusaka.me>
Co-authored-by: Shamil <ashm.tech@proton.me>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-10-10 10:56:10 +02:00
Victor Stinner e31c22dbf9 gh-111489: Add PyTuple_FromArray() function (#139691) 2025-10-10 08:54:12 +02:00
Alper 7f155f9c46 gh-116738: make mmap module thread-safe (#139237) 2025-10-09 12:00:47 +05:30
Bénédikt Tran b04a57deef gh-139748: fix leaks in AC error paths when using unicode FS-based converters (#139765) 2025-10-08 20:52:44 +05:30
Kumar Aditya 49fb46f555 gh-139774: use relaxed atomics for datetime hashes (#139775) 2025-10-08 19:49:54 +05:30
Victor Stinner c4e7d245d6 gh-138342: Move _PyObject_VisitType() to the internal C API (#139734) 2025-10-08 12:10:58 +02:00
Victor Stinner 5a77f02d72 gh-79315: Remove Include/pylock.h and Include/monitoring.h (#139731)
Keep Include/cpython/pylock.h and Include/cpython/monitoring.h.
2025-10-08 00:49:24 +02:00
Skip Montanaro d1ca001d35 gh-127330: Comment correction in _ssl.c (#139603) 2025-10-05 19:15:46 +01:00
Sebastian Pipping 6edb2ddb5f gh-139400: Make sure that parent parsers outlive their subparsers in pyexpat (#139403)
* Modules/pyexpat.c: Disallow collection of in-use parent parsers.

Within libexpat, a parser created via `XML_ExternalEntityParserCreate`
is relying on its parent parser throughout its entire lifetime.
Prior to this fix, is was possible for the parent parser to be
garbage-collected too early.
2025-10-05 17:37:42 +02:00
Zachary Ware 98e748b3a0 gh-139573: Update OpenSSL in CI (GH-139577) 2025-10-04 19:43:17 -05:00
Sebastian Pipping fc48a3c9ca gh-90949: Fix an "unused function" compiler warning introduced in GH-139234 (#139558)
Fix a compiler warning `-Wunused-function` after f04bea44c3.

The `set_invalid_arg` function in `Modules/pyexpat.c` may be unused if the underlying Expat
version is less than 2.4.0.
2025-10-04 14:19:06 +00:00
Dino Viehland ff0cf0af10 gh-139525: Don't specialize functions which have a modified vectorcall (#139524)
Don't specialize functions which have a modified vectorcall
2025-10-03 09:58:32 -07:00
Victor Stinner 4e7e2dd043 gh-139322: Reenable test_os.test_getlogin() (#139498)
Fix also getlogin() errno.
2025-10-02 20:51:57 +00:00
Kumar Aditya 76b07c035c gh-116946: partial revert gh-139073 for thread handle type (#139474) 2025-10-01 17:49:31 +00:00
Nadeshiko Manju f39dea3bae gh-123828: Fix data race in _interpchannels._waiting_release (GH-124107) 2025-10-01 11:34:47 +00:00