Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix TypeError in signals module on weak object finalize by GC #503

Merged
merged 1 commit into from Mar 28, 2023

Conversation

rvtpro
Copy link
Contributor

@rvtpro rvtpro commented Apr 17, 2022

Checklist
  • I've ensured that similar functionality has not already been implemented
  • I've ensured that similar functionality has not earlier been proposed and declined
  • I've branched off the master or python-dual-support branch
  • I've merged fresh upstream into my branch recently
  • I've ran tox successfully in local environment
  • I've included docstrings and/or documentation and/or examples for my code (if this is a new feature)
Description:

Fixed a bug in signal module with weakref callback and added some tests for signal module.
How to reproduce error:

import urwid
def handler(weak_debug, widget, newtext):
    weak_debug.set_text("Edit widget changed to %s" % newtext)

debug = urwid.Text('')
edit = urwid.Edit('')
key = urwid.connect_signal(edit, 'change', handler, weak_args=[debug])
del debug

throws

Exception ignored in: <function Signals.connect.<locals>.weakref_callback at 0x7f97bdf44f70>
Traceback (most recent call last):
  File ".../urwid/signals.py", line 178, in weakref_callback
    del getattr(o, self._signal_attr, {})[name][key]
TypeError: list indices must be integers or slices, not Key

@neumond
Copy link
Contributor

neumond commented Oct 4, 2022

👍
I've applied similar monkeypatch in my project. It would be nice to see this merged.

@penguinolog penguinolog merged commit 6d2393b into urwid:master Mar 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants