Repository navigation
Conversation
gi._gi.ResultTuple (returned by Gtk.accelerator_parse()) has __hash__
hardcoded to 0, while plain tuples use content-based hashing. This
breaks set membership checks: (key, mods) in {ResultTuple(...)} fails
even though equality holds, because Python set lookup uses hash first.
Fix: wrap Gtk.accelerator_parse() calls with tuple() so both the set
contents and the lookup key share the same hash implementation.
Fixes: #1089
blshkv
added a commit
to blshkv/pentoo-overlay
that referenced
this pull request
Jun 3, 2026
Gtk.accelerator_parse() returns gi._gi.ResultTuple which has __hash__ hardcoded to 0, while plain tuples have a proper content-based hash. This breaks set membership checks when comparing ResultTuple against a plain (key, mods) tuple even though == returns True. Fix: wrap Gtk.accelerator_parse() results with tuple() in the two affected set comprehensions in test_prefseditor_keybindings.py. Upstream PR: gnome-terminator/terminator#1092 Bug: gnome-terminator/terminator#1089
Member
|
Given that the same tests pass in my test environment where I try to match the conditions described in the issue I'm hesitant to pull in this fix. If you could describe the environment and conditions in which the tests fail so that I can ensure the tests fix this, I would appreciate it. Maybe it has a newer version of Gtk that behaves differently? |
Member
|
Found an environment where the issue could be reproduced. Testing fix now |
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1089
Gtk.accelerator_parse()returns agi._gi.ResultTuple, a subclass oftuplethat has__hash__hardcoded to0. Plain Python tuples use content-based hashing.This breaks set membership checks in two tests:
Even though
ResultTuple == plain_tuplereturnsTrue, Python set lookup first checks the hash bucket. Sincehash(plain_tuple) != 0in general, the element is never found.Fix
Wrap
Gtk.accelerator_parse()withtuple()in both affected set/list comprehensions so all objects share the same hash implementation:Affected tests
test_non_empty_default_keybinding_accels_are_distincttest_duplicate_accels_not_possible_to_set