1 SUSPECT #1
import contextvars
v = contextvars.ContextVar("v", default=0)
v.set(42)
print(v.get()) # (no error)
42 2 SUSPECT #2
from concurrent.futures import ThreadPoolExecutor
def square(x): return x * x
with ThreadPoolExecutor(max_workers=3) as ex:
results = list(ex.map(square, range(5)))
print(results) # (no error)
[0, 1, 4, 9, 16] 3 SUSPECT #3
import sys
class NoRepr:
def __repr__(self):
raise RuntimeError("nope")
n = NoRepr()
print(type(n).__name__)
# attempting to print n itself would fail # (no error β type().__name__ doesn't call __repr__)
NoRepr 4 SUSPECT #4
from dataclasses import dataclass
@dataclass(slots=True, frozen=True)
class Vec:
x: float
y: float
v = Vec(1.0, 2.0)
# attempted reassignment
try:
v.x = 5.0
except Exception as e:
print(type(e).__name__) # (no error in main β the exception IS caught)
FrozenInstanceError 5 SUSPECT #5
import weakref
class Node:
pass
# No strong reference held to Node()
r = weakref.ref(Node())
print(r()) Traceback (most recent call last):
File "lineup.py", line 6, in <module>
r = weakref.ref(Node())
weakref.WeakReferenceError: target object has no strong references