[Python-checkins] cpython (merge 3.4 -> default): Issue #22420: Merge with 3.4

terry.reedy python-checkins at python.org
Sat Sep 20 04:39:49 CEST 2014


https://hg.python.org/cpython/rev/ab050bd7e51c
changeset:   92482:ab050bd7e51c
parent:      92479:8b58be9f98a7
parent:      92481:42b03d5b1cbb
user:        Terry Jan Reedy <tjreedy at udel.edu>
date:        Fri Sep 19 22:39:09 2014 -0400
summary:
  Issue #22420: Merge with 3.4

files:
  Lib/idlelib/PyShell.py       |  11 +++++------
  Lib/idlelib/configHandler.py |  24 ++++++++++++------------
  2 files changed, 17 insertions(+), 18 deletions(-)


diff --git a/Lib/idlelib/PyShell.py b/Lib/idlelib/PyShell.py
--- a/Lib/idlelib/PyShell.py
+++ b/Lib/idlelib/PyShell.py
@@ -21,7 +21,7 @@
 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 @@
             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 @@
     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':
diff --git a/Lib/idlelib/configHandler.py b/Lib/idlelib/configHandler.py
--- a/Lib/idlelib/configHandler.py
+++ b/Lib/idlelib/configHandler.py
@@ -203,9 +203,9 @@
         if userDir != '~': # expanduser() found user home dir
             if not os.path.exists(userDir):
                 warn = ('\n Warning: os.path.expanduser("~") points to\n '+
-                        userDir+',\n but the path does not exist.\n')
+                        userDir+',\n but the path does not exist.')
                 try:
-                    sys.stderr.write(warn)
+                    print(warn, file=sys.stderr)
                 except OSError:
                     pass
                 userDir = '~'
@@ -218,8 +218,8 @@
                 os.mkdir(userDir)
             except OSError:
                 warn = ('\n Warning: unable to create user config directory\n'+
-                        userDir+'\n Check path and permissions.\n Exiting!\n\n')
-                sys.stderr.write(warn)
+                        userDir+'\n Check path and permissions.\n Exiting!\n')
+                print(warn, file=sys.stderr)
                 raise SystemExit
         return userDir
 
@@ -244,12 +244,12 @@
         except ValueError:
             warning = ('\n Warning: configHandler.py - IdleConf.GetOption -\n'
                        ' invalid %r value for configuration option %r\n'
-                       ' from section %r: %r\n' %
+                       ' from section %r: %r' %
                        (type, option, section,
                         self.userCfg[configType].Get(section, option,
                                                      raw=raw)))
             try:
-                sys.stderr.write(warning)
+                print(warning, file=sys.stderr)
             except OSError:
                 pass
         try:
@@ -263,10 +263,10 @@
             warning = ('\n Warning: configHandler.py - IdleConf.GetOption -\n'
                        ' problem retrieving configuration option %r\n'
                        ' from section %r.\n'
-                       ' returning default value: %r\n' %
+                       ' returning default value: %r' %
                        (option, section, default))
             try:
-                sys.stderr.write(warning)
+                print(warning, file=sys.stderr)
             except OSError:
                 pass
         return default
@@ -375,10 +375,10 @@
                 warning=('\n Warning: configHandler.py - IdleConf.GetThemeDict'
                            ' -\n problem retrieving theme element %r'
                            '\n from theme %r.\n'
-                           ' returning default value: %r\n' %
+                           ' returning default value: %r' %
                            (element, themeName, theme[element]))
                 try:
-                    sys.stderr.write(warning)
+                    print(warning, file=sys.stderr)
                 except OSError:
                     pass
             colour=cfgParser.Get(themeName,element,default=theme[element])
@@ -635,10 +635,10 @@
                     warning=('\n Warning: configHandler.py - IdleConf.GetCoreKeys'
                                ' -\n problem retrieving key binding for event %r'
                                '\n from key set %r.\n'
-                               ' returning default value: %r\n' %
+                               ' returning default value: %r' %
                                (event, keySetName, keyBindings[event]))
                     try:
-                        sys.stderr.write(warning)
+                        print(warning, file=sys.stderr)
                     except OSError:
                         pass
         return keyBindings

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list