summaryrefslogtreecommitdiffstats
path: root/Objects
Commit message (Collapse)AuthorAgeFilesLines
* bpo-45392: Update the docstring of the 'type' built-in (GH-29439) (GH-29452)Miss Islington (bot)2021-11-061-3/+1
| | | | | (cherry picked from commit 91275207296c39e495fe118019a757c4ddefede8) Co-authored-by: Mark Dickinson <mdickinson@enthought.com>
* bpo-30570: Use Py_EnterRecursiveCall() in issubclass() (GH-29048)Miss Islington (bot)2021-10-221-6/+14
| | | | | | | | * Use Py_EnterRecursiveCall() in issubclass() Reviewed-by: Gregory P. Smith <greg@krypto.org> [Google] (cherry picked from commit 423fa1c1817abfa8c3d1bc308ddbbd8f28b69d68) Co-authored-by: Dennis Sweeney <36520290+sweeneyde@users.noreply.github.com>
* bpo-45521: Fix a bug in the obmalloc radix tree code. (GH-29051) (GH-29122)Miss Islington (bot)2021-10-211-1/+1
| | | | | | MAP_BOT_LENGTH was incorrectly used to compute MAP_TOP_MASK instead of MAP_TOP_LENGTH. On 64-bit machines, the error causes the tree to hold 46-bits of virtual addresses, rather than the intended 48-bits. (cherry picked from commit 311910b31a4bd94dc79298388b7cb65ca5546438)
* [3.10] bpo-45467: Fix IncrementalDecoder and StreamReader in the ↵Serhiy Storchaka2021-10-141-20/+44
| | | | | | | | | | | "raw-unicode-escape" codec (GH-28944) (GH-28952) They support now splitting escape sequences between input chunks. Add the third parameter "final" in codecs.raw_unicode_escape_decode(). It is True by default to match the former behavior. (cherry picked from commit 39aa98346d5dd8ac591a7cafb467af21c53f1e5d) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* [3.10] bpo-45461: Fix IncrementalDecoder and StreamReader in the ↵Miss Islington (bot)2021-10-141-12/+37
| | | | | | | | | | | | "unicode-escape" codec (GH-28939) (GH-28943) They support now splitting escape sequences between input chunks. Add the third parameter "final" in codecs.unicode_escape_decode(). It is True by default to match the former behavior. (cherry picked from commit c96d1546b11b4c282a7e21737cb1f5d16349656d) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* [3.10] Fix typos in the Objects directory (GH-28766) (GH-28797)Christian Clauss2021-10-076-7/+7
| | | | | (cherry picked from commit 5f401f10400123afa9171548c432ea3fc37c0736) Automerge-Triggered-By: GH:JulienPalard
* bpo-45385: Fix reference leak from descr_check (GH-28719) (GH-28779)Miss Islington (bot)2021-10-071-39/+37
|
* [3.10] bpo-45355: More use of sizeof(_Py_CODEUNIT) (GH-28720). (GH-28721)Serhiy Storchaka2021-10-041-2/+2
| | | | (cherry picked from commit 252b7bcb236dc261f3af1275bc90f9a303d9648f)
* [3.10] bpo-45355: Use sizeof(_Py_CODEUNIT) instead of literal 2 for the size ↵Serhiy Storchaka2021-10-041-2/+2
| | | | | | of the code unit (GH-28711). (GH-28718) (cherry picked from commit 60b9e040c9cf40e69f42c0008e564458aa0379e8)
* [3.10] Remove trailing spaces (GH-28709)Serhiy Storchaka2021-10-033-3/+3
|
* Fix spelling error in comment (GH-28696) (GH-28699)Miss Islington (bot)2021-10-021-1/+1
|
* [3.10] [codemod] Fix non-matching bracket pairs (GH-28473) (GH-28511)Łukasz Langa2021-09-211-1/+1
| | | | | | | | Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Łukasz Langa <lukasz@langa.pl> (cherry picked from commit 8f943ca25732d548cf9f0b0393ba8d582fb93e29) Co-authored-by: Mohamad Mansour <66031317+mohamadmansourX@users.noreply.github.com>
* bpo-44640: Improve punctuation consistency in isinstance/issubclass error ↵Miss Islington (bot)2021-09-191-2/+2
| | | | | | | | | | messages (GH-27144) (GH-28436) Co-authored-by: Łukasz Langa <lukasz@langa.pl> (cherry picked from commit f4813388b4506b2fafb0089848c5b11cd503758c) Co-authored-by: wyz23x2 <52805709+wyz23x2@users.noreply.github.com> Co-authored-by: wyz23x2 <52805709+wyz23x2@users.noreply.github.com>
* bpo-45198: __set_name__ documentation not clear about its usage with ↵Miss Islington (bot)2021-09-181-1/+2
| | | | | | | non-descriptor classes (GH-28439) (cherry picked from commit 94b462686b7dfabbd69cc9401037d736d71c4dc2) Co-authored-by: Raymond Hettinger <rhettinger@users.noreply.github.com>
* bpo-45167: Fix deepcopying of GenericAlias (GH-28324) (GH-28367)Miss Islington (bot)2021-09-151-0/+2
| | | | | (cherry picked from commit 5dce51a8875d9639786741e962b3cb208596b096) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* [3.10] bpo-45083: Include the exception class qualname when formatting an ↵Miss Islington (bot)2021-09-081-0/+8
| | | | | | | | | | | | exception (GH-28119) (GH-28134) Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no> (cherry picked from commit b4b6342848ec0459182a992151099252434cc619) Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com> * Use a private version of _PyType_GetQualName Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* bpo-45123: PyAiter_Check and PyObject_GetAiter fix & rename. (GH-28194) ↵Miss Islington (bot)2021-09-071-7/+5
| | | | | | | (GH-28199) Fix PyAiter_Check to only check for the `__anext__` presense (not for `__aiter__`). Rename `PyAiter_Check()` to `PyAIter_Check()`, `PyObject_GetAiter()` -> `PyObject_GetAIter()`.
* bpo-44963: Implement send() and throw() methods for anext_awaitable objects ↵Miss Islington (bot)2021-09-071-22/+96
| | | | | | | | (GH-27955) Co-authored-by: Yury Selivanov <yury@edgedb.com> (cherry picked from commit 533e725821b15e2df2cd4479a34597c1d8faf616) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
* bpo-45030: Fix integer overflow in __reduce__ of the range iterator (GH-28000)Miss Islington (bot)2021-09-041-16/+18
| | | | | | | It happened with fast range iterator when the calculated stop = start + step * len was out of the C long range. (cherry picked from commit 936f6a16b9ef85bd56b18a247b962801e954c30e) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* bpo-45018: Fix rangeiter_reduce in rangeobject.c (GH-27938)Miss Islington (bot)2021-08-281-1/+1
| | | | | | Co-authored-by: Łukasz Langa <lukasz@langa.pl> (cherry picked from commit 94a3d2a6329ab7941e93ad2f5bcbb8af2b8b80d2) Co-authored-by: chilaxan <chilaxan@gmail.com>
* bpo-44954: Fix wrong result in float.fromhex corner case (GH-27834)Miss Islington (bot)2021-08-201-2/+2
| | | | | (cherry picked from commit 60b93d9e4922eeae25052bc15909d1f4152babde) Co-authored-by: Mark Dickinson <mdickinson@enthought.com>
* bpo-44698: Restore complex pow behaviour for small integral exponents ↵Miss Islington (bot)2021-08-171-21/+7
| | | | | | | (GH-27772) (GH-27796) (cherry picked from commit 4b9a2dcf19e5d13c3bc2afea2de1f65cd994c699) Co-authored-by: Mark Dickinson <mdickinson@enthought.com>
* bpo-33930: Fix segfault with deep recursion when cleaning method objects ↵Miss Islington (bot)2021-08-111-1/+5
| | | | | | | (GH-27678) (GH-27719) (cherry picked from commit bfc2d5a5c4550ab3a2fadeb9459b4bd948ff61a2) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
* bpo-44872: use new trashcan macros in framobject.c (GH-27683) (GH-27690)Irit Katriel2021-08-101-2/+2
|
* bpo-44662: Add ability to annotate types.Union (GH-27214) (GH-27461)Miss Islington (bot)2021-07-301-1/+23
| | | | | | Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com> (cherry picked from commit 8182c8329c709f42218a8a17d81639ece5b7b627) Co-authored-by: Yurii Karabas <1998uriyyo@gmail.com>
* bpo-44707: Fix an undefined behavior of the null pointer arithmetic ↵Miss Islington (bot)2021-07-291-2/+9
| | | | | | | (GH-27292) (GH-27442) (cherry picked from commit e5c8ddb1714fb51ab1defa24352c98e0f01205dc) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* bpo-41103: Resurrect the old buffer protocol. (GH-27437) (GH-27441)Miss Islington (bot)2021-07-291-0/+79
| | | | | | | | Revert "bpo-41103: Remove old buffer protocol support (GH-21117)" This reverts commit 6f8a6ee59cb7f99f68df8ee9c3e8c8cf19af3eed. (cherry picked from commit ce5e1a6809b714eb0383219190a076d9f883e008) Co-authored-by: Inada Naoki <songofacandy@gmail.com>
* bpo-44657: Fix instancemethod_call to use PyInstanceMethod_GET_FUNCTION ↵Miss Islington (bot)2021-07-281-1/+1
| | | | | | | (GH-27202) (cherry picked from commit ddf8ae31a0f371eff2db14c7f7a45976b86d56ea) Co-authored-by: Dong-hee Na <donghee.na@python.org>
* bpo-34013: Move the Python 2 hints from the exception constructor to the ↵Miss Islington (bot)2021-07-271-201/+0
| | | | | | | parser (GH-27392) (cherry picked from commit ecc3c8e4216958d85385bf2467441c975128f26c) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
* bpo-44698: Fix undefined behaviour in complex exponentiation. (GH-27278) ↵Miss Islington (bot)2021-07-261-8/+15
| | | | | | | (#27366) (cherry picked from commit 1d582bbc969e05896addf97844ddf17ce9830e5e) Co-authored-by: T. Wouters <thomas@python.org>
* bpo-44732: Rename types.Union to types.UnionType (GH-27342)Miss Islington (bot)2021-07-261-3/+3
| | | | | | | Co-authored-by: Łukasz Langa <lukasz@langa.pl> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com> (cherry picked from commit 2b8ad9e6c5f0a66e9ca2d15f85336d8a3eefefb0) Co-authored-by: Hasan <hasan.aleeyev@gmail.com>
* bpo-44676: Serialize the union type using only public API (GH-27323) (GH-27340)Miss Islington (bot)2021-07-241-48/+0
| | | | | | | Remove also the _from_args() constructor. (cherry picked from commit 435a0334d341e5f8faed594d9f015746bb7845db) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* bpo-44731: Simplify the union type implementation (GH-27318) (GH-27334)Ken Jin2021-07-241-81/+7
| | | | | Remove direct support of typing types in the C code because they are already supported by defining methods __or__ and __ror__ in the Python code. Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* [3.10] bpo-44676: Add ability to serialize types.Union (GH-27244) (GH-27333)Pablo Galindo Salgado2021-07-241-0/+51
| | | | | (cherry picked from commit fe13f0b0f696464dd6f283576668dbf57cb11399) Co-authored-by: Yurii Karabas <1998uriyyo@gmail.com>
* bpo-44720: Don't crash when calling weakref.proxy(not_an_iterator).__next__ ↵Miss Islington (bot)2021-07-241-0/+6
| | | | | | | (GH-27316) (GH-27324) (cherry picked from commit 5370f0a82aaa4ba617070d5c71d2b18236096ac0) Co-authored-by: Dennis Sweeney <36520290+sweeneyde@users.noreply.github.com>
* bpo-42747: Remove Py_TPFLAGS_HAVE_AM_SEND and make ↵Miss Islington (bot)2021-07-233-30/+6
| | | | | | | | | | | | | | | Py_TPFLAGS_HAVE_VERSION_TAG no-op (GH-27260) (GH-27306) * 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. (cherry picked from commit a4760cc32d9e5dac7be262e9736eb30502cd7be3) Co-authored-by: Petr Viktorin <encukou@gmail.com>
* bpo-44653: Support typing types in parameter substitution in the union type. ↵Miss Islington (bot)2021-07-221-13/+12
| | | | | | | (GH-27247) (#27296) (cherry picked from commit 2e3744d50b6e30ea24351e55b4352dcc58fd469e) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* bpo-44633: Fix parameter substitution of the union type with wrong types. ↵Miss Islington (bot)2021-07-181-16/+28
| | | | | | | | | (GH-27218) (GH-27224) A TypeError is now raised instead of returning NotImplemented. (cherry picked from commit 3ea5332a4365bdd771286b3e9692495116e9ceef) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* [3.10] bpo-44654: Refactor and clean up the union type implementation ↵Miss Islington (bot)2021-07-175-99/+55
| | | | | | (GH-27196) (GH-27219) (cherry picked from commit 0fd27375cabd12e68a2f12cfeca11a2d5043429e)
* [3.10] bpo-44490: Add __parameters__ and __getitem__ to types.Union ↵Serhiy Storchaka2021-07-172-19/+84
| | | | | | | | | | | (GH-26980) (GH-27207) Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com> Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>. (cherry picked from commit c45fa1a5d9b419cf13ad4b5a7cb453956495b83e) Co-authored-by: Yurii Karabas <1998uriyyo@gmail.com> Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
* [3.10] bpo-44652: Preserve natural order of args in the union type. ↵Serhiy Storchaka2021-07-161-2/+2
| | | | | | | (GH-27185) (GH-27190) (cherry picked from commit 0cd2d51aadcd2a0c0739a5df0a6235d64f35619e) Automerge-Triggered-By: GH:ambv
* [3.10] bpo-44636: Collapse union of equal types (GH-27178) (GH-27181)Serhiy Storchaka2021-07-161-8/+16
| | | | | | | | The result of `int | int` is now `int`. Fix comparison of the union type with non-hashable objects. `int | str == {}` no longer raises a TypeError. (cherry picked from commit d9f923280f204204f8703756aef4f655b579b4b8)
* bpo-44646: Fix the hash of the union type. (GH-27179) (#27180)Miss Islington (bot)2021-07-161-4/+6
| | | | | | | | | It no longer depends on the order of arguments. hash(int | str) == hash(str | int) Co-authored-by: Jack DeVries <58614260+jdevries3133@users.noreply.github.com> (cherry picked from commit aeaa553d650786afc6e68df1f4813ae1a5b71d05) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* bpo-44184: Apply GH-26274 to the non-GC-type branch of subtype_dealloc ↵Miss Islington (bot)2021-07-151-3/+11
| | | | | | | | | | | (GH-27165) (GH-27174) The non-GC-type branch of subtype_dealloc is using the type of an object after freeing in the same unsafe way as GH-26274 fixes. (I believe the old news entry covers this change well enough.) https://bugs.python.org/issue44184 (cherry picked from commit 074e7659f208051b6b973f7fdb654dd22b93aaa2) Co-authored-by: T. Wouters <thomas@python.org>
* bpo-42073: allow classmethod to wrap other classmethod-like descriptors ↵Miss Islington (bot)2021-07-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (GH-27115) (GH-27162) Patch by Erik Welch. bpo-19072 (GH-8405) allows `classmethod` to wrap other descriptors, but this does not work when the wrapped descriptor mimics classmethod. The current PR fixes this. In Python 3.8 and before, one could create a callable descriptor such that this works as expected (see Lib/test/test_decorators.py for examples): ```python class A: @myclassmethod def f1(cls): return cls @classmethod @myclassmethod def f2(cls): return cls ``` In Python 3.8 and before, `A.f2()` return `A`. Currently in Python 3.9, it returns `type(A)`. This PR make `A.f2()` return `A` again. As of GH-8405, classmethod calls `obj.__get__(type)` if `obj` has `__get__`. This allows one to chain `@classmethod` and `@property` together. When using classmethod-like descriptors, it's the second argument to `__get__`--the owner or the type--that is important, but this argument is currently missing. Since it is None, the "owner" argument is assumed to be the type of the first argument, which, in this case, is wrong (we want `A`, not `type(A)`). This PR updates classmethod to call `obj.__get__(type, type)` if `obj` has `__get__`. Co-authored-by: Erik Welch <erik.n.welch@gmail.com> (cherry picked from commit b83861f0265e07207a6ae2c49c40fa8f447893f2)
* bpo-44632: Fix support of TypeVar in the union type (GH-27139) (GH-27143)Miss Islington (bot)2021-07-151-1/+1
| | | | | | | | int | TypeVar('T') returns now an instance of types.Union instead of typing.Union. (cherry picked from commit a158b20019b50e3ece6e4743ec4e6ae8d818b690) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* [3.10] bpo-44635: Convert None to NoneType in the union type constructor ↵Serhiy Storchaka2021-07-151-9/+7
| | | | | | (GH-27136). (GH-27142) (cherry picked from commit b81cac05606c84958b52ada09f690463a3c7e949)
* bpo-44606: Fix __instancecheck__ and __subclasscheck__ for the union type. ↵Miss Islington (bot)2021-07-141-4/+19
| | | | | | | | | | | | (GH-27120) * Fix issubclass() for None. E.g. issubclass(type(None), int | None) returns now True. * Fix issubclass() for virtual subclasses. E.g. issubclass(dict, int | collections.abc.Mapping) returns now True. * Fix crash in isinstance() if the check for one of items raises exception. (cherry picked from commit 81989058de381108dfd0a4255b93d4fb34417002) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* bpo-44562: Use PyType_GenericAlloc in Py_GenericAlias (GH-27021)Miss Islington (bot)2021-07-051-2/+2
| | | | | | | | | | | | * bpo-44562: Use PyType_GenericAlloc in Py_GenericAlias * Update Objects/genericaliasobject.c Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> (cherry picked from commit b324c4c5f763c5116a97db8591e6dcb94456570a) Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
* bpo-44562: Remove invalid PyObject_GC_Del from error path of ↵Miss Islington (bot)2021-07-041-3/+3
| | | | | | | types.GenericAlias … (GH-27016) (cherry picked from commit d33943a6c368c2184e238019c63ac7a267da5594) Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>