classification
Title: IDLE should suppress ValueError for list.remove()
Type: behavior Stage:
Components: IDLE Versions: Python 3.9
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: terry.reedy Nosy List: rhettinger, terry.reedy
Priority: normal Keywords:

Created on 2021-09-14 15:33 by rhettinger, last changed 2021-09-15 03:00 by terry.reedy.

Messages (2)
msg401782 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2021-09-14 15:33
I got this today running a stock Python 3.9.6 for macOS downloaded from python.org.

-------------------------------------------------------------

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/tkinter/__init__.py", line 1892, in __call__
    return self.func(*args)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/idlelib/multicall.py", line 176, in handler
    r = l[i](event)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/idlelib/autocomplete_w.py", line 350, in keypress_event
    self.hide_window()
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/idlelib/autocomplete_w.py", line 463, in hide_window
    self.widget.event_delete(HIDE_VIRTUAL_EVENT_NAME, seq)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/idlelib/multicall.py", line 392, in event_delete
    triplets.remove(triplet)
ValueError: list.remove(x): x not in list
msg401807 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2021-09-15 03:00
The offending function is

        def event_delete(self, virtual, *sequences):
            if virtual not in self.__eventinfo:
                return
            func, triplets = self.__eventinfo[virtual]
            for seq in sequences:
                triplet = _parse_sequence(seq)
                if triplet is None:
                    #print("Tkinter event_delete: %s" % seq, file=sys.__stderr__)
                    widget.event_delete(self, virtual, seq)
                else:
                    if func is not None:
                        self.__binders[triplet[1]].unbind(triplet, func)
                    triplets.remove(triplet)

The triplets collection is part of *virtual* whereas each triplet is derived from a member of sequences. 
The discrepancy seems to be extremely rare.  I will catch the exception until such time as I see a plausible, reproducible, and testable reason.
History
Date User Action Args
2021-09-15 03:00:13terry.reedysetmessages: + msg401807
2021-09-14 15:33:16rhettingercreate