Commit Graph

7178 Commits

Author SHA1 Message Date
Mark Shannon a7252f88d3
bpo-40116: Add insertion order bit-vector to dict values to allow dicts to share keys more freely. (GH-28520) 2021-10-06 13:19:53 +01:00
Serhiy Storchaka 252b7bcb23
bpo-45355: More use of sizeof(_Py_CODEUNIT) (GH-28720) 2021-10-04 14:11:26 +03:00
Serhiy Storchaka 60b9e040c9
bpo-45355: Use sizeof(_Py_CODEUNIT) instead of literal 2 for the size of the code unit (GH-28711) 2021-10-03 21:22:42 +03:00
Raymond Hettinger dc878240dc
Fix spelling error in comment (GH-28696) 2021-10-02 13:52:05 -05:00
Victor Stinner 8620be99da
bpo-45061: Revert unicode_is_singleton() change (GH-28516)
Don't use a loop over 256 items, only checks for a single singleton.
2021-09-22 12:16:53 +02:00
Mohamad Mansour 8f943ca257
[codemod] Fix non-matching bracket pairs (GH-28473)
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>
2021-09-22 01:09:00 +02:00
Victor Stinner 86f28372b1
bpo-45061: Detect refcount bug on empty string singleton (GH-28504)
Detect refcount bugs in C extensions when the empty Unicode string
singleton is destroyed by mistake.

* Move forward declarations to the top of unicodeobject.c.
* Simplifiy unicode_is_singleton().
2021-09-21 23:43:09 +02:00
Victor Stinner 79a3148099
bpo-45061: Detect refcount bug on empty tuple singleton (GH-28503)
Detect refcount bugs in C extensions when the empty tuple singleton
is destroyed by mistake.

Add the _Py_FatalRefcountErrorFunc() function.
2021-09-21 23:04:34 +02:00
Serhiy Storchaka f25f2e2e8c
Clean up initialization __class_getitem__ with Py_GenericAlias. (GH-28450)
The cast to PyCFunction is redundant. Overuse of redundant casts
can hide actual bugs.
2021-09-19 18:05:30 +03:00
Raymond Hettinger 94b462686b
bpo-45198: __set_name__ documentation not clear about its usage with non-descriptor classes (GH-28439) 2021-09-18 01:49:43 -05:00
wyz23x2 f4813388b4
bpo-44640: Improve punctuation consistency in isinstance/issubclass error messages (GH-27144)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2021-09-18 01:10:17 +02:00
Mark Shannon 064464fc38
bpo-45219: Factor dictkey indexing (GH-28389) 2021-09-17 12:20:51 +01:00
Barry Warsaw 07e737d002
bpo-45155 : Default arguments for int.to_bytes(length=1, byteorder=sys.byteorder) (#28265)
Add default arguments for int.to_bytes() and int.from_bytes()

Co-authored-by: Brandt Bucher <brandtbucher@gmail.com>
2021-09-15 19:55:24 -07:00
Serhiy Storchaka 5dce51a887
bpo-45167: Fix deepcopying of GenericAlias (GH-28324) 2021-09-15 20:25:41 +02:00
Benjamin Peterson 024fda47d4
closes bpo-45190: Update Unicode data to version 14.0.0. (GH-28336) 2021-09-14 11:00:38 -07:00
Serhiy Storchaka 92bf8691fb
bpo-43413: Fix handling keyword arguments in subclasses of some buitin classes (GH-26456)
* Constructors of subclasses of some buitin classes (e.g. tuple, list,
  frozenset) no longer accept arbitrary keyword arguments.
* Subclass of set can now define a __new__() method with additional
  keyword parameters without overriding also __init__().
2021-09-12 13:27:50 +03:00
Victor Stinner fb305092a5
bpo-44348: BaseException deallocator uses trashcan (GH-28190)
The deallocator function of the BaseException type now uses the
trashcan mecanism to prevent stack overflow. For example, when a
RecursionError instance is raised, it can be linked to another
RecursionError through the __context__ attribute or the __traceback__
attribute, and then a chain of exceptions is created. When the chain
is destroyed, nested deallocator function calls can crash with a
stack overflow if the chain is too long compared to the available
stack memory.
2021-09-07 15:42:11 +02:00
Yury Selivanov 2c3474a637
bpo-45123: PyAiter_Check and PyObject_GetAiter fix & rename. (GH-28194)
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>
2021-09-07 11:52:30 +01:00
Pablo Galindo Salgado 533e725821
bpo-44963: Implement send() and throw() methods for anext_awaitable objects (GH-27955)
Co-authored-by: Yury Selivanov <yury@edgedb.com>
2021-09-07 11:30:14 +01:00
Tim Peters 5cb4c672d8
bpo-34561: Switch to Munro & Wild "powersort" merge strategy. (#28108)
For list.sort(), replace our ad hoc merge ordering strategy with the principled, elegant,
and provably near-optimal one from Munro and Wild's "powersort".
2021-09-06 12:54:41 -05:00
Serhiy Storchaka 936f6a16b9
bpo-45030: Fix integer overflow in __reduce__ of the range iterator (GH-28000)
It happened with fast range iterator  when the calculated stop = start + step * len
was out of the C long range.
2021-09-04 21:02:21 +03:00
Victor Stinner 4300352000
bpo-45061: Detect Py_DECREF(Py_True) bug (GH-28089)
Add a deallocator to the bool type to detect refcount bugs in C
extensions which call Py_DECREF(Py_True) or Py_DECREF(Py_False) by
mistake.
2021-08-31 18:05:15 +02:00
chilaxan 94a3d2a632
bpo-45018: Fix rangeiter_reduce in rangeobject.c (GH-27938)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2021-08-27 12:27:19 +02:00
Mark Shannon d3eaf0cc5b
bpo-44945: Specialize BINARY_ADD (GH-27967) 2021-08-27 09:21:01 +01:00
Mark Shannon 15d50d7ed8
bpo-44946: Streamline operators and creation of ints for common case of single 'digit'. (GH-27832) 2021-08-25 14:28:43 +01:00
Mark Shannon f9242d50b1
bpo-44990: Change layout of evaluation frames. "Layout B" (GH-27933)
Places the locals between the specials and stack. This is the more "natural" layout for a C struct, makes the code simpler and gives a slight speedup (~1%)
2021-08-25 13:44:20 +01:00
Mark Dickinson ae5259171b
Fix bytes.__bytes__ to not truncate at a zero byte (GH-27902) 2021-08-23 15:24:12 +01:00
Dong-hee Na 24b63c695a
bpo-24234: Implement bytes.__bytes__ (GH-27901) 2021-08-23 19:01:51 +09:00
Mark Dickinson 6082bb5add
bpo-24234: implement complex.__complex__ (GH-27887)
Co-authored-by: Dong-hee Na <donghee.na92@gmail.com>
2021-08-23 09:15:49 +01:00
Mark Dickinson 60b93d9e49
bpo-44954: Fix wrong result in float.fromhex corner case (GH-27834) 2021-08-20 11:40:11 +01:00
Mark Dickinson 4b9a2dcf19
bpo-44698: Restore complex pow behaviour for small integral exponents (GH-27772) 2021-08-17 17:51:28 +01:00
Hai Shi 3e2c643ae0
bpo-42035: Add PyType_GetQualName() to get a type's qualified name. (GH-27551) 2021-08-17 15:39:34 +02:00
Guido van Rossum 62bd97303e
Fix a SystemError in code.replace() (#27771)
While the comment said 'We don't bother resizing localspluskinds',
this would cause .replace() to crash when it happened.
(Also types.CodeType(), but testing that is tedious, and this tests all
code paths.)
2021-08-16 11:34:23 -07:00
Mark Shannon 1a511dc92d
bpo-44914: Maintain invariants of type version tags. (GH-27773)
* Do not invalidate type versions unnecessarily.
2021-08-16 12:21:34 +01:00
Pablo Galindo Salgado bfc2d5a5c4
bpo-33930: Fix segfault with deep recursion when cleaning method objects (GH-27678) 2021-08-11 00:34:14 +01:00
Serhiy Storchaka 058fb35b57
bpo-44854: Remove trailing whitespaces (GH-27689) 2021-08-09 21:32:54 +03:00
Irit Katriel 7d14fdb03c
bpo-44872: use new trashcan macros in framobject.c (#27683) 2021-08-09 18:11:38 +01:00
Mark Shannon ac75f6bdd4
bpo-44826: Specialize STORE_ATTR (GH-27590)
* Generalize cache names for LOAD_ATTR to allow store and delete specializations.

* Factor out specialization of attribute dictionary access.

* Specialize STORE_ATTR.
2021-08-09 10:40:21 +01:00
Mark Shannon cee67fa661
bpo-44821: Eagerly assign __dict__ for new objects. (GH-27589) 2021-08-04 16:41:14 +01:00
Serhiy Storchaka 8c9f847997
bpo-27275: Change popitem() and pop() methods of collections.OrderedDict (GH-27530)
* Unify the C and Python implementations of OrderedDict.popitem().

The C implementation no longer calls ``__getitem__`` and ``__delitem__``
methods of the OrderedDict subclasses.

* Change popitem() and pop() methods of collections.OrderedDict

For consistency with dict both implementations (pure Python and C)
of these methods in OrderedDict no longer call __getitem__ and
__delitem__ methods of the OrderedDict subclasses.

Previously only the Python implementation of popitem() did not
call them.
2021-08-03 13:00:55 +02:00
Mark Shannon e06ae75e16
bpo-44206: Make sure that dict-keys's version is set to zero when value is popped (GH-27542) 2021-08-02 14:54:23 +01:00
Yurii Karabas 8182c8329c
bpo-44662: Add ability to annotate types.Union (#27214)
Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
2021-07-29 21:44:48 +02:00
Serhiy Storchaka e5c8ddb171
bpo-44707: Fix an undefined behavior of the null pointer arithmetic (GH-27292) 2021-07-29 12:36:24 +01:00
Inada Naoki ce5e1a6809
bpo-41103: Resurrect the old buffer protocol. (GH-27437)
Revert "bpo-41103: Remove old buffer protocol support (#21117)"

This reverts commit 6f8a6ee59c.
2021-07-29 12:46:47 +02:00
Hai Shi a390ebea17
bpo-42035: Add a PyType_GetName() to get type's short name. (GH-23903) 2021-07-29 09:57:02 +02:00
Dong-hee Na ddf8ae31a0
bpo-44657: Fix instancemethod_call to use PyInstanceMethod_GET_FUNCTION (GH-27202) 2021-07-28 22:10:36 +09:00
Pablo Galindo Salgado ecc3c8e421
bpo-34013: Move the Python 2 hints from the exception constructor to the parser (GH-27392) 2021-07-27 21:30:32 +01:00
T. Wouters 1d582bbc96
bpo-44698: Fix undefined behaviour in complex exponentiation. (GH-27278) 2021-07-26 18:03:35 +02:00
Hasan 2b8ad9e6c5
bpo-44732: Rename types.Union to types.UnionType (#27342)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2021-07-26 18:00:21 +02:00
Mark Shannon ae0a2b7562
bpo-44590: Lazily allocate frame objects (GH-27077)
* Convert "specials" array to InterpreterFrame struct, adding f_lasti, f_state and other non-debug FrameObject fields to it.

* Refactor, calls pushing the call to the interpreter upward toward _PyEval_Vector.

* Compute f_back when on thread stack, only filling in value when frame object outlives stack invocation.

* Move ownership of InterpreterFrame in generator from frame object to generator object.

* Do not create frame objects for Python calls.

* Do not create frame objects for generators.
2021-07-26 11:22:16 +01:00