-
-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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
tkinter's after() AttributeError with functools.partial (no attribute __name__) #88570
Comments
|
Reproducible in Python 3.9. The issue occurs because functools.partial is a class, not function. I believe the fix is simply something like: try: This will use the name 'partial'. The lack of '__name__' is noted in the functools docs so I agree with Philip that this is an issue with tkinter. Philip, do you want to open a pull request for this? It should be noted that functools.partial is not required in this situation as 'after' takes arguments for the function call: |
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. |
It is on borderline between new feature and bugfix (depends on your interpretation of the documentation), so I decided to backport it to not yet released 3.10, but not to 3.9 which has been already used for a year. |
I was thinking the same. |
Can this issue be closed? |
When the backport is done or Serhiy changes his mind. Can you change labels on your own PRs? |
There were some issues with the backporting bot. Seems they were temporary. Thank you for your contribution E. Paine. For this issue and others. |
Sadly not (hence why I need to ask for e.g. skip news) |
after
support callable classes #26812after
support callable classes (GH-26812) #26921Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: