Skip to content

Tkinter getint(), getboolean() argument must be str, not tuple #118760

Description

@zooba

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 tuple

I 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

Activity

  1. changed the title [-]Tkinter getint() argument must be str, not tuple[/-] [+]Tkinter getint(), getboolean() argument must be str, not tuple[/+] on May 8, 2024
  2. serhiy-storchaka commented on May 8, 2024

    @serhiy-storchaka
    Member

    Yes, it is my fault.

  3. terryjreedy commented on May 8, 2024

    @terryjreedy
    Member

    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:

    Exception in Tkinter callback
    Traceback (most recent call last):
      File "F:\dev\3x\Lib\tkinter\__init__.py", line 2064, in __call__
        args = self.subst(*args)
      File "F:\dev\3x\Lib\tkinter\__init__.py", line 1758, in _substitute
        try: e.send_event = getboolean(E)
                            ~~~~~~~~~~^^^
    TypeError: getboolean() argument must be str, not tuple
    

    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.

  4. added a commit that references this issue on May 8, 2024
  5. serhiy-storchaka commented on May 8, 2024

    @serhiy-storchaka
    Member

    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 wantobjects is 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.

  6. added a commit that references this issue on May 8, 2024
  7. terryjreedy commented on May 8, 2024

    @terryjreedy
    Member

    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.

  8. added a commit that references this issue on May 15, 2024
  9. added a commit that references this issue on May 15, 2024
  10. serhiy-storchaka commented on May 15, 2024

    @serhiy-storchaka
    Member

    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.

  11. added 2 commits that reference this issue on May 15, 2024
  12. added a commit that references this issue on May 20, 2024
  13. added a commit that references this issue on May 20, 2024
  14. encukou commented on May 21, 2024

    @encukou
    Member

    Can this be closed now?

  15. terryjreedy commented on May 21, 2024

    @terryjreedy
    Member

    IDLE and test_idle work fine for me now.

  16. zooba commented on May 21, 2024

    @zooba
    MemberAuthor

    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.

  17. added 2 commits that reference this issue on Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions