-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
bpo-41611: IDLE: Catch TclError exceptions in AutoCompleteWindow.winconfig_event() #26404
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
bpo-41611: IDLE: Catch TclError exceptions in AutoCompleteWindow.winconfig_event() #26404
Conversation
…onfig_event() Due to the <Configure> event sometimes being triggered after some delay, the completion list window may no longer exist when the handler is called. Therefore it is necessary to catch potential TclError exceptions in the handler's code. Signed-off-by: Tal Einat <[email protected]>
Why only Pipelines and not others? Why only Win32 and not Win64? I am tempted to ignore, but I will trigger a rerun by editing the new comment. (If you think too much so, you can expand.) Edit: rerun passed. |
Condense comment.
| self.is_configuring = True | ||
| if not self.is_active(): | ||
| return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it is a bug to leave self.is_configuring True when returning. It seems that not self.active should be added to the condition above. I also remember doing some test that indicated that this function may still be executed past here more than once. But another issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, though unrelated to the bug in the bpo issue. Want us to fix this in this PR while we're here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tempted but no. Partly discipline -- we have coherent problem and solution we agree on, lets merge it (when you are ready). We have done really great today with good focus. Partly I want to retry the test I remember to check for any anomaly. Start with just a PR, if you want, after this is merged into you local clone. Or start with wider issue Clean up autocomplete_w code. There is a too-big function that I would like to split. And maybe other things. Oh, and maybe some tests needing review.
| try: | ||
| # Position the completion list window | ||
| text = self.widget | ||
| text.see(self.startindex) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heavy-handed? We could move the 'try' down a few lines. I considered whether 'see' is useful even when code below fails, but cannot see that it is. So I am OK with enclosing the entire logical block.
If we caught TclError after 261, what would we do? To return, we would have to duplicate the cleanup code after the new pass. To 'break', we would have to wrap this block with a fake loop. Both are worse.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well I did write "somewhat heavy-handed" ;)
But yes, I too believe this is actually a good solution, besides perhaps refactoring to introduce a more consistent mechanism to avoid uncaught exceptions in event handlers.
But that seems out of scope for this fix.
|
Thanks @taleinat for the PR 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.9. |
…onfig_event() (pythonGH-26404) Since the <Configure> event may occur after the completion window is gone, catch potential TclError exceptions when accessing acw. (cherry picked from commit 4e2e5c1) Co-authored-by: Tal Einat <[email protected]>
|
GH-26419 is a backport of this pull request to the 3.10 branch. |
…onfig_event() (pythonGH-26404) Since the <Configure> event may occur after the completion window is gone, catch potential TclError exceptions when accessing acw. (cherry picked from commit 4e2e5c1) Co-authored-by: Tal Einat <[email protected]>
|
GH-26420 is a backport of this pull request to the 3.9 branch. |
|
|
I opened bpo-44282 to follow up on this. |
Due to the <Configure> event sometimes being triggered after some delay, the completion list window may no longer exist when the handler is called. Therefore it is necessary to catch potential TclError exceptions in the handler's code.
This PR is a somewhat heavy-handed solution (simply wrapping most of the code in a try/except block), but seems like what's needed for such an event handler.
https://bugs.python.org/issue41611