mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
gh-92063: Enforce types in specialized PRECALL opcodes (GH-92068)
* Check the types of PRECALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS * fix PRECALL_NO_KW_METHOD_DESCRIPTOR_NOARGS as well * fix PRECALL_NO_KW_METHOD_DESCRIPTOR_O * fix PRECALL_NO_KW_METHOD_DESCRIPTOR_FAST
This commit is contained in:
parent
3a8e2b6e65
commit
868b1afa05
3 changed files with 56 additions and 16 deletions
|
@ -4726,6 +4726,33 @@ order (MRO) for bases """
|
|||
with self.assertRaises(TypeError):
|
||||
str.__add__(fake_str, "abc")
|
||||
|
||||
def test_specialized_method_calls_check_types(self):
|
||||
# https://github.com/python/cpython/issues/92063
|
||||
class Thing:
|
||||
pass
|
||||
thing = Thing()
|
||||
for i in range(20):
|
||||
with self.assertRaises(TypeError):
|
||||
# PRECALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS
|
||||
list.sort(thing)
|
||||
for i in range(20):
|
||||
with self.assertRaises(TypeError):
|
||||
# PRECALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS
|
||||
str.split(thing)
|
||||
for i in range(20):
|
||||
with self.assertRaises(TypeError):
|
||||
# PRECALL_NO_KW_METHOD_DESCRIPTOR_NOARGS
|
||||
str.upper(thing)
|
||||
for i in range(20):
|
||||
with self.assertRaises(TypeError):
|
||||
# PRECALL_NO_KW_METHOD_DESCRIPTOR_FAST
|
||||
str.strip(thing)
|
||||
from collections import deque
|
||||
for i in range(20):
|
||||
with self.assertRaises(TypeError):
|
||||
# PRECALL_NO_KW_METHOD_DESCRIPTOR_O
|
||||
deque.append(thing, thing)
|
||||
|
||||
def test_repr_as_str(self):
|
||||
# Issue #11603: crash or infinite loop when rebinding __str__ as
|
||||
# __repr__.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue