Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add failing regression tests
  • Loading branch information
brandtbucher committed Oct 21, 2022
commit e56520e778117af181ca0803d18d4b8da0a07b9f
67 changes: 67 additions & 0 deletions Lib/test/test_opcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,73 @@ def f():
for _ in range(1025):
self.assertFalse(f())

def test_load_shadowing_slot_should_raise_type_error(self):
class Class:
__slots__ = ("slot",)

class Sneaky:
__slots__ = ("shadowed",)
shadowing = Class.slot

def f(o):
o.shadowing

o = Sneaky()
o.shadowed = 42

for _ in range(1025):
with self.assertRaises(TypeError):
f(o)

def test_store_shadowed_slot_should_raise_type_error(self):
class Class:
__slots__ = ("slot",)

class Sneaky:
__slots__ = ("shadowed",)
shadowing = Class.slot

def f(o):
o.shadowing = 42

o = Sneaky()

for _ in range(1025):
with self.assertRaises(TypeError):
f(o)

def test_load_borrowed_slot_should_not_crash(self):
class Class:
__slots__ = ("slot",)

class Sneaky:
borrowed = Class.slot

def f(o):
o.borrowed

o = Sneaky()

for _ in range(1025):
with self.assertRaises(TypeError):
f(o)

def test_store_borrowed_slot_should_not_crash(self):
class Class:
__slots__ = ("slot",)

class Sneaky:
borrowed = Class.slot

def f(o):
o.borrowed = 42

o = Sneaky()

for _ in range(1025):
with self.assertRaises(TypeError):
f(o)


class TestLoadMethodCache(unittest.TestCase):
def test_descriptor_added_after_optimization(self):
Expand Down