1 SUSPECT #1
class Box:
def __init__(self):
self._v = 0
@property
def v(self):
return self._v
@v.setter
def v(self, x):
self._v = x * 2
b = Box()
b.value = 5
print(b.v) Traceback (most recent call last):
File "lineup.py", line 13, in <module>
print(b.v)
AttributeError: 'Box' object has no attribute 'v' (did you mean: '_v'?) 2 SUSPECT #2
import functools
@functools.cache
def slow(n):
return n * 2
slow([1, 2, 3]) Traceback (most recent call last):
File "lineup.py", line 7, in <module>
slow([1, 2, 3])
~~~~^^^^^^^^^^
TypeError: unhashable type: 'list' 3 SUSPECT #3
def factory():
funcs = []
for i in range(3):
funcs.append(lambda: i)
return funcs
print([f() for f in factory()]) # (no error β but the OUTPUT might surprise you)
[2, 2, 2] 4 SUSPECT #4
data = {"a": 1, "b": 2, "c": 3}
for key in data:
if key == "b":
data["d"] = 4 Traceback (most recent call last):
File "lineup.py", line 2, in <module>
for key in data:
KeyError: 'd' 5 SUSPECT #5
try:
raise ValueError("first")
except ValueError as e:
raise RuntimeError("second") from e Traceback (most recent call last):
File "lineup.py", line 2, in <module>
raise ValueError("first")
ValueError: first
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "lineup.py", line 4, in <module>
raise RuntimeError("second") from e
RuntimeError: second