diff options
Diffstat (limited to 'Lib/idlelib')
-rw-r--r-- | Lib/idlelib/CallTips.py | 6 | ||||
-rw-r--r-- | Lib/idlelib/ColorDelegator.py | 32 | ||||
-rw-r--r-- | Lib/idlelib/Delegator.py | 2 | ||||
-rw-r--r-- | Lib/idlelib/EditorWindow.py | 4 | ||||
-rw-r--r-- | Lib/idlelib/FileList.py | 4 | ||||
-rw-r--r-- | Lib/idlelib/GrepDialog.py | 12 | ||||
-rw-r--r-- | Lib/idlelib/MultiCall.py | 2 | ||||
-rw-r--r-- | Lib/idlelib/Percolator.py | 4 | ||||
-rw-r--r-- | Lib/idlelib/PyShell.py | 19 | ||||
-rw-r--r-- | Lib/idlelib/ScrolledList.py | 4 | ||||
-rw-r--r-- | Lib/idlelib/UndoDelegator.py | 8 | ||||
-rw-r--r-- | Lib/idlelib/WidgetRedirector.py | 2 | ||||
-rw-r--r-- | Lib/idlelib/WindowList.py | 2 | ||||
-rw-r--r-- | Lib/idlelib/configHandler.py | 14 | ||||
-rw-r--r-- | Lib/idlelib/configHelpSourceEdit.py | 2 | ||||
-rw-r--r-- | Lib/idlelib/configSectionNameDialog.py | 2 | ||||
-rw-r--r-- | Lib/idlelib/keybindingDialog.py | 2 | ||||
-rw-r--r-- | Lib/idlelib/rpc.py | 30 | ||||
-rw-r--r-- | Lib/idlelib/run.py | 28 |
19 files changed, 89 insertions, 90 deletions
diff --git a/Lib/idlelib/CallTips.py b/Lib/idlelib/CallTips.py index 997eb13a0f..1ffbc162db 100644 --- a/Lib/idlelib/CallTips.py +++ b/Lib/idlelib/CallTips.py @@ -201,9 +201,9 @@ if __name__=='__main__': arg_text = ct.fetch_tip(name) if arg_text != expected: failed.append(t) - print "%s - expected %s, but got %s" % (t, expected, - get_arg_text(entity)) - print "%d of %d tests failed" % (len(failed), len(tests)) + print("%s - expected %s, but got %s" % (t, expected, + get_arg_text(entity))) + print("%d of %d tests failed" % (len(failed), len(tests))) tc = TC() tests = (t1, t2, t3, t4, t5, t6, diff --git a/Lib/idlelib/ColorDelegator.py b/Lib/idlelib/ColorDelegator.py index 4cfcdc6353..5328d41196 100644 --- a/Lib/idlelib/ColorDelegator.py +++ b/Lib/idlelib/ColorDelegator.py @@ -72,7 +72,7 @@ class ColorDelegator(Delegator): "hit": idleConf.GetHighlight(theme, "hit"), } - if DEBUG: print 'tagdefs',self.tagdefs + if DEBUG: print('tagdefs',self.tagdefs) def insert(self, index, chars, tags=None): index = self.index(index) @@ -91,13 +91,13 @@ class ColorDelegator(Delegator): def notify_range(self, index1, index2=None): self.tag_add("TODO", index1, index2) if self.after_id: - if DEBUG: print "colorizing already scheduled" + if DEBUG: print("colorizing already scheduled") return if self.colorizing: self.stop_colorizing = True - if DEBUG: print "stop colorizing" + if DEBUG: print("stop colorizing") if self.allow_colorizing: - if DEBUG: print "schedule colorizing" + if DEBUG: print("schedule colorizing") self.after_id = self.after(1, self.recolorize) close_when_done = None # Window to be closed when done colorizing @@ -106,7 +106,7 @@ class ColorDelegator(Delegator): if self.after_id: after_id = self.after_id self.after_id = None - if DEBUG: print "cancel scheduled recolorizer" + if DEBUG: print("cancel scheduled recolorizer") self.after_cancel(after_id) self.allow_colorizing = False self.stop_colorizing = True @@ -120,42 +120,42 @@ class ColorDelegator(Delegator): if self.after_id: after_id = self.after_id self.after_id = None - if DEBUG: print "cancel scheduled recolorizer" + if DEBUG: print("cancel scheduled recolorizer") self.after_cancel(after_id) if self.allow_colorizing and self.colorizing: - if DEBUG: print "stop colorizing" + if DEBUG: print("stop colorizing") self.stop_colorizing = True self.allow_colorizing = not self.allow_colorizing if self.allow_colorizing and not self.colorizing: self.after_id = self.after(1, self.recolorize) if DEBUG: - print "auto colorizing turned",\ - self.allow_colorizing and "on" or "off" + print("auto colorizing turned",\ + self.allow_colorizing and "on" or "off") return "break" def recolorize(self): self.after_id = None if not self.delegate: - if DEBUG: print "no delegate" + if DEBUG: print("no delegate") return if not self.allow_colorizing: - if DEBUG: print "auto colorizing is off" + if DEBUG: print("auto colorizing is off") return if self.colorizing: - if DEBUG: print "already colorizing" + if DEBUG: print("already colorizing") return try: self.stop_colorizing = False self.colorizing = True - if DEBUG: print "colorizing..." + if DEBUG: print("colorizing...") t0 = time.clock() self.recolorize_main() t1 = time.clock() - if DEBUG: print "%.3f seconds" % (t1-t0) + if DEBUG: print("%.3f seconds" % (t1-t0)) finally: self.colorizing = False if self.allow_colorizing and self.tag_nextrange("TODO", "1.0"): - if DEBUG: print "reschedule colorizing" + if DEBUG: print("reschedule colorizing") self.after_id = self.after(1, self.recolorize) if self.close_when_done: top = self.close_when_done @@ -240,7 +240,7 @@ class ColorDelegator(Delegator): self.tag_add("TODO", next) self.update() if self.stop_colorizing: - if DEBUG: print "colorizing stopped" + if DEBUG: print("colorizing stopped") return def removecolors(self): diff --git a/Lib/idlelib/Delegator.py b/Lib/idlelib/Delegator.py index 6125591fe0..cc6266126e 100644 --- a/Lib/idlelib/Delegator.py +++ b/Lib/idlelib/Delegator.py @@ -23,7 +23,7 @@ class Delegator: def cachereport(self): keys = self.__cache.keys() keys.sort() - print keys + print(keys) def setdelegate(self, delegate): self.resetcache() diff --git a/Lib/idlelib/EditorWindow.py b/Lib/idlelib/EditorWindow.py index 396e2bdb65..7cd6c1f379 100644 --- a/Lib/idlelib/EditorWindow.py +++ b/Lib/idlelib/EditorWindow.py @@ -859,7 +859,7 @@ class EditorWindow(object): try: self.load_extension(name) except: - print "Failed to load extension", repr(name) + print("Failed to load extension", repr(name)) import traceback traceback.print_exc() @@ -870,7 +870,7 @@ class EditorWindow(object): try: mod = __import__(name, globals(), locals(), []) except ImportError: - print "\nFailed to import extension: ", name + print("\nFailed to import extension: ", name) return cls = getattr(mod, name) keydefs = idleConf.GetExtensionBindings(name) diff --git a/Lib/idlelib/FileList.py b/Lib/idlelib/FileList.py index 2ef0640c0d..9c6fafeaa4 100644 --- a/Lib/idlelib/FileList.py +++ b/Lib/idlelib/FileList.py @@ -54,7 +54,7 @@ class FileList: try: key = self.inversedict[edit] except KeyError: - print "Don't know this EditorWindow object. (close)" + print("Don't know this EditorWindow object. (close)") return if key: del self.dict[key] @@ -67,7 +67,7 @@ class FileList: try: key = self.inversedict[edit] except KeyError: - print "Don't know this EditorWindow object. (rename)" + print("Don't know this EditorWindow object. (rename)") return filename = edit.io.filename if not filename: diff --git a/Lib/idlelib/GrepDialog.py b/Lib/idlelib/GrepDialog.py index 99d2e4dabc..c96fada305 100644 --- a/Lib/idlelib/GrepDialog.py +++ b/Lib/idlelib/GrepDialog.py @@ -77,13 +77,13 @@ class GrepDialog(SearchDialogBase): list.sort() self.close() pat = self.engine.getpat() - print "Searching %r in %s ..." % (pat, path) + print("Searching %r in %s ..." % (pat, path)) hits = 0 for fn in list: try: f = open(fn) except IOError as msg: - print msg + print(msg) continue lineno = 0 while 1: @@ -102,16 +102,16 @@ class GrepDialog(SearchDialogBase): s = "" else: s = "s" - print "Found", hits, "hit%s." % s - print "(Hint: right-click to open locations.)" + print("Found", hits, "hit%s." % s) + print("(Hint: right-click to open locations.)") else: - print "No hits." + print("No hits.") def findfiles(self, dir, base, rec): try: names = os.listdir(dir or os.curdir) except os.error as msg: - print msg + print(msg) return [] list = [] subdirs = [] diff --git a/Lib/idlelib/MultiCall.py b/Lib/idlelib/MultiCall.py index 40db92db73..1bb1576853 100644 --- a/Lib/idlelib/MultiCall.py +++ b/Lib/idlelib/MultiCall.py @@ -388,7 +388,7 @@ if __name__ == "__main__": text.pack() def bindseq(seq, n=[0]): def handler(event): - print seq + print(seq) text.bind("<<handler%d>>"%n[0], handler) text.event_add("<<handler%d>>"%n[0], seq) n[0] += 1 diff --git a/Lib/idlelib/Percolator.py b/Lib/idlelib/Percolator.py index ebbcba9e6a..a0b1303792 100644 --- a/Lib/idlelib/Percolator.py +++ b/Lib/idlelib/Percolator.py @@ -58,10 +58,10 @@ def main(): self.name = name Delegator.__init__(self, None) def insert(self, *args): - print self.name, ": insert", args + print(self.name, ": insert", args) self.delegate.insert(*args) def delete(self, *args): - print self.name, ": delete", args + print(self.name, ": delete", args) self.delegate.delete(*args) root = Tk() root.wm_protocol("WM_DELETE_WINDOW", root.quit) diff --git a/Lib/idlelib/PyShell.py b/Lib/idlelib/PyShell.py index 46ef211c05..e8284d81fc 100644 --- a/Lib/idlelib/PyShell.py +++ b/Lib/idlelib/PyShell.py @@ -19,8 +19,8 @@ from code import InteractiveInterpreter try: from Tkinter import * except ImportError: - print>>sys.__stderr__, "** IDLE can't import Tkinter. " \ - "Your Python may not be configured for Tk. **" + print("** IDLE can't import Tkinter. " \ + "Your Python may not be configured for Tk. **", file=sys.__stderr__) sys.exit(1) import tkMessageBox @@ -504,14 +504,14 @@ class ModifiedInterpreter(InteractiveInterpreter): console = self.tkconsole.console if how == "OK": if what is not None: - print >>console, repr(what) + print(repr(what), file=console) elif how == "EXCEPTION": if self.tkconsole.getvar("<<toggle-jit-stack-viewer>>"): self.remote_stack_viewer() elif how == "ERROR": errmsg = "PyShell.ModifiedInterpreter: Subprocess ERROR:\n" - print >>sys.__stderr__, errmsg, what - print >>console, errmsg, what + print(errmsg, what, file=sys.__stderr__) + print(errmsg, what, file=console) # we received a response to the currently active seq number: try: self.tkconsole.endexecuting() @@ -576,8 +576,8 @@ class ModifiedInterpreter(InteractiveInterpreter): except (OverflowError, SyntaxError): self.tkconsole.resetoutput() tkerr = self.tkconsole.stderr - print>>tkerr, '*** Error in script or command!\n' - print>>tkerr, 'Traceback (most recent call last):' + print('*** Error in script or command!\n', file=tkerr) + print('Traceback (most recent call last):', file=tkerr) InteractiveInterpreter.showsyntaxerror(self, filename) self.tkconsole.showprompt() else: @@ -730,8 +730,7 @@ class ModifiedInterpreter(InteractiveInterpreter): if use_subprocess: # When run w/o subprocess, both user and IDLE errors # are printed here; skip message in that case. - print >> self.tkconsole.stderr, \ - "IDLE internal error in runcode()" + print("IDLE internal error in runcode()", file=self.tkconsole.stderr) self.showtraceback() if use_subprocess: self.tkconsole.endexecuting() @@ -1349,7 +1348,7 @@ def main(): if os.path.isfile(script): pass else: - print "No script file: ", script + print("No script file: ", script) sys.exit() enable_shell = True if o == '-s': diff --git a/Lib/idlelib/ScrolledList.py b/Lib/idlelib/ScrolledList.py index 9211936577..350fdbd5ba 100644 --- a/Lib/idlelib/ScrolledList.py +++ b/Lib/idlelib/ScrolledList.py @@ -124,8 +124,8 @@ def test(): root.protocol("WM_DELETE_WINDOW", root.destroy) class MyScrolledList(ScrolledList): def fill_menu(self): self.menu.add_command(label="pass") - def on_select(self, index): print "select", self.get(index) - def on_double(self, index): print "double", self.get(index) + def on_select(self, index): print("select", self.get(index)) + def on_double(self, index): print("double", self.get(index)) s = MyScrolledList(root) for i in range(30): s.append("item %02d" % i) diff --git a/Lib/idlelib/UndoDelegator.py b/Lib/idlelib/UndoDelegator.py index 182a1170e8..0f95b3bddc 100644 --- a/Lib/idlelib/UndoDelegator.py +++ b/Lib/idlelib/UndoDelegator.py @@ -38,10 +38,10 @@ class UndoDelegator(Delegator): def dump_event(self, event): from pprint import pprint pprint(self.undolist[:self.pointer]) - print "pointer:", self.pointer, - print "saved:", self.saved, - print "can_merge:", self.can_merge, - print "get_saved():", self.get_saved() + print("pointer:", self.pointer, end=' ') + print("saved:", self.saved, end=' ') + print("can_merge:", self.can_merge, end=' ') + print("get_saved():", self.get_saved()) pprint(self.undolist[self.pointer:]) return "break" diff --git a/Lib/idlelib/WidgetRedirector.py b/Lib/idlelib/WidgetRedirector.py index 126a2cd672..59005b8708 100644 --- a/Lib/idlelib/WidgetRedirector.py +++ b/Lib/idlelib/WidgetRedirector.py @@ -83,7 +83,7 @@ def main(): redir = WidgetRedirector(text) global orig_insert def my_insert(*args): - print "insert", args + print("insert", args) orig_insert(*args) orig_insert = redir.register("insert", my_insert) root.mainloop() diff --git a/Lib/idlelib/WindowList.py b/Lib/idlelib/WindowList.py index 2fad998da1..fc463b804a 100644 --- a/Lib/idlelib/WindowList.py +++ b/Lib/idlelib/WindowList.py @@ -46,7 +46,7 @@ class WindowList: callback() except: t, v, tb = sys.exc_info() - print "warning: callback failed in WindowList", t, ":", v + print("warning: callback failed in WindowList", t, ":", v) registry = WindowList() diff --git a/Lib/idlelib/configHandler.py b/Lib/idlelib/configHandler.py index 826fb5dbb8..469d0e4868 100644 --- a/Lib/idlelib/configHandler.py +++ b/Lib/idlelib/configHandler.py @@ -679,18 +679,18 @@ idleConf=IdleConf() ### module test if __name__ == '__main__': def dumpCfg(cfg): - print '\n',cfg,'\n' + print('\n',cfg,'\n') for key in cfg.keys(): sections=cfg[key].sections() - print key - print sections + print(key) + print(sections) for section in sections: options=cfg[key].options(section) - print section - print options + print(section) + print(options) for option in options: - print option, '=', cfg[key].Get(section,option) + print(option, '=', cfg[key].Get(section,option)) dumpCfg(idleConf.defaultCfg) dumpCfg(idleConf.userCfg) - print idleConf.userCfg['main'].Get('Theme','name') + print(idleConf.userCfg['main'].Get('Theme','name')) #print idleConf.userCfg['highlight'].GetDefHighlight('Foo','normal') diff --git a/Lib/idlelib/configHelpSourceEdit.py b/Lib/idlelib/configHelpSourceEdit.py index 661162196c..912a441698 100644 --- a/Lib/idlelib/configHelpSourceEdit.py +++ b/Lib/idlelib/configHelpSourceEdit.py @@ -164,6 +164,6 @@ if __name__ == '__main__': def run(): keySeq = '' dlg = GetHelpSourceDialog(root, 'Get Help Source') - print dlg.result + print(dlg.result) Button(root,text='Dialog', command=run).pack() root.mainloop() diff --git a/Lib/idlelib/configSectionNameDialog.py b/Lib/idlelib/configSectionNameDialog.py index 4f1b002afc..21dfab12ce 100644 --- a/Lib/idlelib/configSectionNameDialog.py +++ b/Lib/idlelib/configSectionNameDialog.py @@ -92,6 +92,6 @@ if __name__ == '__main__': keySeq='' dlg=GetCfgSectionNameDialog(root,'Get Name', 'The information here should need to be word wrapped. Test.') - print dlg.result + print(dlg.result) Button(root,text='Dialog',command=run).pack() root.mainloop() diff --git a/Lib/idlelib/keybindingDialog.py b/Lib/idlelib/keybindingDialog.py index aff9cac587..69900f9fbd 100644 --- a/Lib/idlelib/keybindingDialog.py +++ b/Lib/idlelib/keybindingDialog.py @@ -263,6 +263,6 @@ if __name__ == '__main__': def run(): keySeq='' dlg=GetKeysDialog(root,'Get Keys','find-again',[]) - print dlg.result + print(dlg.result) Button(root,text='Dialog',command=run).pack() root.mainloop() diff --git a/Lib/idlelib/rpc.py b/Lib/idlelib/rpc.py index e3a42d943a..169bcebcc5 100644 --- a/Lib/idlelib/rpc.py +++ b/Lib/idlelib/rpc.py @@ -104,14 +104,14 @@ class RPCServer(SocketServer.TCPServer): raise except: erf = sys.__stderr__ - print>>erf, '\n' + '-'*40 - print>>erf, 'Unhandled server exception!' - print>>erf, 'Thread: %s' % threading.currentThread().getName() - print>>erf, 'Client Address: ', client_address - print>>erf, 'Request: ', repr(request) + print('\n' + '-'*40, file=erf) + print('Unhandled server exception!', file=erf) + print('Thread: %s' % threading.currentThread().getName(), file=erf) + print('Client Address: ', client_address, file=erf) + print('Request: ', repr(request), file=erf) traceback.print_exc(file=erf) - print>>erf, '\n*** Unrecoverable, server exiting!' - print>>erf, '-'*40 + print('\n*** Unrecoverable, server exiting!', file=erf) + print('-'*40, file=erf) os._exit(0) #----------------- end class RPCServer -------------------- @@ -152,7 +152,7 @@ class SocketIO(object): s = self.location + " " + str(threading.currentThread().getName()) for a in args: s = s + " " + str(a) - print>>sys.__stderr__, s + print(s, file=sys.__stderr__) def register(self, oid, object): self.objtable[oid] = object @@ -201,7 +201,7 @@ class SocketIO(object): except: msg = "*** Internal Error: rpc.py:SocketIO.localcall()\n\n"\ " Object: %s \n Method: %s \n Args: %s\n" - print>>sys.__stderr__, msg % (oid, method, args) + print(msg % (oid, method, args), file=sys.__stderr__) traceback.print_exc(file=sys.__stderr__) return ("EXCEPTION", None) @@ -323,7 +323,7 @@ class SocketIO(object): try: s = pickle.dumps(message) except pickle.PicklingError: - print >>sys.__stderr__, "Cannot pickle:", repr(message) + print("Cannot pickle:", repr(message), file=sys.__stderr__) raise s = struct.pack("<i", len(s)) + s while len(s) > 0: @@ -379,10 +379,10 @@ class SocketIO(object): try: message = pickle.loads(packet) except pickle.UnpicklingError: - print >>sys.__stderr__, "-----------------------" - print >>sys.__stderr__, "cannot unpickle packet:", repr(packet) + print("-----------------------", file=sys.__stderr__) + print("cannot unpickle packet:", repr(packet), file=sys.__stderr__) traceback.print_stack(file=sys.__stderr__) - print >>sys.__stderr__, "-----------------------" + print("-----------------------", file=sys.__stderr__) raise return message @@ -526,11 +526,11 @@ class RPCClient(SocketIO): def accept(self): working_sock, address = self.listening_sock.accept() if self.debugging: - print>>sys.__stderr__, "****** Connection request from ", address + print("****** Connection request from ", address, file=sys.__stderr__) if address[0] == LOCALHOST: SocketIO.__init__(self, working_sock) else: - print>>sys.__stderr__, "** Invalid host: ", address + print("** Invalid host: ", address, file=sys.__stderr__) raise socket.error def get_remote_proxy(self, oid): diff --git a/Lib/idlelib/run.py b/Lib/idlelib/run.py index 6b29003f20..fa201a8d21 100644 --- a/Lib/idlelib/run.py +++ b/Lib/idlelib/run.py @@ -115,11 +115,11 @@ def manage_socket(address): server = MyRPCServer(address, MyHandler) break except socket.error as err: - print>>sys.__stderr__,"IDLE Subprocess: socket error: "\ - + err[1] + ", retrying...." + print("IDLE Subprocess: socket error: "\ + + err[1] + ", retrying....", file=sys.__stderr__) else: - print>>sys.__stderr__, "IDLE Subprocess: Connection to "\ - "IDLE GUI failed, exiting." + print("IDLE Subprocess: Connection to "\ + "IDLE GUI failed, exiting.", file=sys.__stderr__) show_socket_error(err, address) global exit_now exit_now = True @@ -149,14 +149,14 @@ def print_exception(): typ, val, tb = excinfo = sys.exc_info() sys.last_type, sys.last_value, sys.last_traceback = excinfo tbe = traceback.extract_tb(tb) - print>>efile, '\nTraceback (most recent call last):' + print('\nTraceback (most recent call last):', file=efile) exclude = ("run.py", "rpc.py", "threading.py", "Queue.py", "RemoteDebugger.py", "bdb.py") cleanup_traceback(tbe, exclude) traceback.print_list(tbe, file=efile) lines = traceback.format_exception_only(typ, val) for line in lines: - print>>efile, line, + print(line, end=' ', file=efile) def cleanup_traceback(tb, exclude): "Remove excluded traces from beginning/end of tb; get cached lines" @@ -178,7 +178,7 @@ def cleanup_traceback(tb, exclude): if len(tb) == 0: # exception was in IDLE internals, don't prune! tb[:] = orig_tb[:] - print>>sys.stderr, "** IDLE Internal Exception: " + print("** IDLE Internal Exception: ", file=sys.stderr) rpchandler = rpc.objecttable['exec'].rpchandler for i in range(len(tb)): fn, ln, nm, line = tb[i] @@ -227,14 +227,14 @@ class MyRPCServer(rpc.RPCServer): thread.interrupt_main() except: erf = sys.__stderr__ - print>>erf, '\n' + '-'*40 - print>>erf, 'Unhandled server exception!' - print>>erf, 'Thread: %s' % threading.currentThread().getName() - print>>erf, 'Client Address: ', client_address - print>>erf, 'Request: ', repr(request) + print('\n' + '-'*40, file=erf) + print('Unhandled server exception!', file=erf) + print('Thread: %s' % threading.currentThread().getName(), file=erf) + print('Client Address: ', client_address, file=erf) + print('Request: ', repr(request), file=erf) traceback.print_exc(file=erf) - print>>erf, '\n*** Unrecoverable, server exiting!' - print>>erf, '-'*40 + print('\n*** Unrecoverable, server exiting!', file=erf) + print('-'*40, file=erf) quitting = True thread.interrupt_main() |