summaryrefslogtreecommitdiffstats
path: root/Include/cpython
Commit message (Collapse)AuthorAgeFilesLines
* gh-94936: C getters: co_varnames, co_cellvars, co_freevars (GH-95008)Miss Islington (bot)2022-08-041-0/+6
| | | | | (cherry picked from commit 42b102bbf9a9ae6fae8f6710202fb7afeeac277c) Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
* Revert "[3.11] GH-92678: Expose managed dict clear and visit functions ↵Mark Shannon2022-08-041-3/+0
| | | | | (GH-95246). (#95256)" (#95647) This reverts commit 7f731943393d57cf26ed5f2353e6e53084cd55fd.
* [3.11] gh-95174: Add pthread stubs for WASI (GH-95234) (#95503)Christian Heimes2022-08-012-0/+91
| | | | | | Co-authored-by: Brett Cannon <brett@python.org>. (cherry picked from commit 0fe645d6fd22a6f57e777a29e65cf9a4ff9785ae) Co-authored-by: Christian Heimes <christian@python.org>
* [3.11] GH-92678: Expose managed dict clear and visit functions (GH-95246). ↵Pablo Galindo Salgado2022-07-251-0/+3
| | | | | (#95256) Co-authored-by: Mark Shannon <mark@hotpy.org>
* [3.11] GH-93516: Backport GH-93769 (GH-94231)Mark Shannon2022-06-281-0/+1
| | | * Store offset of first traceable instruction to avoid having to recompute it all the time when tracing.
* [3.11] gh-93382: Cache result of `PyCode_GetCode` in codeobject (GH-93383) ↵Ken Jin2022-06-231-0/+1
| | | | | | (#93493) Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Co-authored-by: Dennis Sweeney <36520290+sweeneyde@users.noreply.github.com>
* [3.11] GH-93516: Backport GH-93769: Speedup line number checks when tracing ↵Mark Shannon2022-06-221-1/+3
| | | | | (GH-94127) Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
* gh-93937, C API: Move PyFrame_GetBack() to Python.h (#93938) (#94000)Victor Stinner2022-06-202-13/+17
| | | | | | | | | | | | | | | | | | Move the follow functions and type from frameobject.h to pyframe.h, so the standard <Python.h> provide frame getter functions: * PyFrame_Check() * PyFrame_GetBack() * PyFrame_GetBuiltins() * PyFrame_GetGenerator() * PyFrame_GetGlobals() * PyFrame_GetLasti() * PyFrame_GetLocals() * PyFrame_Type Remove #include "frameobject.h" from many C files. It's no longer needed. (cherry picked from commit 27b989403356ccdd47545a93aeab8434e9c69f21)
* [3.11] gh-93741: Add private C API _PyImport_GetModuleAttrString() ↵Serhiy Storchaka2022-06-141-0/+3
| | | | | | | | | | (GH-93742) (GH-93792) It combines PyImport_ImportModule() and PyObject_GetAttrString() and saves 4-6 lines of code on every use. Add also _PyImport_GetModuleAttr() which takes Python strings as arguments. (cherry picked from commit 6fd4c8ec7740523bb81191c013118d9d6959bc9d)
* gh-89653: PEP 670: Fix PyUnicode_READ() cast (GH-92872)Miss Islington (bot)2022-05-171-1/+2
| | | | | | | _Py_CAST() cannot be used with a constant type: use _Py_STATIC_CAST() instead. (cherry picked from commit e6fd7992a92879103215b3e9f218fe07212af9b1) Co-authored-by: Victor Stinner <vstinner@python.org>
* gh-92781: Avoid mixing declarations and code in C API (#92783) (#92813)Victor Stinner2022-05-163-9/+13
| | | | | | | Avoid mixing declarations and code in the C API to fix the compiler warning: "ISO C90 forbids mixed declarations and code" [-Werror=declaration-after-statement]. (cherry picked from commit 90e72300730189c4a48529baaad9b0005d40731c)
* gh-89653: PEP 670: unicodeobject.h uses _Py_CAST() (GH-92696) (GH-92703)Miss Islington (bot)2022-05-121-6/+12
| | | | | | | | | | | | | | | Use _Py_CAST() and _Py_STATIC_CAST() in macros wrapping static inline functions of unicodeobject.h. Change also the kind type from unsigned int to int: same parameter type than PyUnicode_FromKindAndData(). The limited API version 3.11 no longer casts arguments to expected types. (cherry picked from commit d0c9353a79c2003385c83892db5dfd4e443474c9) Co-authored-by: Victor Stinner <vstinner@python.org> Co-authored-by: Victor Stinner <vstinner@python.org>
* gh-89653: PEP 670: Use PyObject* type for parameters (GH-92694)Miss Islington (bot)2022-05-112-12/+16
| | | | | | | | | | | | Use the PyObject* type for parameters of static inline functions: * Py_SIZE(): same parameter type than PyObject_Size() * PyList_GET_SIZE(), PyList_SET_ITEM(): same parameter type than PyList_Size() and PyList_SetItem() * PyTuple_GET_SIZE(), PyTuple_SET_ITEM(): same parameter type than PyTuple_Size() and PyTuple_SetItem(). (cherry picked from commit 6de78ef96afbaa127472bb9dc0a4e41e44555d00) Co-authored-by: Victor Stinner <vstinner@python.org>
* gh-89653: PEP 670: Limited API doesn't cast arguments (GH-92654)Miss Islington (bot)2022-05-113-3/+13
| | | | | | | | | | | The limited API version 3.11 no longer casts arguments to expected types of functions of functions: * PyList_GET_SIZE(), PyList_SET_ITEM() * PyTuple_GET_SIZE(), PyTuple_SET_ITEM() * PyWeakref_GET_OBJECT() (cherry picked from commit 7d3b469e475e6e52ce4f0bad7198bb05ead77b1d) Co-authored-by: Victor Stinner <vstinner@python.org>
* gh-57684: Add -P cmdline option and PYTHONSAFEPATH env var (#31542)Victor Stinner2022-05-051-0/+1
| | | | | | | | | | | | Add the -P command line option and the PYTHONSAFEPATH environment variable to not prepend a potentially unsafe path to sys.path. * Add sys.flags.safe_path flag. * Add PyConfig.safe_path member. * Programs/_bootstrap_python.c uses config.safe_path=0. * Update subprocess._optim_args_from_interpreter_flags() to handle the -P command line option. * Modules/getpath.py sets safe_path to 1 if a "._pth" file is present.
* gh-89653: PEP 670: Convert PyCFunction macros to functions (#92302)Victor Stinner2022-05-051-24/+56
| | | | | | | | | | Convert the following macros to static inline functions: * PyCFunction_GET_CLASS() * PyCFunction_GET_FLAGS() * PyCFunction_GET_FUNCTION() * PyCFunction_GET_SELF() Limited C API version 3.11 no longer casts arguments.
* gh-91321: Add _Py_NULL macro (#92253)Victor Stinner2022-05-032-12/+12
| | | | | | | | Fix C++ compiler warnings: "zero as null pointer constant" (clang -Wzero-as-null-pointer-constant). * Add the _Py_NULL macro used by static inline functions to use nullptr in C++. * Replace NULL with nullptr in _testcppext.cpp.
* gh-91320: Fix more old-style cast warnings in C++ (#92247)Victor Stinner2022-05-032-16/+17
| | | | | | | Use _Py_CAST(), _Py_STATIC_CAST() and _PyASCIIObject_CAST() in static inline functions to fix C++ compiler warnings: "use of old-style cast" (clang -Wold-style-cast). test_cppext now builds the C++ test extension with -Wold-style-cast.
* gh-89653: PEP 670: Convert PyBytes macros to functions (#91990)Victor Stinner2022-05-032-10/+43
| | | | | | | | | | | | Convert the following macros to static inline functions: * PyByteArray_AS_STRING() * PyByteArray_GET_SIZE() * PyBytes_AS_STRING() * PyBytes_GET_SIZE() Limited C API version 3.11 no longer casts arguments. Add _PyBytes_CAST() and _PyByteArray_CAST() macros.
* gh-92135: Rename _Py_reinterpret_cast() to _Py_CAST() (#92230)Victor Stinner2022-05-035-8/+8
| | | Rename also _Py_static_cast() to _Py_STATIC_CAST().
* gh-92154: Expose PyCode_GetCode in the C API (GH-92168)Ken Jin2022-05-031-0/+3
|
* gh-91320: Add _Py_reinterpret_cast() macro (#91959)Victor Stinner2022-04-275-8/+16
| | | | | | | | | | | | | | Fix C++ compiler warnings about "old-style cast" (g++ -Wold-style-cast) in the Python C API. Use C++ reinterpret_cast<> and static_cast<> casts when the Python C API is used in C++. Example of fixed warning: Include/object.h:107:43: error: use of old-style cast to ‘PyObject*’ {aka ‘struct _object*’} [-Werror=old-style-cast] #define _PyObject_CAST(op) ((PyObject*)(op)) Add _Py_reinterpret_cast() and _Py_static_cast() macros.
* gh-89653: PEP 670: Functions don't cast pointers (#91697)Victor Stinner2022-04-251-17/+47
| | | | | | | | | | | | | | | | | | | | | In the limited C API version 3.11 and newer, the following functions no longer cast their object pointer argument with _PyObject_CAST() or _PyObject_CAST_CONST(): * Py_REFCNT(), Py_TYPE(), Py_SIZE() * Py_SET_REFCNT(), Py_SET_TYPE(), Py_SET_SIZE() * Py_IS_TYPE() * Py_INCREF(), Py_DECREF() * Py_XINCREF(), Py_XDECREF() * Py_NewRef(), Py_XNewRef() * PyObject_TypeCheck() * PyType_Check() * PyType_CheckExact() Split Py_DECREF() implementation in 3 versions to make the code more readable. Update the xxlimited.c extension, which uses the limited C API version 3.11, to pass PyObject* to these functions.
* gh-80527: Deprecate PEP 623 Unicode functions (#91801)Victor Stinner2022-04-221-5/+11
| | | | | | | | | | | Deprecate functions: * PyUnicode_AS_DATA() * PyUnicode_AS_UNICODE() * PyUnicode_GET_DATA_SIZE() * PyUnicode_GET_SIZE() Previously, these functions were macros and so it wasn't possible to decorate them with Py_DEPRECATED().
* gh-89653: Add assertions to unicodeobject.h functions (#91800)Victor Stinner2022-04-211-0/+7
|
* gh-89653: PEP 670: Convert unicodeobject.h macros to functions (#91799)Victor Stinner2022-04-211-18/+44
| | | | | | | | | | | | Convert unicodeobject.h macros to static inline functions: * PyUnicode_AS_DATA() * PyUnicode_AS_UNICODE() * PyUnicode_GET_DATA_SIZE() * PyUnicode_GET_SIZE() Static inline functions are wrapped by macros which casts arguments with _PyObject_CAST() to prevent introducing new compiler warnings when passing "const PyObject*".
* gh-79315: Add Include/cpython/pythread.h header (#91798)Victor Stinner2022-04-211-0/+39
|
* gh-79315: Add Include/cpython/modsupport.h header (#91797)Victor Stinner2022-04-211-0/+107
|
* gh-89653: PEP 670: Group deprecated API in unicodeobject.h (#91796)Victor Stinner2022-04-211-56/+58
|
* gh-89653: PEP 670: Convert unicodeobject.h macros to functions (#91773)Victor Stinner2022-04-211-57/+74
| | | | | | | | | | | | | | | | | Convert unicodeobject.h macros to static inline functions: * PyUnicode_MAX_CHAR_VALUE() * PyUnicode_READ() * PyUnicode_READY() * PyUnicode_READ_CHAR() * PyUnicode_WRITE() Move PyUnicode_READY() after _PyUnicode_Ready(), since it uses _PyUnicode_Ready(). Static inline functions are wrapped by macros which casts arguments with _PyObject_CAST() and casts 'kind' arguments to "unsigned int" to prevent introducing new compiler warnings when passing "const PyObject*".
* GH-91719: Make MSVC generate somewhat faster switch code (#91718)Guido van Rossum2022-04-211-1/+1
| | | | | | | | | | | Apparently a switch on an 8-bit quantity where all cases are present generates a more efficient jump (doing only one indexed memory load instead of two). So we make opcode and use_tracing uint8_t, and generate a macro full of extra `case NNN:` lines for all unused opcodes. See https://github.com/faster-cpython/ideas/issues/321#issuecomment-1103263673
* GH-88116: Use a compact format to represent end line and column offsets. ↵Mark Shannon2022-04-211-13/+19
| | | | | | | | | | | | (GH-91666) * Stores all location info in linetable to conform to PEP 626. * Remove column table from code objects. * Remove end-line table from code objects. * Document new location table format
* gh-89653: PEP 670: Convert tuple macros to functions (#91786)Victor Stinner2022-04-212-11/+29
| | | | | | | | | | | | | | Convert macros to static inline functions: * PyTuple_GET_SIZE() * PyTuple_SET_ITEM() * PyList_GET_SIZE() * PyList_SET_ITEM() Add a macro converting arguments to PyTupleObject*, PyListObject* or PyObject* to prevent emitting new compiler warnings. According to PEP 670, PyTuple_GET_ITEM() and PyList_GET_ITEM() are left as macros.
* gh-89653: PEP 670: Convert PyWeakref_GET_OBJECT() to function (#91785)Victor Stinner2022-04-211-10/+16
| | | | | | Convert the PyWeakref_GET_OBJECT() macro to a static inline function. Add an assertion to check the argument with PyWeakref_Check(). Add a macro converting the argument to PyObject* to prevent emitting new compiler warning.
* gh-89653: PEP 670: Convert unicodeobject.h macros to functions (#91705)Victor Stinner2022-04-211-41/+61
| | | | | | | | | | | | | | | | | | Convert unicodeobject.h macros to static inline functions: * PyUnicode_CHECK_INTERNED() * PyUnicode_DATA(), _PyUnicode_COMPACT_DATA(), _PyUnicode_NONCOMPACT_DATA() * PyUnicode_GET_LENGTH() * PyUnicode_IS_ASCII() * PyUnicode_IS_COMPACT() * PyUnicode_IS_COMPACT_ASCII() * PyUnicode_IS_READY() Reorder functions to declare functions before their first usage. Static inline functions are wrapped by macros which casts arguments with _PyObject_CAST() to prevent introducing new compiler warnings when passing "const PyObject*".
* gh-89770: Implement PEP-678 - Exception notes (GH-31317)Irit Katriel2022-04-161-1/+1
|
* gh-90501: Add PyErr_GetHandledException and PyErr_SetHandledException (GH-30531)Irit Katriel2022-04-151-0/+2
|
* gh-91502: Add a new API to check if a frame is an entry frame (GH-91503)Pablo Galindo Salgado2022-04-131-0/+10
|
* Add new PyFrame_GetLasti C-API function (GH-32413)Mark Shannon2022-04-081-0/+1
|
* bpo-35134: Remove the Include/code.h header file (GH-32385)Victor Stinner2022-04-071-2/+13
| | | | | | Remove the Include/code.h header file. C extensions should only include the main <Python.h> header file. Python.h includes directly Include/cpython/code.h instead.
* bpo-35134: Add Include/cpython/setobject.h header (GH-32384)Victor Stinner2022-04-061-0/+67
|
* bpo-35134: Add Include/cpython/complexobject.h header (GH-32383)Victor Stinner2022-04-061-0/+44
| | | | Move the private _PyComplex_FormatAdvancedWriter() function to the internal C API. This function is no longer exported.
* Revert "bpo-46850: Move _PyEval_EvalFrameDefault() to internal C API ↵Victor Stinner2022-04-062-0/+12
| | | | | | | | | | | (GH-32052)" (GH-32343) * Revert "bpo-46850: Move _PyInterpreterState_SetEvalFrameFunc() to internal C API (GH-32054)" This reverts commit f877b40e3f7e0d97878884d80fbec879a85ab7e8. * Revert "bpo-46850: Move _PyEval_EvalFrameDefault() to internal C API (GH-32052)" This reverts commit b9a5522dd952125a99ff554f01f311cae25f5a91.
* bpo-46850: Move _PyInterpreterState_SetEvalFrameFunc() to internal C API ↵Victor Stinner2022-04-011-10/+0
| | | | | | | | | | | (GH-32054) Move the private _PyFrameEvalFunction type, and private _PyInterpreterState_GetEvalFrameFunc() and _PyInterpreterState_SetEvalFrameFunc() functions to the internal C API. The _PyFrameEvalFunction callback function type now uses the _PyInterpreterFrame type which is part of the internal C API. Update the _PyFrameEvalFunction documentation.
* bpo-46850: Move _PyEval_EvalFrameDefault() to internal C API (GH-32052)Victor Stinner2022-04-011-2/+0
| | | | | Move the private undocumented _PyEval_EvalFrameDefault() function to the internal C API. The function now uses the _PyInterpreterFrame type which is part of the internal C API.
* bpo-40421: Add missing getters for frame object attributes to C-API. (GH-32114)Mark Shannon2022-03-311-0/+5
|
* bpo-47164: Add _PyCFunctionObject_CAST() macr (GH-32190)Victor Stinner2022-03-311-6/+11
| | | | | | | | Add _PyCFunctionObject_CAST() and _PyCMethodObject_CAST() macros to make macros casting their argument easier to read, but also to check the type of their input in debug mode: assert(PyCFunction_Check(func) and assert(PyCMethod_Check(func). Reformat also PyCFunction_XXX() macros for readability.
* bpo-47164: Add _PyASCIIObject_CAST() macro (GH-32191)Victor Stinner2022-03-311-33/+34
| | | | | | | | | | | | Add macros to cast objects to PyASCIIObject*, PyCompactUnicodeObject* and PyUnicodeObject*: _PyASCIIObject_CAST(), _PyCompactUnicodeObject_CAST() and _PyUnicodeObject_CAST(). Using these new macros make the code more readable and check their argument with: assert(PyUnicode_Check(op)). Remove redundant assert(PyUnicode_Check(op)) in macros using directly or indirectly these new CAST macros. Replacing existing casts with these macros.
* bpo-42197: Don't create `f_locals` dictionary unless we actually need it. ↵Mark Shannon2022-03-251-0/+1
| | | | | | | | | | | (GH-32055) * `PyFrame_FastToLocalsWithError` and `PyFrame_LocalsToFast` are no longer called during profile and tracing. (Contributed by Fabio Zadrozny) * Make accesses to a frame's `f_locals` safe from C code, not relying on calls to `PyFrame_FastToLocals` or `PyFrame_LocalsToFast`. * Document new `PyFrame_GetLocals` C-API function.
* bpo-47045: Remove `f_state` field (GH-31963)Mark Shannon2022-03-222-1/+2
| | | | | * Remove the f_state field from _PyInterpreterFrame * Make ownership of the frame explicit, replacing the is_generator field with an owner field.