- changed status to resolved
Event removal not working
Issue #2973
resolved
Very simple test scenario:
import sqlalchemy as sa
@sa.event.listens_for(sa.orm.mapper, 'instrument_class')
def my_listener(mapper, cls):
pass
sa.event.remove(
sa.orm.mapper, 'instrument_class', my_listener
)
This throws a ValueError:
def remove(self, event_key):
target = event_key.dispatch_target
stack = [target]
while stack:
cls = stack.pop(0)
stack.extend(cls.__subclasses__())
if cls in self._clslevel:
> self._clslevel[cls].remove(event_key.fn)
E ValueError: list.remove(x): x not in list
Maybe the event_key.fn
should be event_key.fn_wrap
instead?
Comments (3)
-
repo owner -
repo owner thanks for the test case!
-
reporter Thanks a lot for fixing this!
- Log in to comment
.Mapper
or :class:.ClassManager
level, as opposed to on an individual mapped class, and also on :class:.Connection
) that also made use of internal argument conversion (which is most within those categories) would fail to be removable. fixes#2973→ <<cset e60529da7974>>