Repository navigation
Tkinter getint(), getboolean() argument must be str, not tuple #118760
Copy link
Copy link
Closed
Labels
OS-windowsrelease-blockertopic-IDLEtopic-tkintertype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Discovered during 3.13b1 release (we decided not to block the release over it, so this is just a known issue in b1):
While interacting with the config dialog in IDLE, I get these errors printed in the background.
Exception in Tkinter callback
Traceback (most recent call last):
File "D:\cpython\Lib\tkinter\__init__.py", line 2064, in __call__
args = self.subst(*args)
File "D:\cpython\Lib\tkinter\__init__.py", line 1752, in _substitute
e.state = getint_event(s)
~~~~~~~~~~~~^^^
File "D:\cpython\Lib\tkinter\__init__.py", line 1726, in getint_event
return getint(s)
TypeError: getint() argument must be str, not tupleI suspect this is the underlying cause of these test failures, which were discovered in our final stage testing of the Windows release:
======================================================================
ERROR: test_highlight_target_text_mouse (idlelib.idle_test.test_configdialog.HighPageTest.test_highlight_target_text_mouse)
----------------------------------------------------------------------
Traceback (most recent call last):
File "D:\a\1\b\Python\Lib\idlelib\idle_test\test_configdialog.py", line 447, in test_highlight_target_text_mouse
eq(d.highlight_target.get(), elem[tag])
~~~~^^^^^
KeyError: 'sel'
======================================================================
FAIL: test_highlight_sample_b1_motion (idlelib.idle_test.test_configdialog.HighPageTest.test_highlight_sample_b1_motion)
----------------------------------------------------------------------
Traceback (most recent call last):
File "D:\a\1\b\Python\Lib\idlelib\idle_test\test_configdialog.py", line 493, in test_highlight_sample_b1_motion
eq(hs.tag_ranges('sel'), ())
~~^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: Tuples differ: (<string object: '1.0'>, <string object: '1.24'>) != ()
First tuple contains 2 additional elements.
First extra element 0:
<string object: '1.0'>
- (<string object: '1.0'>, <string object: '1.24'>)
+ ()
======================================================================
FAIL: test_highlight_sample_double_click (idlelib.idle_test.test_configdialog.HighPageTest.test_highlight_sample_double_click)
----------------------------------------------------------------------
Traceback (most recent call last):
File "D:\a\1\b\Python\Lib\idlelib\idle_test\test_configdialog.py", line 471, in test_highlight_sample_double_click
eq(hs.tag_ranges('sel'), ())
~~^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: Tuples differ: (<string object: '1.0'>, <string object: '1.24'>) != ()
First tuple contains 2 additional elements.
First extra element 0:
<string object: '1.0'>
- (<string object: '1.0'>, <string object: '1.24'>)
+ ()
----------------------------------------------------------------------Possibly related to @serhiy-storchaka's recent changes?
Linked PRs
- gh-118760: Fix errors in calling Tkinter bindings on Windows #118782
- gh-118760: Restore the default value of tkinter.wantobjects to 1 #118784
- [3.13] gh-118760: Fix errors in calling Tkinter bindings on Windows (GH-118782) #119072
- [3.13] gh-118760: Restore the default value of tkinter.wantobjects to 1 (GH-118784) #119251
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
OS-windowsrelease-blockertopic-IDLEtopic-tkintertype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Projects
- StatusShow more project fieldsDone
Activity
[-]Tkinter getint() argument must be str, not tuple[/-][+]Tkinter getint(), getboolean() argument must be str, not tuple[/+]serhiy-storchaka commentedon May 8, 2024
Yes, it is my fault.
terryjreedy commentedon May 8, 2024
I see same test failures and errors in main and 3.13.0b1, not in 3.13.0a6. In main, I see geting error and also:
The Setting dialog Highlights page is unique in IDLE in having tag binding, which happen to be for left button clicks. Click on an element in the sample and the callback changes the label and background in the buttons above. The bug is that clicks after the first are often ignored, so that multiple clicks are required for one to be registered. At some point, a double click causes the sample box and the dialog to shrink in height by a half inch.
Because not all clicks are ignored, users can managed if they think to keep trying. I expect this will affect other tkinter apps with tag bindings and think this should be blocker for next beta.
pythongh-118760: Fix errors in calling Tkinter bindings on Windows
serhiy-storchaka commentedon May 8, 2024
It is a consequence of #98592.
For unknown reasons some arguments are passed as a 1-tuple containing a Tcl_Obj with type "string" and value "0" what
wantobjectsis 2 (i.e. when they are not forcefully stringified). This happens only on Windows, and not always, running only the selected test is passed. I also tried to write tests for generated events (#118778), but they do not expose such weird behavior (perhaps for the same reason as it is not always reproducible in IDLE tests).I have two solutions for this. One -- fix the Event creation code where it fails. Two -- simply restore wantobjects = 1 by default (but keep experimental support for wantobjects = 2). I am going to apply both solutions.
pythongh-118760: Restore the default value of tkiter.wantobjects to 1
terryjreedy commentedon May 8, 2024
Opening Settings with Font tab default raises 2 getint errors. But non-default size is correct.
Selecting Highlights and first click always works. First click after successful click always fails with getboolean error. Sometimes (>1/2?) next click also fails, with getboolean. This is the only random behavior I see. If failure, 3rd click seems to work. Selecting another tab and back to Highlights and first click works.
gh-118760: Fix errors in calling Tkinter bindings on Windows (GH-118782)
pythongh-118760: Fix errors in calling Tkinter bindings on Windows (p…
serhiy-storchaka commentedon May 15, 2024
This may be due to the caching of the mutable Tcl_Obj in the Tcl core, so the string "2" may be interpreted differently depending on the interpretation of other strings "2" -- as a string, a number, a "pixel" object, or a list containing any of the listed.
[3.13] gh-118760: Fix errors in calling Tkinter bindings on Windows (G…
gh-118760: Restore the default value of tkinter.wantobjects to 1 (GH-…
pythongh-118760: Restore the default value of tkinter.wantobjects to 1 (
[3.13] gh-118760: Restore the default value of tkinter.wantobjects to…
encukou commentedon May 21, 2024
Can this be closed now?
terryjreedy commentedon May 21, 2024
IDLE and test_idle work fine for me now.
zooba commentedon May 21, 2024
I don't know that I can confirm fully until we do the next release, as the test that failed was the one that tests the installer after it's produced. But we can easily bypass the tests again if they fail next time, so no further need to keep this open IMHO.
pythongh-118760: Fix errors in calling Tkinter bindings on Windows (p…
pythongh-118760: Restore the default value of tkinter.wantobjects to 1 (