Content-Length: 290189 | pFad | https://github.com/python/cpython/issues/100814

40 Missing method tkinter.Image._register · Issue #100814 · python/cpython · GitHub
Skip to content

Missing method tkinter.Image._register #100814

@TheLizzard

Description

@TheLizzard

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.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions









      ApplySandwichStrip

      pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


      --- a PPN by Garber Painting Akron. With Image Size Reduction included!

      Fetched URL: https://github.com/python/cpython/issues/100814

      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy