14 lines
333 B
Python
14 lines
333 B
Python
from types import FunctionType
|
|
|
|
|
|
class DeferErrror(RuntimeError):
|
|
pass
|
|
|
|
|
|
class FreeVarsError(DeferErrror):
|
|
def __init__(self, fn: FunctionType) -> None:
|
|
super().__init__(
|
|
"deferred function must not have free variables",
|
|
)
|
|
self.add_note("free vars: " + str(list(fn.__code__.co_freevars)))
|