-
-
Notifications
You must be signed in to change notification settings - Fork 30k
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
pyshell.py: name 'sys' is not defined #73348
Comments
Sorry for my bad English. line 7, 13 at pyshell.py. |
pyshell.py is not part of CPython, this is the wrong place to report a bug like this. |
I think the OP is talking about Lib/idlelib/pyshell.py. The relevant changeset is 76f831e4b806. "from tkinter import *" imports the sys module as a side-effect. OO O, did you notice this by reading the code or by using a tool like flake8? |
to msg284696 - (view): OK~ |
Great, thanks for following up with us. |
I misread your comment. I think we need to add "import sys" to that file so I'm reopening this. |
New changeset 52d671684342 by Terry Jan Reedy in branch '3.6': |
I agree that depending on the incidental import is a bug. Tkinter could change, or I might change 'from tkinter import *' to 'from tkinter import Tk, ...' or 'import tkinter as tk'. Serhiy, tkinter/init.py imports enum, sys, and re under their own names, so that * imports incidentally import them into other programs. I believe it is customary for library modules to underscore stdlib imports to prevent this: "import enum as _enum", etc. But I don't remember is this is in the devguide. Do you think we should make the change to tkinter? |
I agree that incidental names should be eliminated from import. Could you open a new issue for this? |
Reopening because I missed file=sys.__stderr__ in the print() above sys.exit ;-(. Reported by JelleZijlstra in PR. I wonder if there is any way to force an import to fail when testing. I could at least partly test by moving the code for import failure and that for "if TkVersion < 8.5" into functions. |
The follow-up tkinter import issue is bpo-29446 |
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: