Commit graph

14768 commits

Author SHA1 Message Date
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
Victor Stinner
719c9dd72f
gh-119182: Use public PyUnicodeWriter in time_strftime() (#129207)
Replace the private _PyUnicodeWriter API with the public
PyUnicodeWriter API.
2025-01-23 01:18:03 +01:00
Łukasz Langa
67d804b494
GH-91048: Don't attempt to run on FreeBSD (#129189) 2025-01-22 19:27:58 +01:00
Yury Selivanov
188598851d
GH-91048: Add utils for capturing async call stack for asyncio programs and enable profiling (#124640)
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Savannah Ostrowski <savannahostrowski@gmail.com>
Co-authored-by: Jacob Coffee <jacob@z7x.org>
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
2025-01-22 17:25:29 +01:00
Michael Droettboom
3d7c0e5366
gh-129141: Fix build on gcc-9.4.0 (GH-129142) 2025-01-21 19:13:33 +01:00
Petr Viktorin
13475e0a5a
gh-128889: Zero out memory ctypes for generated struct layout tests (GH-128944) 2025-01-21 16:29:02 +01:00
Bénédikt Tran
fafc618e2f
gh-111178: fix UBSan failures in Modules/_ctypes (#129071)
This fixes UBSan failures for the following objects:

- `DictRemoverObject` and `StructParamObject`,
- `CDataObject` and `CFieldObject`, and
- `PyCFuncPtrObject` and `PyCArgObject`.

On the default build, we convert the `LOCK_PTR` and `UNLOCK_PTR` macros to
functions with an unused parameter to ease "unused variable" compiler warnings
suppression. Finally, we also remove some redundant casts to `PyObject *`.
2025-01-21 11:50:13 +01:00
Mark Shannon
f5b6356a11
GH-128563: Add new frame owner type for interpreter entry frames (GH-129078)
Add new frame owner type for interpreter entry frames
2025-01-21 10:15:02 +00:00
Petr Viktorin
d3b1bb228c
gh-128156: Guard use of ffi_type_complex_double on macOS system libffi (GH-128680)
* Determine ffi complex support at runtime
* Also, generate SIMPLE_TYPE_CHARS once at runtime
2025-01-21 10:59:18 +01:00