1 SUSPECT #1
from typing import NamedTuple
class Point(NamedTuple):
x: int
y: int
p = Point(1, 2)
p.x = 99 Traceback (most recent call last):
File "lineup.py", line 7, in <module>
p.x = 99
^^^
AttributeError: can't set attribute 2 SUSPECT #2
import sys
sys.setrecursionlimit(40)
def f(): f()
try:
f()
except RecursionError as e:
print("ok", type(e).__name__) # (no error in main β the RecursionError IS caught)
ok RecursionError 3 SUSPECT #3
class Vec:
__slots__ = ("x", "y")
Vec.z = 99
print(Vec.z) Traceback (most recent call last):
File "lineup.py", line 4, in <module>
Vec.z = 99
SlotsViolationError: cannot add 'z' to slotted class 'Vec' 4 SUSPECT #4
from abc import ABC, abstractmethod
class Animal(ABC):
@abstractmethod
def speak(self): ...
Animal() Traceback (most recent call last):
File "lineup.py", line 7, in <module>
Animal()
~~~~~~^^
TypeError: Can't instantiate abstract class Animal without an implementation for abstract method 'speak' 5 SUSPECT #5
import itertools
result = list(itertools.islice(itertools.cycle([1, 2]), 5))
print(result) # (no error)
[1, 2, 1, 2, 1]