summaryrefslogtreecommitdiffstats
path: root/Objects/abstract.c
Commit message (Collapse)AuthorAgeFilesLines
* bpo-46140: take more Py_buffer arguments as const * (GH-30217)David Hewitt2021-12-221-3/+4
|
* bpo-45760: Remove PyNumber_InMatrixMultiply (GH-29751)Dong-hee Na2021-11-261-29/+4
|
* bpo-45636: Simplify BINARY_OP (GH-29565)Brandt Bucher2021-11-161-0/+12
|
* bpo-30570: Use Py_EnterRecursiveCall() in issubclass() (GH-29048)Dennis Sweeney2021-10-221-6/+14
| | | | | * Use Py_EnterRecursiveCall() in issubclass() Reviewed-by: Gregory P. Smith <greg@krypto.org> [Google]
* bpo-35134: Move classobject.h to Include/cpython/ (GH-28968)Victor Stinner2021-10-151-1/+0
| | | | | | | | | Move classobject.h, context.h, genobject.h and longintrepr.h header files from Include/ to Include/cpython/. Remove redundant "#ifndef Py_LIMITED_API" in context.h. Remove explicit #include "longintrepr.h" in C files. It's not needed, Python.h already includes it.
* bpo-45439: Move _PyObject_CallNoArgs() to pycore_call.h (GH-28895)Victor Stinner2021-10-121-0/+1
| | | | | | | * Move _PyObject_CallNoArgs() to pycore_call.h (internal C API). * _ssl, _sqlite and _testcapi extensions now call the public PyObject_CallNoArgs() function, rather than _PyObject_CallNoArgs(). * _lsprof extension is now built with Py_BUILD_CORE_MODULE macro defined to get access to internal _PyObject_CallNoArgs().
* bpo-45439: Rename _PyObject_CallNoArg() to _PyObject_CallNoArgs() (GH-28891)Victor Stinner2021-10-111-2/+2
| | | | | Fix typo in the private _PyObject_CallNoArg() function name: rename it to _PyObject_CallNoArgs() to be consistent with the public function PyObject_CallNoArgs().
* bpo-44640: Improve punctuation consistency in isinstance/issubclass error ↵wyz23x22021-09-171-2/+2
| | | | | messages (GH-27144) Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* bpo-45123: PyAiter_Check and PyObject_GetAiter fix & rename. (GH-28194)Yury Selivanov2021-09-071-7/+5
| | | | | | | | Fix PyAiter_Check to only check for the `__anext__` presense (not for `__aiter__`). Rename `PyAiter_Check()` to `PyAIter_Check()`, `PyObject_GetAiter()` -> `PyObject_GetAIter()`. Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
* bpo-41103: Resurrect the old buffer protocol. (GH-27437)Inada Naoki2021-07-291-0/+79
| | | | | Revert "bpo-41103: Remove old buffer protocol support (#21117)" This reverts commit 6f8a6ee59cb7f99f68df8ee9c3e8c8cf19af3eed.
* bpo-42747: Remove Py_TPFLAGS_HAVE_AM_SEND and make ↵Petr Viktorin2021-07-231-3/+1
| | | | | | | | | | | | Py_TPFLAGS_HAVE_VERSION_TAG no-op (GH-27260) * Remove code that checks Py_TPFLAGS_HAVE_VERSION_TAG The field is always present in the type struct, as explained in the added comment. * Remove Py_TPFLAGS_HAVE_AM_SEND The flag is not needed, and since it was added in 3.10 it can be removed now.
* bpo-44654: Refactor and clean up the union type implementation (GH-27196)Serhiy Storchaka2021-07-171-4/+2
|
* bpo-31861: Add aiter and anext to builtins (#23847)Joshua Bronson2021-03-231-0/+31
| | | | | | Co-authored-by: jab <jab@users.noreply.github.com> Co-authored-by: Daniel Pope <mauve@mauveweb.co.uk> Co-authored-by: Justin Wang <justin39@gmail.com>
* bpo-38302: __pow__/__rpow__ now called when __ipow__ returns NotImplemented ↵Alex2021-02-261-21/+27
| | | | (#16459)
* bpo-40170: Always define PyIter_Check() as a function (GH-24548)Erlend Egeberg Aasland2021-02-161-5/+5
|
* bpo-42979: Use _Py_CheckSlotResult() to check slots result (GH-24356)Victor Stinner2021-01-291-187/+282
| | | | | | | | | | | | | | | When Python is built in debug mode (with C assertions), calling a type slot like sq_length (__len__() in Python) now fails with a fatal error if the slot succeeded with an exception set, or failed with no exception set. The error message contains the slot, the type name, and the current exception (if an exception is set). * Check the result of all slots using _Py_CheckSlotResult(). * No longer pass op_name to ternary_op() in release mode. * Replace operator with dunder Python method name in error messages. For example, replace "*" with "__mul__". * Fix compiler_exit_scope() when an exception is set. * Fix bytearray.extend() when an exception is set: don't call bytearray_setslice() with an exception set.
* bpo-42979: Enhance abstract.c assertions checking slot result (GH-24352)Victor Stinner2021-01-271-8/+9
| | | | | | | | * bpo-42979: Enhance abstract.c assertions checking slot result Add _Py_CheckSlotResult() function which fails with a fatal error if a slot function succeeded with an exception set or failed with no exception set: write the slot name, the type name and the current exception (if an exception is set).
* bpo-42085: Introduce dedicated entry in PyAsyncMethods for sending values ↵Vladimir Matveev2020-11-101-0/+26
| | | | (#22780)
* Delete PyGen_Send (#22663)Vladimir Matveev2020-10-121-25/+0
|
* bpo-41756: Add PyIter_Send function (#22443)Vladimir Matveev2020-10-101-0/+24
|
* bpo-41974: Remove complex.__float__, complex.__floordiv__, etc (GH-22593)Serhiy Storchaka2020-10-091-5/+5
| | | | | | Remove complex special methods __int__, __float__, __floordiv__, __mod__, __divmod__, __rfloordiv__, __rmod__ and __rdivmod__ which always raised a TypeError.
* bpo-41909: Enable previously disabled recursion checks. (GH-22536)Serhiy Storchaka2020-10-041-2/+0
| | | | | | | | | | | Enable recursion checks which were disabled when get __bases__ of non-type objects in issubclass() and isinstance() and when intern strings. It fixes a stack overflow when getting __bases__ leads to infinite recursion. Originally recursion checks was disabled for PyDict_GetItem() which silences all errors including the one raised in case of detected recursion and can return incorrect result. But now the code uses PyDict_GetItemWithError() and PyDict_SetDefault() instead.
* bpo-41428: Implementation for PEP 604 (GH-21515)Maggie Moss2020-09-091-6/+9
| | | | | See https://www.python.org/dev/peps/pep-0604/ for more information. Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
* bpo-39573: Use the Py_TYPE() macro (GH-21433)Victor Stinner2020-07-101-2/+2
| | | Replace obj->ob_type with Py_TYPE(obj).
* bpo-41123: Remove PyLong_FromUnicode() (GH-21204)Inada Naoki2020-06-291-1/+1
|
* bpo-41103: Remove old buffer protocol support (#21117)Inada Naoki2020-06-251-79/+0
| | | They are deprecated since Python 3.0.
* bpo-36710: Pass tstate explicitly in abstract.c (GH-21075)Victor Stinner2020-06-231-40/+61
| | | | In functions calling more than one PyErr function, get tstate and then pass it explicitly.
* bpo-40824: Do not mask errors in __iter__ in "in" and the operator module. ↵Serhiy Storchaka2020-06-221-1/+3
| | | | | | | (GH-20537) Unexpected errors in calling the __iter__ method are no longer masked by TypeError in the "in" operator and functions operator.contains(), operator.indexOf() and operator.countOf().
* bpo-40792: Make the result of PyNumber_Index() always having exact type int. ↵Serhiy Storchaka2020-05-281-12/+20
| | | | | | | | | | | | (GH-20443) Previously, the result could have been an instance of a subclass of int. Also revert bpo-26202 and make attributes start, stop and step of the range object having exact type int. Add private function _PyNumber_Index() which preserves the old behavior of PyNumber_Index() for performance to use it in the conversion functions like PyLong_AsLong().
* bpo-37999: No longer use __int__ in implicit integer conversions. (GH-15636)Serhiy Storchaka2020-05-261-7/+24
| | | | Only __index__ should be used to make integer conversions lossless.
* bpo-38787: Add PyCFunction_CheckExact() macro for exact type checks (GH-20024)scoder2020-05-121-1/+1
| | | | | … now that we allow subtypes of PyCFunction. Also add PyCMethod_CheckExact() and PyCMethod_Check() for checks against the PyCMethod subtype.
* bpo-39465: Don't access directly _Py_Identifier members (GH-20043)Victor Stinner2020-05-111-1/+1
| | | | | * Replace id->object with _PyUnicode_FromId(&id) * Use _Py_static_string_init(str) macro to initialize statically name_op in typeobject.c.
* bpo-40268: Remove unused structmember.h includes (GH-19530)Victor Stinner2020-04-151-4/+4
| | | | | | If only offsetof() is needed: include stddef.h instead. When structmember.h is used, add a comment explaining that PyMemberDef is used.
* bpo-40268: Remove a few pycore_pystate.h includes (GH-19510)Victor Stinner2020-04-141-1/+1
|
* bpo-40170: Remove PyIndex_Check() macro (GH-19428)Victor Stinner2020-04-081-2/+0
| | | | | Always declare PyIndex_Check() as an opaque function to hide implementation details: remove PyIndex_Check() macro. The macro accessed directly the PyTypeObject.tp_as_number member.
* bpo-40170: Add _PyIndex_Check() internal function (GH-19426)Victor Stinner2020-04-081-9/+11
| | | | | | | | | Add _PyIndex_Check() function to the internal C API: fast inlined verson of PyIndex_Check(). Add Include/internal/pycore_abstract.h header file. Replace PyIndex_Check() with _PyIndex_Check() in C files of Objects and Python subdirectories.
* bpo-40170: Convert PyObject_CheckBuffer() macro to a function (GH-19376)Victor Stinner2020-04-071-0/+10
| | | | | Convert PyObject_CheckBuffer() macro to a function to hide implementation details: the macro accessed directly the PyTypeObject.tp_as_buffer member.
* bpo-39481: Implementation for PEP 585 (#18239)Guido van Rossum2020-04-071-0/+6
| | | | | | | | | | | | This implements things like `list[int]`, which returns an object of type `types.GenericAlias`. This object mostly acts as a proxy for `list`, but has attributes `__origin__` and `__args__` that allow recovering the parts (with values `list` and `(int,)`. There is also an approximate notion of type variables; e.g. `list[T]` has a `__parameters__` attribute equal to `(T,)`. Type variables are objects of type `typing.TypeVar`.
* bpo-39947: Move Py_EnterRecursiveCall() to internal C API (GH-18972)Victor Stinner2020-03-131-0/+1
| | | | | | Move the static inline function flavor of Py_EnterRecursiveCall() and Py_LeaveRecursiveCall() to the internal C API: they access PyThreadState attributes. The limited C API provides regular functions which hide implementation details.
* bpo-38643: Raise SystemError instead of crashing when PyNumber_ToBase is ↵Serhiy Storchaka2020-03-091-9/+6
| | | | called with invalid base. (GH-18863)
* bpo-39573: Use Py_IS_TYPE() macro to check for types (GH-18809)Andy Lester2020-03-061-3/+2
| | | Co-authored-by: Victor Stinner <vstinner@python.org>
* bpo-39573: Finish converting to new Py_IS_TYPE() macro (GH-18601)Andy Lester2020-03-041-1/+1
|
* bpo-39382: Avoid dangling object use in abstract_issubclass() (GH-18530)Yonatan Goldschmidt2020-02-221-3/+9
| | | | | Hold reference of __bases__ tuple until tuple item is done with, because by dropping the reference the item may be destroyed.
* bpo-39245: Switch to public API for Vectorcall (GH-18460)Petr Viktorin2020-02-111-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The bulk of this patch was generated automatically with: for name in \ PyObject_Vectorcall \ Py_TPFLAGS_HAVE_VECTORCALL \ PyObject_VectorcallMethod \ PyVectorcall_Function \ PyObject_CallOneArg \ PyObject_CallMethodNoArgs \ PyObject_CallMethodOneArg \ ; do echo $name git grep -lwz _$name | xargs -0 sed -i "s/\b_$name\b/$name/g" done old=_PyObject_FastCallDict new=PyObject_VectorcallDict git grep -lwz $old | xargs -0 sed -i "s/\b$old\b/$new/g" and then cleaned up: - Revert changes to in docs & news - Revert changes to backcompat defines in headers - Nudge misaligned comments
* bpo-39573: Use Py_TYPE() in abstract.c (GH-18390)Victor Stinner2020-02-071-94/+94
| | | Replace direct access to PyObject.ob_type with Py_TYPE().
* Restore PyObject_IsInstance() comment (GH-18345)Victor Stinner2020-02-041-17/+23
| | | | | | | | | | | | Restore PyObject_IsInstance() comment explaining why only tuples of types are accepted, but not general sequence. Comment written by Guido van Rossum in commit 03290ecbf1661c0192e6abdbe00ae163af461d77 which implements isinstance(x, (A, B, ...)). The comment was lost in a PyObject_IsInstance() optimization: commit ec569b794737be248671d0dfac11b664fc930eef. Cleanup also the code. recursive_isinstance() is no longer recursive, so rename it to object_isinstance(), whereas object_isinstance() is recursive and so rename it to object_recursive_isinstance().
* bpo-38644: Pass tstate to Py_EnterRecursiveCall() (GH-16997)Victor Stinner2019-11-041-31/+49
| | | | | | | | | | | | | * Add _Py_EnterRecursiveCall() and _Py_LeaveRecursiveCall() which require a tstate argument. * Pass tstate to _Py_MakeRecCheck() and _Py_CheckRecursiveCall(). * Convert Py_EnterRecursiveCall() and Py_LeaveRecursiveCall() macros to static inline functions. _PyThreadState_GET() is the most efficient way to get the tstate, and so using it with _Py_EnterRecursiveCall() and _Py_LeaveRecursiveCall() should be a little bit more efficient than using Py_EnterRecursiveCall() and Py_LeaveRecursiveCall() which use the "slower" PyThreadState_GET().
* abstract.c should not be executable. (GH-15348)Benjamin Peterson2019-08-211-0/+0
|
* bpo-15913: Implement PyBuffer_SizeFromFormat() (GH-13873)Joannah Nanjekye2019-08-201-0/+42
| | | | Implement PyBuffer_SizeFromFormat() function (previously documented but not implemented): call struct.calcsize().
* bpo-37648: Fixed minor inconsistency in some __contains__. (GH-14904)Serhiy Storchaka2019-08-041-1/+1
| | | | | The collection's item is now always at the left and the needle is on the right of ==.