summaryrefslogtreecommitdiffstats
path: root/Misc/NEWS.d/next/C API
Commit message (Collapse)AuthorAgeFilesLines
* Python 3.13.0a2v3.13.0a2Thomas Wouters2023-11-2219-93/+0
|
* gh-111863: Rename blurb snippet placed in the wrong directory by accident. ↵T. Wouters2023-11-211-0/+1
| | | | | (#112300) Rename blurb snippet placed in the wrong directory by accident.
* gh-111956: Add thread-safe one-time initialization. (gh-111960)Sam Gross2023-11-161-0/+2
|
* gh-112026: Add again _PyThreadState_UncheckedGet() function (#112121)Victor Stinner2023-11-151-0/+3
| | | | Add again the private _PyThreadState_UncheckedGet() function as an alias to the new public PyThreadState_GetUnchecked() function.
* gh-112026: Restore removed _PyDict_GetItemStringWithError() (#112119)Victor Stinner2023-11-151-0/+2
| | | | Restore the removed _PyDict_GetItemStringWithError() function. It is used by numpy.
* gh-112026: Restore removed private C API (#112115)Victor Stinner2023-11-151-0/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Restore removed private C API functions, macros and structures which have no simple replacement for now: * _PyDict_GetItem_KnownHash() * _PyDict_NewPresized() * _PyHASH_BITS * _PyHASH_IMAG * _PyHASH_INF * _PyHASH_MODULUS * _PyHASH_MULTIPLIER * _PyLong_Copy() * _PyLong_FromDigits() * _PyLong_New() * _PyLong_Sign() * _PyObject_CallMethodId() * _PyObject_CallMethodNoArgs() * _PyObject_CallMethodOneArg() * _PyObject_CallOneArg() * _PyObject_EXTRA_INIT * _PyObject_FastCallDict() * _PyObject_GetAttrId() * _PyObject_Vectorcall() * _PyObject_VectorcallMethod() * _PyStack_AsDict() * _PyThread_CurrentFrames() * _PyUnicodeWriter structure * _PyUnicodeWriter_Dealloc() * _PyUnicodeWriter_Finish() * _PyUnicodeWriter_Init() * _PyUnicodeWriter_Prepare() * _PyUnicodeWriter_PrepareKind() * _PyUnicodeWriter_WriteASCIIString() * _PyUnicodeWriter_WriteChar() * _PyUnicodeWriter_WriteLatin1String() * _PyUnicodeWriter_WriteStr() * _PyUnicodeWriter_WriteSubstring() * _PyUnicode_AsString() * _PyUnicode_FromId() * _PyVectorcall_Function() * _Py_HashDouble() * _Py_HashPointer() * _Py_IDENTIFIER() * _Py_c_abs() * _Py_c_diff() * _Py_c_neg() * _Py_c_pow() * _Py_c_prod() * _Py_c_quot() * _Py_c_sum() * _Py_static_string() * _Py_static_string_init()
* gh-112026: Add again <unistd.h> include in Python.h (#112046)Victor Stinner2023-11-151-0/+3
| | | | Add again <ctype.h> and <unistd.h> includes in Python.h, but don't include them in the limited C API version 3.13 and newer.
* gh-111262: Add PyDict_Pop() function (#112028)Victor Stinner2023-11-141-0/+4
| | | | | | | _PyDict_Pop_KnownHash(): remove the default value and the return type becomes an int. Co-authored-by: Stefan Behnel <stefan_ml@behnel.de> Co-authored-by: Antoine Pitrou <pitrou@free.fr>
* gh-111138: Add PyList_Extend() and PyList_Clear() functions (#111862)Victor Stinner2023-11-131-0/+2
| | | | | | * Split list_extend() into two sub-functions: list_extend_fast() and list_extend_iter(). * list_inplace_concat() no longer has to call Py_DECREF() on the list_extend() result, since list_extend() now returns an int.
* gh-111569: Implement Python critical section API (gh-111571)Sam Gross2023-11-081-0/+3
| | | | | | | | Critical sections are helpers to replace the global interpreter lock with finer grained locking. They provide similar guarantees to the GIL and avoid the deadlock risk that plain locking involves. Critical sections are implicitly ended whenever the GIL would be released. They are resumed when the GIL would be acquired. Nested critical sections behave as if the sections were interleaved.
* gh-111089: Revert PyUnicode_AsUTF8() changes (#111833)Victor Stinner2023-11-072-4/+0
| | | | | | | | | | | | | | | | | | | | | * Revert "gh-111089: Use PyUnicode_AsUTF8() in Argument Clinic (#111585)" This reverts commit d9b606b3d04fc56fb0bcc479d7d6c14562edb5e2. * Revert "gh-111089: Use PyUnicode_AsUTF8() in getargs.c (#111620)" This reverts commit cde1071b2a72e8261ca66053ef61431b7f3a81fd. * Revert "gh-111089: PyUnicode_AsUTF8() now raises on embedded NUL (#111091)" This reverts commit d731579bfb9a497cfb0076cb6b221058a20088fe. * Revert "gh-111089: Add PyUnicode_AsUTF8() to the limited C API (#111121)" This reverts commit d8f32be5b6a736dc2fc9dca3f1bf176c82fc9b44. * Revert "gh-111089: Use PyUnicode_AsUTF8() in sqlite3 (#111122)" This reverts commit 37e4e20eaa8f27ada926d49e5971fecf0477ad26.
* gh-106672: C API: Report indiscriminately ignored errors (GH-106674)Serhiy Storchaka2023-11-071-0/+5
| | | | | Functions which indiscriminately ignore all errors now report them as unraisable errors.
* gh-111506: Implement Py_SET_REFCNT() as opaque function in limited C API ↵Victor Stinner2023-11-031-0/+2
| | | | | | | | (#111508) In the limited C API version 3.13, Py_SET_REFCNT() function is now implemented as an opaque function call. Add _Py_SetRefcnt() to the stable ABI.
* gh-108082: Add PyErr_FormatUnraisable() function (GH-111086)Serhiy Storchaka2023-10-311-0/+1
|
* gh-108765: Python.h no longer includes <stddef.h> on Windows (#111563)Victor Stinner2023-10-311-0/+3
| | | | In practice, only Windows is impacted, because the HAVE_STDDEF_H macro was only defined on Windows.
* gh-109587: Allow "precompiled" perf-trampolines to largely mitigate the cost ↵gsallam2023-10-271-0/+2
| | | | of enabling perf-trampolines (#109666)
* gh-67565: Remove redundant C-contiguity checks (GH-105521)Furkan Onder2023-10-231-0/+1
| | | | Co-authored-by: Stefan Krah <skrah@bytereef.org>
* gh-111089: Add PyUnicode_AsUTF8() to the limited C API (#111121)Victor Stinner2023-10-201-0/+2
| | | | | | | | Add PyUnicode_AsUTF8() function to the limited C API. multiprocessing posixshmem now uses PyUnicode_AsUTF8() instead of PyUnicode_AsUTF8AndSize(): the extension is built with the limited C API. The function now raises an exception if the filename contains an embedded null character instead of truncating silently the filename.
* gh-111089: PyUnicode_AsUTF8() now raises on embedded NUL (#111091)Victor Stinner2023-10-201-0/+2
| | | | | | | | | * PyUnicode_AsUTF8() now raises an exception if the string contains embedded null characters. * Update related C API tests (test_capi.test_unicode). * type_new_set_doc() uses PyUnicode_AsUTF8AndSize() to silently truncate doc containing null bytes. Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* gh-85283: Add PySys_Audit() to the limited C API (#108571)Victor Stinner2023-10-171-0/+2
| | | | | | | | | | The PySys_Audit() function was added in Python 3.8 by the PEP 578 "Python Runtime Audit Hooks". Add also PySys_AuditTuple() to the limited C API, function added to Python 3.13. Move non-limited "PerfMap" C API from Include/sysmodule.h to Include/cpython/sysmodule.h.
* gh-110964: Remove private _PyArg functions (#110966)Victor Stinner2023-10-171-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Move the following private functions and structures to pycore_modsupport.h internal C API: * _PyArg_BadArgument() * _PyArg_CheckPositional() * _PyArg_NoKeywords() * _PyArg_NoPositional() * _PyArg_ParseStack() * _PyArg_ParseStackAndKeywords() * _PyArg_Parser structure * _PyArg_UnpackKeywords() * _PyArg_UnpackKeywordsWithVararg() * _PyArg_UnpackStack() * _Py_ANY_VARARGS() Changes: * Python/getargs.h now includes pycore_modsupport.h to export functions. * clinic.py now adds pycore_modsupport.h when one of these functions is used. * Add pycore_modsupport.h includes when a C extension uses one of these functions. * Define Py_BUILD_CORE_MODULE in C extensions which now include directly or indirectly (via code generated by Argument Clinic) pycore_modsupport.h: * _csv * _curses_panel * _dbm * _gdbm * _multiprocessing.posixshmem * _sqlite.row * _statistics * grp * resource * syslog * _testcapi: bad_get() no longer uses METH_FASTCALL calling convention but METH_VARARGS. Replace _PyArg_UnpackStack() with PyArg_ParseTuple(). * _testcapi: add PYTESTCAPI_NEED_INTERNAL_API macro which is defined by _testcapi sub-modules which need the internal C API (pycore_modsupport.h): exceptions.c, float.c, vectorcall.c, watchers.c. * Remove Include/cpython/modsupport.h header file. Include/modsupport.h no longer includes the removed header file. * Fix mypy clinic.py
* gh-85283: Add PyMem_RawMalloc() to the limited C API (#108570)Victor Stinner2023-10-171-0/+3
| | | | | | | | | Add PyMem_RawMalloc(), PyMem_RawCalloc(), PyMem_RawRealloc() and PyMem_RawFree() to the limited C API. These functions were added by Python 3.4 and are needed to port stdlib extensions to the limited C API, like grp and pwd. Co-authored-by: Erlend E. Aasland <erlend@python.org>
* gh-110815: Support non-ASCII keyword names in PyArg_ParseTupleAndKeywords() ↵Serhiy Storchaka2023-10-141-0/+1
| | | | | | | (GH-110816) It already mostly worked, except in the case when invalid keyword argument with non-ASCII name was passed to function with non-ASCII parameter names. Then it crashed in the debug mode.
* Python 3.13.0a1v3.13.0a1Thomas Wouters2023-10-1358-211/+0
|
* gh-85283: If Py_LIMITED_API is defined, undefine Py_BUILD_CORE (#110725)Victor Stinner2023-10-111-0/+3
| | | | | | | | | | | If the Py_LIMITED_API macro is defined, Py_BUILD_CORE, Py_BUILD_CORE_BUILTIN and Py_BUILD_CORE_MODULE macros are now undefined by Python.h. Only undefine these 3 macros after including "exports.h" which uses them to define PyAPI_FUNC(), PyAPI_DATA() and PyMODINIT_FUNC macros. Remove hacks (undefine manually the 3 Py_BUILD_CORE macros) in Modules/_testcapi/parts.h and Modules/_testclinic_limited.c.
* gh-110289: C API: Add PyUnicode_EqualToUTF8() and ↵Serhiy Storchaka2023-10-111-0/+1
| | | | PyUnicode_EqualToUTF8AndSize() functions (GH-110297)
* gh-84489: Properly handle trailing spaces in Py_BuildValue() format strings ↵Zackery Spytz2023-10-111-0/+1
| | | | | | | | | (GH-21158) The docs state that the space, tab, colon, and comma characters are ignored in Py_BuildValue() format strings. Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* gh-85283: Add PySys_AuditTuple() function (#108965)Victor Stinner2023-10-051-0/+3
| | | | | | sys.audit() now has assertions to check that the event argument is not NULL and that the format argument does not use the "N" format. Add tests on PySys_AuditTuple().
* gh-110235: Raise TypeError for duplicate/unknown fields in PyStructSequence ↵Xuehai Pan2023-10-041-0/+2
| | | | constructor (GH-110258)
* gh-108867: Add PyThreadState_GetUnchecked() function (#108870)Victor Stinner2023-10-031-0/+5
| | | | | | Add PyThreadState_GetUnchecked() function: similar to PyThreadState_Get(), but don't issue a fatal error if it is NULL. The caller is responsible to check if the result is NULL. Previously, this function was private and known as _PyThreadState_UncheckedGet().
* gh-107073: Make PyObject_VisitManagedDict() public (#108763)Victor Stinner2023-10-021-0/+3
| | | | | | | | Make PyObject_VisitManagedDict() and PyObject_ClearManagedDict() functions public in Python 3.13 C API. * Rename _PyObject_VisitManagedDict() to PyObject_VisitManagedDict(). * Rename _PyObject_ClearManagedDict() to PyObject_ClearManagedDict(). * Document these functions.
* gh-110014: Remove PY_TIMEOUT_MAX from limited C API (#110217)Victor Stinner2023-10-021-0/+2
| | | | | | | | If the timeout is greater than PY_TIMEOUT_MAX, PyThread_acquire_lock_timed() uses a timeout of PY_TIMEOUT_MAX microseconds, which is around 280.6 years. This case is unlikely and limiting a timeout to 280.6 years sounds like a reasonable trade-off. The constant PY_TIMEOUT_MAX is not used in PyPI top 5,000 projects.
* gh-109521: Fix obscure cases handling in PyImport_GetImporter() (GH-109522)Serhiy Storchaka2023-09-231-0/+5
| | | | | | | | PyImport_GetImporter() now sets RuntimeError if it fails to get sys.path_hooks or sys.path_importer_cache or they are not list and dict correspondingly. Previously it could return NULL without setting error in obscure cases, crash or raise SystemError if these attributes have wrong type.
* Fix typos in docs and comments (#109619)Heinz-Alexander Fuetterer2023-09-201-1/+1
|
* gh-108724: Add PyMutex and _PyParkingLot APIs (gh-109344)Sam Gross2023-09-191-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | PyMutex is a one byte lock with fast, inlineable lock and unlock functions for the common uncontended case. The design is based on WebKit's WTF::Lock. PyMutex is built using the _PyParkingLot APIs, which provides a cross-platform futex-like API (based on WebKit's WTF::ParkingLot). This internal API will be used for building other synchronization primitives used to implement PEP 703, such as one-time initialization and events. This also includes tests and a mini benchmark in Tools/lockbench/lockbench.py to compare with the existing PyThread_type_lock. Uncontended acquisition + release: * Linux (x86-64): PyMutex: 11 ns, PyThread_type_lock: 44 ns * macOS (arm64): PyMutex: 13 ns, PyThread_type_lock: 18 ns * Windows (x86-64): PyMutex: 13 ns, PyThread_type_lock: 38 ns PR Overview: The primary purpose of this PR is to implement PyMutex, but there are a number of support pieces (described below). * PyMutex: A 1-byte lock that doesn't require memory allocation to initialize and is generally faster than the existing PyThread_type_lock. The API is internal only for now. * _PyParking_Lot: A futex-like API based on the API of the same name in WebKit. Used to implement PyMutex. * _PyRawMutex: A word sized lock used to implement _PyParking_Lot. * PyEvent: A one time event. This was used a bunch in the "nogil" fork and is useful for testing the PyMutex implementation, so I've included it as part of the PR. * pycore_llist.h: Defines common operations on doubly-linked list. Not strictly necessary (could do the list operations manually), but they come up frequently in the "nogil" fork. ( Similar to https://man.freebsd.org/cgi/man.cgi?queue) --------- Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
* gh-108511: Add C API functions which do not silently ignore errors (GH-109025)Serhiy Storchaka2023-09-171-0/+4
| | | | | | | | | Add the following functions: * PyObject_HasAttrWithError() * PyObject_HasAttrStringWithError() * PyMapping_HasKeyWithError() * PyMapping_HasKeyStringWithError()
* gh-108765: Python.h no longer includes <ctype.h> (#108831)Victor Stinner2023-09-031-0/+5
| | | | | | | | | | | | | | | | | | | | | | | Remove <ctype.h> in C files which don't use it; only sre.c and _decimal.c still use it. Remove _PY_PORT_CTYPE_UTF8_ISSUE code from pyport.h: * Code added by commit b5047fd01948ab108edcc1b3c2c901d915814cfd in 2004 for MacOSX and FreeBSD. * Test removed by commit 52ddaefb6bab1a74ecffe8519c02735794ebfbe1 in 2007, since Python str type now uses locale independent functions like Py_ISALPHA() and Py_TOLOWER() and the Unicode database. Modules/_sre/sre.c replaces _PY_PORT_CTYPE_UTF8_ISSUE with new functions: sre_isalnum(), sre_tolower(), sre_toupper(). Remove unused includes: * _localemodule.c: remove <stdio.h>. * getargs.c: remove <float.h>. * dynload_win.c: remove <direct.h>, it no longer calls _getcwd() since commit fb1f68ed7cc1536482d1debd70a53c5442135fe2 (in 2001).
* gh-108765: Python.h no longer includes <sys/time.h> (#108775)Victor Stinner2023-09-021-0/+6
| | | | | | | | | Python.h no longer includes <time.h>, <sys/select.h> and <sys/time.h> standard header files. * Add <time.h> include to xxsubtype.c. * Add <sys/time.h> include to posixmodule.c and semaphore.c. * readline.c includes <sys/select.h> instead of <sys/time.h>. * resource.c no longer includes <time.h> and <sys/time.h>.
* gh-108765: Python.h no longer includes <unistd.h> (#108783)Victor Stinner2023-09-021-0/+4
|
* gh-108765: Python.h no longer includes <ieeefp.h> (#108781)Victor Stinner2023-09-021-0/+4
| | | | Remove also the HAVE_IEEEFP_H macro: remove ieeefp.h from the AC_CHECK_HEADERS() check of configure.ac.
* gh-108337: Add pyatomic.h header (#108701)Victor Stinner2023-08-311-0/+1
| | | | | | | | This adds a new header that provides atomic operations on common data types. The intention is that this will be exposed through Python.h, although that is not the case yet. The only immediate use is in the test file. Co-authored-by: Sam Gross <colesbury@gmail.com>
* gh-108634: Py_TRACE_REFS uses a hash table (#108663)Victor Stinner2023-08-311-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Python built with "configure --with-trace-refs" (tracing references) is now ABI compatible with Python release build and debug build. Moreover, it now also supports the Limited API. Change Py_TRACE_REFS build: * Remove _PyObject_EXTRA_INIT macro. * The PyObject structure no longer has two extra members (_ob_prev and _ob_next). * Use a hash table (_Py_hashtable_t) to trace references (all objects): PyInterpreterState.object_state.refchain. * Py_TRACE_REFS build is now ABI compatible with release build and debug build. * Limited C API extensions can now be built with Py_TRACE_REFS: xxlimited, xxlimited_35, _testclinic_limited. * No longer rename PyModule_Create2() and PyModule_FromDefAndSpec2() functions to PyModule_Create2TraceRefs() and PyModule_FromDefAndSpec2TraceRefs(). * _Py_PrintReferenceAddresses() is now called before finalize_interp_delete() which deletes the refchain hash table. * test_tracemalloc find_trace() now also filters by size to ignore the memory allocated by _PyRefchain_Trace(). Test changes for Py_TRACE_REFS: * Add test.support.Py_TRACE_REFS constant. * Add test_sys.test_getobjects() to test sys.getobjects() function. * test_exceptions skips test_recursion_normalizing_with_no_memory() and test_memory_error_in_PyErr_PrintEx() if Python is built with Py_TRACE_REFS. * test_repl skips test_no_memory(). * test_capi skisp test_set_nomemory().
* gh-108444: Add PyLong_AsInt() public function (#108445)Victor Stinner2023-08-241-0/+4
| | | | | | * Rename _PyLong_AsInt() to PyLong_AsInt(). * Add documentation. * Add test. * For now, keep _PyLong_AsInt() as an alias to PyLong_AsInt().
* gh-108314: Add PyDict_ContainsString() function (#108323)Victor Stinner2023-08-241-0/+4
|
* gh-107916: Save the error code before decoding the filename in ↵Serhiy Storchaka2023-08-211-0/+4
| | | | PyErr_SetFromErrnoWithFilename() etc (GH-107929)
* gh-107915: Handle errors in C API functions PyErr_Set*() and PyErr_Format() ↵Serhiy Storchaka2023-08-191-0/+4
| | | | | | | | (GH-107918) Such C API functions as PyErr_SetString(), PyErr_Format(), PyErr_SetFromErrnoWithFilename() and many others no longer crash or ignore errors if it failed to format the error message or decode the filename. Instead, they keep a corresponding error.
* gh-108014: Add Py_IsFinalizing() function (#108032)Victor Stinner2023-08-181-0/+2
| | | Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* gh-107810: Improve DeprecationWarning for metaclasses with custom tp_new ↵Marc Mueller2023-08-101-0/+1
| | | | | | (GH-107834) Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
* gh-107091: Fix some uses of :func: role (GH-107378)Serhiy Storchaka2023-07-291-1/+1
| | | :c:func: or :c:macro: should be used instead.
* gh-107226: PyModule_AddObjectRef() should only be in the limited API 3.10 ↵Serhiy Storchaka2023-07-251-0/+2
| | | | (GH-107227)