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
IDLE - regression with exit() and quit() #61785
Comments
This issue is a split from bpo-5492, where Terry noticed a serious regression that "quit()" and "exit()" no longer work in IDLE. Before bpo-9290, the PyShell object itself was stdin and it didn't have a "fileno" method. The code in site.py would skip over the call to fileno, leaving fd == -1, which then called close() on stdin, effectively the close() method of PyShell. The application of bpo-9290 introduced PseudoFile as a subclass of io.TextIOBase which has a "fileno" method. The site.py code find it, calls it, but an error gets raised so that the close() method doesn't get called. Even if you subclass fileno(), you still need to subclass close() so that it calls the original close function in PyShell. The attached patch, fileno_close.patch, fixes that issue. I would argue that this patch should be applied to all the release candidates as it corrects a serious regression. I would like to hear your thoughts before applying the patch. |
I thought of this exact patch, but then decided against it.
The solution I gave for site.py is to begin .__call__ with The name as seen by the user process should be checked but I cannot do so at the moment (on substitute substitute computer). This would only be done in the release by the file managers. The exact decision is up to them. So I would replace IDLE with site.py in the title. |
I agree that site.py's Quitter exception logic has a flaw as described on the email from python-dev. But I disagree that the problem of IDLE not exiting is due to site.py. Even if you fix site.py (which I did), calling sys.stdin.close() won't close IDLE since PseudoInputFile's close method doesn't call PyShell's close method. |
I see that now. Then both files should be fixed. I still object to introducing a buggy .fileno ;-). |
Terry, I agree that the original patch introduces a buggy fileno and it "knows" too much about the internals of site.py which could change. The attached patch modifies site.py, similar to how Nick Coghlan split the two function calls in a single try/except block into two separate try/except blocks. I tried to keep the change as small as possible to avoid introducing any unintended regressions. The change does pass the test suite on 3.4 on Linux. |
Please read http://mail.python.org/pipermail/python-dev/2013-March/125021.html . The fileno() check shouldn't be needed anymore. Also, it can't effect 2.7, or you have another problem. |
(s/effect/affect/, sorry) |
Antoine, it does affect 2.7 since sys.stdin.close() doesn't call PyShell's close method. bpo-9290 introduced this regression. I accept some responsibility because my manual testing of those patches in bpo-9290 didn't include trying the exit() and quit() methods. The attached patch fixes the problem on the 2.7 branch. |
I would also argue that the fileno_close.patch ought to be applied to the 3.2.4 and 3.3.1 release candidates. The changes in bpo-9290 were applied only two months ago. |
I won't argue about any changes in IDLE, but the fileno-checking code in site.py should probably be removed, not complicated. |
I agree with Antoine that fileno checking code should be removed. I dug deeper into why that was introduced in the first place. 00b136b7da84 introduced the warning "Trying to close unclosable fd!" So the code in site.py for checking fileno is cruft and can be safely removed. The site_reversion patch backs out of 86358b43c8bb. |
Perhaps PseudoInputFile.close() should call super().close() to set closed flag. Perhaps close() should be even implemented in PseudoFile. It's my fault in this regression. I deliberately have not implemented PseudoFile.close(), because I saw no sense in deliberate calling of sys.std*.close() and considered closing the window with unpremeditated closing of the standard stream is too dangerous. |
Serhiy, don't worry. There's still plenty of broken found in IDLE. Antoine, may I modify site.py with site_reversion.patch? If not, then I can include a workaround in IDLE. |
Yes, fixing site.py is fine. |
New changeset 99e363e67844 by Roger Serwy in branch '2.7': New changeset d3c67e2fc68c by Roger Serwy in branch '3.3': New changeset 82451c88b3c0 by Roger Serwy in branch 'default': |
Thanks, Antoine. I am closing this issue as fixed. |
Note: 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: