One function
set_handler in benmoran56/esper
The author described this change as “Fix Bug when adding a function as an event handler.”. It counts as a record because the check below fails on the code as it stood at dc9a9bf4c and passes on 43bc99d3b, with nothing else changed between the two runs.
Projectbenmoran56/esper
Fix saved2022-06-10
Sharing licenceMIT · LICENSE
Change size+4 −1
What the code was meant to do, written into the code itself as a docstring
Register a function to handle the named event type. After registering a function, it will receive all events that are dispatched by the passed name. Only a weak reference is kept to the passed function. If :param name: The name of the event type to handle. :param func: The function or method to register as a handler for the event type.
The change
| 13 | 13 | if name not in event_registry: | |
| 14 | 14 | event_registry[name] = set() | |
| 15 | 15 | ||
| 16 | - | event_registry[name].add(_WeakMethod(func, _make_callback(name))) | |
| 16 | + | if isinstance(func, _MethodType): | |
| 17 | + | event_registry[name].add(_WeakMethod(func, _make_callback(name))) | |
| 18 | + | else: | |
| 19 | + | event_registry[name].add(_ref(func, _make_callback(name))) |
The check that tells the two apart
fail→pass·tests/test_world.py::test_event_dispatch_one_arg
Check file tests/test_world.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before itdc9a9bf4c081cd6c81144f0617b845a1d4718b25
Broken version dated2022-03-16
Moduleesper.__init__
Units changedset_handler
Fingerprint31854e9476259c10
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.