summaryrefslogtreecommitdiffstats
path: root/Objects
Commit message (Collapse)AuthorAgeFilesLines
* GH-100964: Break cycles involving exception state when returning from ↵Mark Shannon2023-08-021-5/+4
| | | | generator (GH-107563)
* gh-106092: Fix use-after-free crash in frame_dealloc (#106875)Anders Kaseorg2023-08-011-6/+7
| | | | | | | | | It was possible for the trashcan to delay the deallocation of a PyFrameObject until after its corresponding _PyInterpreterFrame has already been freed. So frame_dealloc needs to avoid dereferencing the f_frame pointer unless it first checks that the pointer still points to the interpreter frame within the frame object. Signed-off-by: Anders Kaseorg <andersk@mit.edu>
* gh-102509: Start initializing `ob_digit` of `_PyLongValue` (GH-102510)Illia Volochii2023-07-281-0/+3
|
* gh-101524: Only Use Public C-API in the _xxsubinterpreters Module (gh-107359)Eric Snow2023-07-272-13/+13
| | | The _xxsubinterpreters module should not rely on internal API. Some of the functions it uses were recently moved there however. Here we move them back (and expose them properly).
* gh-106931: Intern Statically Allocated Strings Globally (gh-107272)Eric Snow2023-07-271-3/+69
| | | | | We tried this before with a dict and for all interned strings. That ran into problems due to interpreter isolation. However, exclusively using a per-interpreter cache caused some inconsistency that can eliminate the benefit of interning. Here we circle back to using a global cache, but only for statically allocated strings. We also use a more-basic _Py_hashtable_t for that global cache instead of a dict. Ideally we would only have the global cache, but the optional isolation of each interpreter's allocator means that a non-static string object must not outlive its interpreter. Thus we would have to store a copy of each such interned string in the global cache, tied to the main interpreter.
* GH-106895: Raise a `ValueError` when attempting to disable events that ↵Mark Shannon2023-07-271-0/+2
| | | | cannot be disabled. (GH-107337)
* gh-106869: Use new PyMemberDef constant names (#106871)Victor Stinner2023-07-2519-137/+139
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Remove '#include "structmember.h"'. * If needed, add <stddef.h> to get offsetof() function. * Update Parser/asdl_c.py to regenerate Python/Python-ast.c. * Replace: * T_SHORT => Py_T_SHORT * T_INT => Py_T_INT * T_LONG => Py_T_LONG * T_FLOAT => Py_T_FLOAT * T_DOUBLE => Py_T_DOUBLE * T_STRING => Py_T_STRING * T_OBJECT => _Py_T_OBJECT * T_CHAR => Py_T_CHAR * T_BYTE => Py_T_BYTE * T_UBYTE => Py_T_UBYTE * T_USHORT => Py_T_USHORT * T_UINT => Py_T_UINT * T_ULONG => Py_T_ULONG * T_STRING_INPLACE => Py_T_STRING_INPLACE * T_BOOL => Py_T_BOOL * T_OBJECT_EX => Py_T_OBJECT_EX * T_LONGLONG => Py_T_LONGLONG * T_ULONGLONG => Py_T_ULONGLONG * T_PYSSIZET => Py_T_PYSSIZET * T_NONE => _Py_T_NONE * READONLY => Py_READONLY * PY_AUDIT_READ => Py_AUDIT_READ * READ_RESTRICTED => Py_AUDIT_READ * PY_WRITE_RESTRICTED => _Py_WRITE_RESTRICTED * RESTRICTED => (READ_RESTRICTED | _Py_WRITE_RESTRICTED)
* gh-102304: Rename _Py_IncRefTotal_DO_NOT_USE_THIS() (#107193)Victor Stinner2023-07-241-2/+2
| | | | | * Rename _Py_IncRefTotal_DO_NOT_USE_THIS() to _Py_INCREF_IncRefTotal() * Rename _Py_DecRefTotal_DO_NOT_USE_THIS() to _Py_DECREF_DecRefTotal() * Remove temporary _Py_INC_REFTOTAL() and _Py_DEC_REFTOTAL() macros
* gh-106320: Remove private _PyDict C API (#107145)Victor Stinner2023-07-241-0/+1
| | | | | | | | | | | | | Move private _PyDict functions to the internal C API (pycore_dict.h): * _PyDict_Contains_KnownHash() * _PyDict_DebugMallocStats() * _PyDict_DelItemIf() * _PyDict_GetItemWithError() * _PyDict_HasOnlyStringKeys() * _PyDict_MaybeUntrack() * _PyDict_MergeEx() No longer export these functions.
* gh-106320: Remove private _PyObject C API (#107147)Victor Stinner2023-07-235-4/+5
| | | | | | | | | | | | | | | | Move private debug _PyObject functions to the internal C API (pycore_object.h): * _PyDebugAllocatorStats() * _PyObject_CheckConsistency() * _PyObject_DebugTypeStats() * _PyObject_IsFreed() No longer export most of these functions, except of _PyObject_IsFreed(). Move test functions using _PyObject_IsFreed() from _testcapi to _testinternalcapi. check_pyobject_is_freed() test no longer catch _testcapi.error: the tested function cannot raise _testcapi.error.
* gh-106320: Remove _PyFunction_Vectorcall() API (#107071)Victor Stinner2023-07-221-0/+1
| | | | Move _PyFunction_Vectorcall() API to the internal C API. No longer export the function.
* gh-106320: Move _PyMethodWrapper_Type to internal C API (#107064)Victor Stinner2023-07-222-1/+2
|
* gh-106320: Remove private _PyInterpreterID C API (#107053)Victor Stinner2023-07-222-3/+3
| | | | | | | Move the private _PyInterpreterID C API to the internal C API: add a new pycore_interp_id.h header file. Remove Include/interpreteridobject.h and Include/cpython/interpreteridobject.h header files.
* gh-106320: Remove _Py_SwappedOp from the C API (#107036)Victor Stinner2023-07-221-1/+1
| | | Move _Py_SwappedOp to the internal C API (pycore_object.h).
* gh-106320: Move private _PySet API to the internal API (#107041)Victor Stinner2023-07-223-0/+3
| | | | | | | | * Add pycore_setobject.h header file. * Move the following API to the internal C API: * _PySet_Dummy * _PySet_NextEntry() * _PySet_Update()
* gh-96663: Add a better error message for __dict__-less classes setattr (#103232)James Hilton-Balfe2023-07-221-3/+13
|
* gh-106004: Add PyDict_GetItemRef() function (#106005)Victor Stinner2023-07-211-16/+61
| | | | | * Add PyDict_GetItemRef() and PyDict_GetItemStringRef() functions. Add these functions to the stable ABI version 3.13. * Add unit tests on the PyDict C API in test_capi.
* gh-105699: Fix a Crasher Related to a Deprecated Global Variable (gh-106923)Eric Snow2023-07-211-4/+7
| | | There was a slight race in _Py_ClearFileSystemEncoding() (when called from _Py_SetFileSystemEncoding()), between freeing the value and setting the variable to NULL, which occasionally caused crashes when multiple isolated interpreters were used. (Notably, I saw at least 10 different, seemingly unrelated spooky-action-at-a-distance, ways this crashed. Yay, free threading!) We avoid the problem by only setting the global variables with the main interpreter (i.e. runtime init).
* gh-105699: Fix an Interned Strings Crasher (gh-106930)Eric Snow2023-07-211-1/+12
| | | | | | | A static (process-global) str object must only have its "interned" state cleared when no longer interned in any interpreters. They are the only ones that can be shared by interpreters so we don't have to worry about any other str objects. We trigger clearing the state with the main interpreter, since no other interpreters may exist at that point and _PyUnicode_ClearInterned() is only called during interpreter finalization. We do not address here the fact that a string will only be interned in the first interpreter that interns it. In any subsequent interpreters str.state.interned is already set so _PyUnicode_InternInPlace() will skip it. That needs to be addressed separately from fixing the crasher.
* gh-106719: Fix __annotations__ getter and setter in the type and module ↵Serhiy Storchaka2023-07-182-47/+33
| | | | | types (GH-106720) No longer suppress arbitrary errors. Simplify the code.
* gh-105235: Prevent reading outside buffer during mmap.find() (#105252)Dennis Sweeney2023-07-131-2/+19
| | | | | | | * Add a special case for s[-m:] == p in _PyBytes_Find * Add tests for _PyBytes_Find * Make sure that start <= end in mmap.find
* gh-106521: Remove _PyObject_LookupAttr() function (GH-106642)Serhiy Storchaka2023-07-1214-45/+45
|
* gh-106307: C API: Add PyMapping_GetOptionalItem() function (GH-106308)Serhiy Storchaka2023-07-111-0/+40
| | | | Also add PyMapping_GetOptionalItemString() function.
* gh-106521: Add PyObject_GetOptionalAttr() function (GH-106522)Serhiy Storchaka2023-07-111-10/+24
| | | | | | It is a new name of former _PyObject_LookupAttr(). Add also PyObject_GetOptionalAttrString().
* gh-106403: Restore weakref support for TypeVar and friends (#106418)Jelle Zijlstra2023-07-111-5/+7
|
* gh-106572: Convert PyObject_DelAttr() to a function (#106611)Victor Stinner2023-07-111-0/+12
| | | | | | | | * Convert PyObject_DelAttr() and PyObject_DelAttrString() macros to functions. * Add PyObject_DelAttr() and PyObject_DelAttrString() functions to the stable ABI. * Replace PyObject_SetAttr(obj, name, NULL) with PyObject_DelAttr(obj, name).
* gh-105227: Add PyType_GetDict() (GH-105747)Eric Snow2023-07-101-0/+7
| | | | | This compensates for static builtin types having `tp_dict` set to `NULL`. Co-authored-by: Petr Viktorin <encukou@gmail.com>
* gh-106487: Allow the 'count' argument of `str.replace` to be a keyword (#106488)Hugo van Kemenade2023-07-102-10/+38
|
* gh-105927: PyWeakref_GetRef() returns 1 on success (#106561)Victor Stinner2023-07-091-1/+1
| | | | | | PyWeakref_GetRef() now returns 1 on success, and return 0 if the reference is dead. Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* gh-106303: Use _PyObject_LookupAttr() instead of PyObject_GetAttr() (GH-106304)Serhiy Storchaka2023-07-091-10/+5
| | | | It simplifies and speed up the code.
* gh-105340: include hidden fast-locals in locals() (#105715)Carl Meyer2023-07-052-8/+64
| | | * gh-105340: include hidden fast-locals in locals()
* gh-96844: Improve error message of list.remove (gh-106455)Dong-hee Na2023-07-051-1/+1
|
* gh-106320: Remove private _PyErr C API functions (#106356)Victor Stinner2023-07-033-4/+6
| | | | Remove private _PyErr C API functions: move them to the internal C API (pycore_pyerrors.h).
* gh-106320: Create pycore_modsupport.h header file (#106355)Victor Stinner2023-07-0311-4/+15
| | | | | | | | | | Remove the following functions from the C API, move them to the internal C API: add a new pycore_modsupport.h internal header file: * PyModule_CreateInitialized() * _PyArg_NoKwnames() * _Py_VaBuildStack() No longer export these functions.
* gh-106320: Add pycore_complexobject.h header file (#106339)Victor Stinner2023-07-022-0/+2
| | | | | | Add internal pycore_complexobject.h header file. Move _Py_c_xxx() functions and _PyComplex_FormatAdvancedWriter() function to this new header file.
* gh-106320: Use _PyInterpreterState_GET() (#106336)Victor Stinner2023-07-021-11/+11
| | | | Replace PyInterpreterState_Get() with inlined _PyInterpreterState_GET().
* gh-104922: remove PY_SSIZE_T_CLEAN (#106315)Inada Naoki2023-07-027-8/+0
|
* gh-106320: Remove _PyInterpreterState_Get() alias (#106321)Victor Stinner2023-07-012-3/+3
| | | | Replace calls to the (removed) slow _PyInterpreterState_Get() with fast inlined _PyInterpreterState_GET() function.
* Fix duplicate word typos in comments (#106225)Md Sadman Chowdhury2023-07-011-1/+1
|
* gh-105486: Change the `repr` of `ParamSpec` list of args in `GenericAlias` ↵Nikita Sobolev2023-07-011-1/+37
| | | | (#105488)
* Cleanup clear_static_tp_subclasses() (#106276)Victor Stinner2023-06-301-0/+2
| | | | Only iterate on the dictionary if Python is built with assertions: subclass is only needed when Python is built with assertions.
* gh-106023: Remove _PyObject_FastCall() function (#106265)Victor Stinner2023-06-301-8/+0
|
* Remove private _PyCodec_Lookup() function (#106269)Victor Stinner2023-06-301-1/+2
| | | | | | | | | | | | | | | Remove the following private functions of the C API: * _PyCodecInfo_GetIncrementalDecoder() * _PyCodecInfo_GetIncrementalEncoder() * _PyCodec_DecodeText() * _PyCodec_EncodeText() * _PyCodec_Forget() * _PyCodec_Lookup() * _PyCodec_LookupTextEncoding() Move these functions to a new pycore_codecs.h internal header file. These functions are no longer exported.
* gh-106023: Rename _PyObject_FastCallDictTstate() (#106264)Victor Stinner2023-06-301-8/+9
| | | | Rename _PyObject_FastCallDictTstate() to _PyObject_VectorcallDictTstate().
* fix typos (#106247)Inada Naoki2023-06-306-10/+10
| | | Most typos are in comments, but two typos are in docstring.
* gh-106023: Update code using _PyObject_FastCall() (#106257)Victor Stinner2023-06-301-1/+2
| | | Replace _PyObject_FastCall() calls with PyObject_Vectorcall().
* Fix possible refleak in CodeType.replace() (GH-106243)Serhiy Storchaka2023-06-291-0/+1
| | | A reference to c_code was leaked if PySys_Audit() failed.
* gh-106033: Get rid of PyDict_GetItem in _PyFunction_FromConstructor (GH-106044)Serhiy Storchaka2023-06-291-4/+6
|
* gh-106168: PyTuple_SET_ITEM() now checks the index (#106164)Victor Stinner2023-06-282-7/+21
| | | | | | | | | | | | | PyTuple_SET_ITEM() and PyList_SET_ITEM() now check the index argument with an assertion if Python is built in debug mode or is built with assertions. * list_extend() and _PyList_AppendTakeRef() now set the list size before calling PyList_SET_ITEM(). * PyStructSequence_GetItem() and PyStructSequence_SetItem() now check the index argument: must be lesser than REAL_SIZE(op). * PyStructSequence_GET_ITEM() and PyStructSequence_SET_ITEM() are now aliases to PyStructSequence_GetItem() and PyStructSequence_SetItem().
* gh-106084: Remove _PyObject_CallMethod() function (#106159)Victor Stinner2023-06-272-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove the following private functions from the public C API: * _Py_CheckFunctionResult() * _PyObject_CallMethod() * _PyObject_CallMethodId() * _PyObject_CallMethodIdNoArgs() * _PyObject_CallMethodIdObjArgs() * _PyObject_CallMethodIdOneArg() * _PyObject_MakeTpCall() * _PyObject_VectorcallMethodId() * _PyStack_AsDict() Move these functions to the internal C API (pycore_call.h). No longer export the following functions: * _PyObject_Call() * _PyObject_CallMethod() * _PyObject_CallMethodId() * _PyObject_CallMethodIdObjArgs() * _PyObject_Call_Prepend() * _PyObject_FastCallDictTstate() * _PyStack_AsDict() The following functions are still exported for stdlib shared extensions: * _Py_CheckFunctionResult() * _PyObject_MakeTpCall() Mark the following internal functions as extern: * _PyStack_UnpackDict() * _PyStack_UnpackDict_Free() * _PyStack_UnpackDict_FreeNoDecRef()