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

Missing method tkinter.Image._register #100814

Open
TheLizzard opened this issue Jan 6, 2023 · 0 comments
Open

Missing method tkinter.Image._register #100814

TheLizzard opened this issue Jan 6, 2023 · 0 comments
Labels
expert-tkinter type-bug An unexpected behavior, bug, or error

Comments

@TheLizzard
Copy link

Bug report

When tkinter get's a keyword argument, it tries to convert it to a string that tcl/tk can handle. The problem is that when a callable object is passed in as the value for a keyword argument, tkinter usually calls an internal _register method but it's missing from the Image class. Here in tkinter/__init__.py, tkinter tries to call self._register(v) but there is no method named _register in the Image class. There is a _register method for Misc and Variable but Image doesn't inherit from any of those. A minimal reproducible example:

import tkinter
root = tkinter.Tk()
tkinter.PhotoImage(height=print)

The expected error is: _tkinter.TclError: expected integer but got "140140827421696print" but it's throwing AttributeError: 'PhotoImage' object has no attribute '_register'.

The only time this bug would appear is when someone makes a mistake and calls PhotoImage or BitmapImage with a callable keyword parameter. So the only difference is the error message.

Your environment

The issue isn't environment dependant.

  • CPython versions tested on: 3.10 but from the source code, it should be present in all 3.7+ versions of cpython.
@TheLizzard TheLizzard added the type-bug An unexpected behavior, bug, or error label Jan 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
expert-tkinter type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants