Commit Graph

14776 Commits

Author SHA1 Message Date
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
Tomasz Pytel 6c67904e79
gh-128657: fix _hashopenssl ref/data race (GH-128886) 2025-02-07 18:47:45 -08:00
Irit Katriel a1417b211f
gh-100239: replace BINARY_SUBSCR & family by BINARY_OP with oparg NB_SUBSCR (#129700) 2025-02-07 22:39:54 +00:00
Kumar Aditya 0d68b14a0d
gh-128002: use per threads tasks linked list in asyncio (#128869)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2025-02-06 19:51:07 +01:00
Kumar Aditya e7bc0cd182
gh-91048: fix `_asyncio.future_discard_from_awaited_by` (#129731)
fix discard
2025-02-06 16:35:33 +00:00
Kumar Aditya 75c551974f
gh-91048: fix thread safety for asyncio stack introspection APIs (#129399) 2025-02-06 21:33:52 +05:30
Victor Stinner dc804ffb2f
gh-128911: Use PyImport_ImportModuleAttr() function (#129657)
* Replace PyImport_ImportModule() + PyObject_GetAttr() with
  PyImport_ImportModuleAttr().
* Replace PyImport_ImportModule() + PyObject_GetAttrString() with
  PyImport_ImportModuleAttrString().
2025-02-05 11:03:58 +01:00
Victor Stinner 14489c1bb4
gh-129354: Use PyErr_FormatUnraisable() function (#129656)
Replace PyErr_WriteUnraisable() with PyErr_FormatUnraisable().
2025-02-04 16:21:10 +01:00
Victor Stinner 218f205f20
gh-129354: Use PyErr_FormatUnraisable() function (#129524)
Replace PyErr_WriteUnraisable() with PyErr_FormatUnraisable().

Update test_sqlite3 tests.

Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2025-02-03 12:10:18 +00:00
Victor Stinner df4a2f5bd7
gh-129539: Reorganize posixmodule.c header (#129558)
Add sections: Python includes, system includes, etc.

Add a comment explaining why an include is needed.
2025-02-02 09:16:48 +00:00
Victor Stinner 71ae93374d
gh-93649: Move _testcapi tests to specific files (#129544)
Move many functions from _testcapimodule.c into more specific files
in Modules/_testcapi/.

In moved code:

* Replace get_testerror() with PyExc_AssertionError.
* Replace raiseTestError() with
  PyErr_Format(PyExc_AssertionError, ...).
2025-02-01 13:39:16 +01:00
Victor Stinner 60a85415ae
gh-93649: Add Modules/_testcapi/function.c file (#129521)
* Move PyFunction C API tests to a new file.
* Add Lib/test/test_capi/test_function.py.
* Move tests from test_capi.test_misc to test_capi.test_function.
2025-01-31 16:02:50 +01:00
Pablo Galindo Salgado 7eaef74561
gh-129430: Make walking vm regions more efficient in MacOS (#129494) 2025-01-31 14:08:48 +00:00
Victor Stinner 79f85a0bc1
gh-129354: Use PyErr_FormatUnraisable() function (#129518)
Replace PyErr_WriteUnraisable() with PyErr_FormatUnraisable().
2025-01-31 15:06:14 +01:00
Victor Stinner 5424e3b034
gh-93649: Add Modules/_testcapi/type.c file (#129516)
Move PyType C API tests to a new file.

Move following tests from test_capi.test_misc to test_capi.test_type:

* BuiltinStaticTypesTests
* test_get_type_name()
* test_get_base_by_token()
2025-01-31 15:03:54 +01:00
Bénédikt Tran 881984b41a
gh-111178: fix UBSan failures in `Modules/_sqlite` (GH-129087)
* fix UBSan failures for `pysqlite_Blob`
* fix UBSan failures for `pysqlite_Connection`
* fix UBSan failures for `pysqlite_Cursor`
* fix UBSan failures for `pysqlite_PrepareProtocol`
* fix UBSan failures for `pysqlite_Row`
* fix UBSan failures for `pysqlite_Statement`

* suppress unused return values
2025-01-31 14:33:30 +01:00
Serhiy Storchaka 9d63ae5fe5
gh-129502: Fix handling errors in ctypes callbacks (GH-129504)
Unlikely errors in preparing arguments for ctypes callback are now
handled in the same way as errors raised in the callback of in converting
the result of the callback -- using sys.unraisablehook() instead of
sys.excepthook() and not setting sys.last_exc and other variables.
2025-01-31 15:30:19 +02:00
Victor Stinner 3447f4a56a
gh-129354: Use PyErr_FormatUnraisable() function (#129514)
Replace PyErr_WriteUnraisable() with PyErr_FormatUnraisable().
2025-01-31 14:20:35 +01:00
Victor Stinner 8b70ff5872
gh-93649: Move PyFrame C API tests to test_capi (#129512)
* Add Lib/test/test_capi/test_frame.py file.
* Move C API tests from test_frame to test_capi.test_frame.
* Add Modules/_testcapi/frame.c file.
* Move C API tests from _testcapimodule.c to frame.c
2025-01-31 13:51:58 +01:00
Victor Stinner 0373926260
gh-129354: Use PyErr_FormatUnraisable() function (#129511)
Replace PyErr_WriteUnraisable() with PyErr_FormatUnraisable().
2025-01-31 13:16:08 +01:00
Petr Viktorin 31c82c28f9
GH-128469: Revert "warn when libpython was loaded from outside the build directory (#128645)" (#129506) 2025-01-31 11:17:37 +00:00
Victor Stinner 95504f429e
gh-129354: Fix grammar in PyErr_FormatUnraisable() (#129475)
Replace "on verb+ing" with "while verb+ing".
2025-01-31 09:45:35 +01:00
Kumar Aditya c07ac3c86a
gh-128452: fix warning in socketmodule.c (#129478) 2025-01-31 13:41:11 +05:30
Victor Stinner 4ca9fc08f8
gh-111495: Add PyFile tests (#129449)
Add tests for the following functions in test_capi.test_file:

* PyFile_FromFd()
* PyFile_GetLine()
* PyFile_NewStdPrinter()
* PyFile_WriteObject()
* PyFile_WriteString()
* PyObject_AsFileDescriptor()

Add Modules/_testlimitedcapi/file.c file.

Remove test_embed.StdPrinterTests which became redundant.
2025-01-30 18:05:32 +01:00
Victor Stinner 4e47e05045
gh-129354: Use PyErr_FormatUnraisable() function (#129435)
Replace PyErr_WriteUnraisable() with PyErr_FormatUnraisable().
2025-01-30 16:09:38 +01:00
Victor Stinner 3bebe46d34
gh-128911: Add PyImport_ImportModuleAttr() function (#128912)
Add PyImport_ImportModuleAttr() and
PyImport_ImportModuleAttrString() functions.

* Add unit tests.
* Replace _PyImport_GetModuleAttr()
  with PyImport_ImportModuleAttr().
* Replace _PyImport_GetModuleAttrString()
  with PyImport_ImportModuleAttrString().
* Remove "pycore_import.h" includes, no longer needed.
2025-01-30 11:17:29 +00:00
Sergey B Kirpichev 6c63afc3be
gh-129467: Fix compiler warning in mpdecimal word_to_string() (#116346)
Turn off false-positive -Wstringop-overflow in word_to_string().
2025-01-30 11:57:55 +01:00
Bénédikt Tran 9bc8c5fc0c
gh-111178: fix UBSan failures in `Modules/_ssl/cert.c` (GH-129088)
fix UBSan failures for `PySSLCertificate`
2025-01-30 11:11:37 +01:00
Filipe Laíns 🇵🇸 29b3ce8355
GH-128469: warn when libpython was loaded from outside the build directory (#128645)
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-01-29 22:35:55 +00:00
Brandt Bucher 002c4e2982
GH-129386: Use symbolic constants for specialization tests (GH-129415) 2025-01-29 10:49:58 -08:00
Pieter Eendebak a29221675e
gh-127119: Faster check for small ints in long_dealloc (GH-127620) 2025-01-29 15:22:18 +00:00
Burkov Egor 25cf79a082
gh-129345: null check for indent syslogmodule (#129348) 2025-01-29 19:19:23 +05:30
Srinivas Reddy Thatiparthy (తాటిపర్తి శ్రీనివాస్ రెడ్డి) 97b0ef05d9
gh-129409: Fix Integer overflow - SEGV while writing data more than 2GB in CSV file (#129413) 2025-01-29 11:15:47 +00:00
Brandt Bucher 828b27680f
GH-126599: Remove the PyOptimizer API (GH-129194) 2025-01-28 16:10:51 -08:00
Sam Gross d23f5701ad
gh-128844: Make `_Py_TryIncref` public as an unstable API. (#128926)
This exposes `_Py_TryIncref` as `PyUnstable_TryIncref()` and the helper
function `_PyObject_SetMaybeWeakref` as `PyUnstable_EnableTryIncRef`.

These are helpers for dealing with unowned references in a safe way,
particularly in the free threading build.

Co-authored-by: Petr Viktorin <encukou@gmail.com>
2025-01-28 19:32:27 +00:00
Erlend E. Aasland 379ab856f5
gh-129346: Handle allocation errors for SQLite aggregate context (#129347) 2025-01-27 18:16:19 +01:00
Bénédikt Tran d6f010dead
gh-111178: fix UBSan failures in `Modules/_decimal` (GH-129074)
* Introduce & use cast macros
* fix UBSan failures for `PyDecContextObject`
* fix UBSan failures for `PyDecContextManagerObject`
* remove redundant casts for `PyDecObject`
2025-01-27 15:15:42 +01:00
Bénédikt Tran 6bb03c7490
gh-111178: fix UBSan failures in `Modules/socketmodule.c` (GH-128249) 2025-01-27 15:06:10 +01:00
Bénédikt Tran 922cfecbce
gh-111178: fix UBSan failures in `Modules/{blake2,md5,sha1,sha2,sha3}module.c` (GH-128248)
- fix UBSan failures in `blake2module.c`
- fix UBSan failures in `md5module.c`
- fix UBSan failures in `sha1module.c`
- fix UBSan failures in `sha2module.c`
- fix UBSan failures in `sha3module.c`

Cosmetics:

- suppress unused return values
- remove redundant casts in constructors
- suppress unused parameters in `{md5,sha*,blake2}module.c`
2025-01-27 14:50:58 +01:00
Peter Bierma 3fb5f6eb9b
gh-128509: Add `PyUnstable_IsImmortal` for finding immortal objects (GH-129182)
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2025-01-27 14:36:33 +01:00
donBarbos 5d9b62005a
gh-126107: Remove copyright block from Modules/config.c.in (#126982)
chore: remove copyright block from config.c.in
2025-01-26 16:57:32 +00:00
Cody Maloney 1ed4487968
gh-129205: Add os.readinto() API for reading data into a caller provided buffer (#129211)
Add a new OS API which will read data directly into a caller provided
writeable buffer protocol object.

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-01-26 14:21:03 +01:00
Victor Stinner be98fda7c6
gh-129223: Raise KeyError in search_map_for_section() if not found (#129262) 2025-01-25 18:19:48 +01:00
Pablo Galindo Salgado 7a54a653b7
gh-129271: Fix reference leak with unicode writer in fast path in the json module (#129272) 2025-01-25 17:54:20 +01:00
Bénédikt Tran f10b7b29cb
gh-111178: fix UBSan failures in `Modules/cjkcodecs/multibytecodec.c` (gh-129090) 2025-01-25 10:04:31 +09:00
Pablo Galindo Salgado 3a3a6b86f4
gh-129223: Do not allow the compiler to optimise away symbols for debug sections (#129225)
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2025-01-24 21:36:32 +01:00
Kumar Aditya 8e0b36006c
gh-128002: use `_PyObject_SetMaybeWeakref` when creating tasks in asyncio (#128885) 2025-01-24 21:12:56 +05:30
Sergey B Kirpichev 3d8fc8b9ae
gh-127937: Convert decimal to use PEP 757 import API (#127925)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-01-24 11:05:52 +00:00
Victor Stinner 6e63c4736b
gh-119182: Use public PyUnicodeWriter in _json.c (#129249)
Replace the private _PyUnicodeWriter API with the public
PyUnicodeWriter API.
2025-01-24 11:38:13 +01:00
Victor Stinner 732670d93b
gh-119182: Use public PyUnicodeWriter in stringio.c (#129243)
Replace the private _PyUnicodeWriter API with the public
PyUnicodeWriter API.
2025-01-23 23:31:49 +00:00
Łukasz Langa fc3d400165
gh-91048: Also clear and set ts->asyncio_running_task with eager tasks (#129197)
This was missing from gh-124640. It's already covered by the new
test_asyncio/test_free_threading.py in combination with the runtime
assertion in set_ts_asyncio_running_task.

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-01-23 19:26:36 +01:00
Sergey B Kirpichev 75f59bb629
gh-101410: support custom messages for domain errors in the math module (#124299)
This adds basic support to override default messages for domain errors
in the math_1() helper.  The sqrt(), atanh(), log2(), log10() and log()
functions were modified as examples.  New macro supports gradual
changing of error messages in other 1-arg functions.

Co-authored-by: CharlieZhao <zhaoyu_hit@qq.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-01-23 13:55:25 +00:00
Victor Stinner 46c7e13c05
gh-129185: Fix PyTraceMalloc_Untrack() at Python exit (#129191)
Support calling PyTraceMalloc_Track() and PyTraceMalloc_Untrack()
during late Python finalization.

* Call _PyTraceMalloc_Fini() later in Python finalization.
* Test also PyTraceMalloc_Untrack() without the GIL
* PyTraceMalloc_Untrack() now gets the GIL.
* Test also PyTraceMalloc_Untrack() in test_tracemalloc_track_race().
2025-01-23 12:07:34 +01:00
Victor Stinner 1d485db953
gh-128863: Deprecate _PyLong_Sign() function (#129176)
Replace _PyLong_Sign() with PyLong_GetSign().
2025-01-23 03:11:53 +01:00
Victor Stinner 327a257e6a
gh-119182: Use public PyUnicodeWriter in wrap_strftime() (#129206)
Replace the private _PyUnicodeWriter API with the public
PyUnicodeWriter API.
2025-01-23 01:18:26 +01:00