[issue44404] tkinter's after() AttributeError with functools.partial (no attribute __name__)

Terry J. Reedy report at bugs.python.org
Fri Jun 18 17:23:10 EDT 2021


Terry J. Reedy <tjreedy at udel.edu> added the comment:

The docstring for .after says the 2nd argument must be a 'function'.  Whether this issue is a bugfix or enhancement request depends whether one interprets 'function' as 'callable' or something narrower that only includes objects that necessarily have __name__ attributes.  The latter would exclude partials and instances of user classes with __call__ methods.

While a one-time-use partial as in the example is superfluous, I think other uses and parameterized callback classes should be supported.  So I agree with changing the tkinter code rather than qualifying 'function' with 'has a .__name__ attribute'.  I think 'type(func).__name__' should be safe.

----------
nosy: +terry.reedy

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44404>
_______________________________________


More information about the Python-bugs-list mailing list