diff options
author | Terry Jan Reedy <tjreedy@udel.edu> | 2014-09-20 02:38:41 (GMT) |
---|---|---|
committer | Terry Jan Reedy <tjreedy@udel.edu> | 2014-09-20 02:38:41 (GMT) |
commit | 81b062f63ace48983439857314fec8063e8c72e0 (patch) | |
tree | a03a857a0cafa21b3016064bb86881f5b0395ab9 /Lib/idlelib/PyShell.py | |
parent | cbfaa7b9d3174d6304ec3b5ab165b5c3514c5d34 (diff) | |
download | cpython-81b062f63ace48983439857314fec8063e8c72e0.zip cpython-81b062f63ace48983439857314fec8063e8c72e0.tar.gz cpython-81b062f63ace48983439857314fec8063e8c72e0.tar.bz2 |
Issue #22420: Avoid 'write to None' crashes by using print instead.
Change a couple of existing prints. Original patch by Serhiy Storchaka.
Diffstat (limited to 'Lib/idlelib/PyShell.py')
-rwxr-xr-x | Lib/idlelib/PyShell.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/Lib/idlelib/PyShell.py b/Lib/idlelib/PyShell.py index 8656927..7eab8d0 100755 --- a/Lib/idlelib/PyShell.py +++ b/Lib/idlelib/PyShell.py @@ -21,7 +21,7 @@ from platform import python_version, system try: from tkinter import * except ImportError: - print("** IDLE can't import Tkinter. " \ + print("** IDLE can't import Tkinter.\n" "Your Python may not be configured for Tk. **", file=sys.__stderr__) sys.exit(1) import tkinter.messagebox as tkMessageBox @@ -651,9 +651,9 @@ class ModifiedInterpreter(InteractiveInterpreter): code = compile(source, filename, "exec") except (OverflowError, SyntaxError): self.tkconsole.resetoutput() - tkerr = self.tkconsole.stderr - print('*** Error in script or command!\n', file=tkerr) - print('Traceback (most recent call last):', file=tkerr) + print('*** Error in script or command!\n' + 'Traceback (most recent call last):', + file=self.tkconsole.stderr) InteractiveInterpreter.showsyntaxerror(self, filename) self.tkconsole.showprompt() else: @@ -1472,8 +1472,7 @@ def main(): try: opts, args = getopt.getopt(sys.argv[1:], "c:deihnr:st:") except getopt.error as msg: - sys.stderr.write("Error: %s\n" % str(msg)) - sys.stderr.write(usage_msg) + print("Error: %s\n%s" % (msg, usage_msg), file=sys.stderr) sys.exit(2) for o, a in opts: if o == '-c': |