diff options
author | Walter Dörwald <walter@livinglogic.de> | 2004-02-12 17:35:32 (GMT) |
---|---|---|
committer | Walter Dörwald <walter@livinglogic.de> | 2004-02-12 17:35:32 (GMT) |
commit | 70a6b49821a3226f55e9716f32d802d06640cb89 (patch) | |
tree | 3c8ca10c1fa09e025bd266cf855a00d7d96c55aa /Lib/idlelib | |
parent | ecfeb7f095dfd9c1c8929bf3df858ee35e0d9e9e (diff) | |
download | cpython-70a6b49821a3226f55e9716f32d802d06640cb89.zip cpython-70a6b49821a3226f55e9716f32d802d06640cb89.tar.gz cpython-70a6b49821a3226f55e9716f32d802d06640cb89.tar.bz2 |
Replace backticks with repr() or "%r"
From SF patch #852334.
Diffstat (limited to 'Lib/idlelib')
-rw-r--r-- | Lib/idlelib/ColorDelegator.py | 2 | ||||
-rw-r--r-- | Lib/idlelib/EditorWindow.py | 10 | ||||
-rw-r--r-- | Lib/idlelib/FileList.py | 6 | ||||
-rw-r--r-- | Lib/idlelib/GrepDialog.py | 2 | ||||
-rw-r--r-- | Lib/idlelib/ObjectBrowser.py | 2 | ||||
-rw-r--r-- | Lib/idlelib/ParenMatch.py | 2 | ||||
-rw-r--r-- | Lib/idlelib/PyShell.py | 18 | ||||
-rw-r--r-- | Lib/idlelib/RemoteDebugger.py | 4 | ||||
-rw-r--r-- | Lib/idlelib/ScriptBinding.py | 6 | ||||
-rw-r--r-- | Lib/idlelib/TreeWidget.py | 2 | ||||
-rw-r--r-- | Lib/idlelib/UndoDelegator.py | 4 | ||||
-rw-r--r-- | Lib/idlelib/WidgetRedirector.py | 2 | ||||
-rw-r--r-- | Lib/idlelib/aboutDialog.py | 5 | ||||
-rw-r--r-- | Lib/idlelib/configDialog.py | 4 | ||||
-rw-r--r-- | Lib/idlelib/configHandler.py | 27 | ||||
-rw-r--r-- | Lib/idlelib/rpc.py | 10 | ||||
-rw-r--r-- | Lib/idlelib/textView.py | 2 |
17 files changed, 55 insertions, 53 deletions
diff --git a/Lib/idlelib/ColorDelegator.py b/Lib/idlelib/ColorDelegator.py index d72d90c..7b7be22 100644 --- a/Lib/idlelib/ColorDelegator.py +++ b/Lib/idlelib/ColorDelegator.py @@ -182,7 +182,7 @@ class ColorDelegator(Delegator): lines_to_get = min(lines_to_get * 2, 100) ok = "SYNC" in self.tag_names(next + "-1c") line = self.get(mark, next) - ##print head, "get", mark, next, "->", `line` + ##print head, "get", mark, next, "->", repr(line) if not line: return for tag in self.tagdefs.keys(): diff --git a/Lib/idlelib/EditorWindow.py b/Lib/idlelib/EditorWindow.py index 0f0961c..65ffe54 100644 --- a/Lib/idlelib/EditorWindow.py +++ b/Lib/idlelib/EditorWindow.py @@ -761,7 +761,7 @@ class EditorWindow: try: self.load_extension(name) except: - print "Failed to load extension", `name` + print "Failed to load extension", repr(name) import traceback traceback.print_exc() @@ -937,7 +937,7 @@ class EditorWindow: elif key == 'context_use_ps1': self.context_use_ps1 = value else: - raise KeyError, "bad option name: %s" % `key` + raise KeyError, "bad option name: %r" % (key,) # If ispythonsource and guess are true, guess a good value for # indentwidth based on file content (if possible), and if @@ -1071,7 +1071,7 @@ class EditorWindow: y = PyParse.Parser(self.indentwidth, self.tabwidth) for context in self.num_context_lines: startat = max(lno - context, 1) - startatindex = `startat` + ".0" + startatindex = repr(startat) + ".0" rawtext = text.get(startatindex, "insert") y.set_str(rawtext) bod = y.find_good_parse_start( @@ -1103,7 +1103,7 @@ class EditorWindow: else: self.reindent_to(y.compute_backslash_indent()) else: - assert 0, "bogus continuation type " + `c` + assert 0, "bogus continuation type %r" % (c,) return "break" # This line starts a brand new stmt; indent relative to @@ -1333,7 +1333,7 @@ class IndentSearcher: if self.finished: return "" i = self.i = self.i + 1 - mark = `i` + ".0" + mark = repr(i) + ".0" if self.text.compare(mark, ">=", "end"): return "" return self.text.get(mark, mark + " lineend+1c") diff --git a/Lib/idlelib/FileList.py b/Lib/idlelib/FileList.py index 4e08e70..198055a 100644 --- a/Lib/idlelib/FileList.py +++ b/Lib/idlelib/FileList.py @@ -35,7 +35,7 @@ class FileList: if os.path.isdir(filename): tkMessageBox.showerror( "Is A Directory", - "The path %s is a directory." % `filename`, + "The path %r is a directory." % (filename,), master=self.root) return None key = os.path.normcase(filename) @@ -46,7 +46,7 @@ class FileList: if not os.path.exists(filename): tkMessageBox.showinfo( "New File", - "Opening non-existent file %s" % `filename`, + "Opening non-existent file %r" % (filename,), master=self.root) if action is None: return self.EditorWindow(self, filename, key) @@ -102,7 +102,7 @@ class FileList: self.inversedict[conflict] = None tkMessageBox.showerror( "Name Conflict", - "You now have multiple edit windows open for %s" % `filename`, + "You now have multiple edit windows open for %r" % (filename,), master=self.root) self.dict[newkey] = edit self.inversedict[edit] = newkey diff --git a/Lib/idlelib/GrepDialog.py b/Lib/idlelib/GrepDialog.py index 79fad31..ab136bc 100644 --- a/Lib/idlelib/GrepDialog.py +++ b/Lib/idlelib/GrepDialog.py @@ -77,7 +77,7 @@ class GrepDialog(SearchDialogBase): list.sort() self.close() pat = self.engine.getpat() - print "Searching %s in %s ..." % (`pat`, path) + print "Searching %r in %s ..." % (pat, path) hits = 0 for fn in list: try: diff --git a/Lib/idlelib/ObjectBrowser.py b/Lib/idlelib/ObjectBrowser.py index 416be5a..a2a6cee 100644 --- a/Lib/idlelib/ObjectBrowser.py +++ b/Lib/idlelib/ObjectBrowser.py @@ -97,7 +97,7 @@ class SequenceTreeItem(ObjectTreeItem): continue def setfunction(value, key=key, object=self.object): object[key] = value - item = make_objecttreeitem(`key` + ":", value, setfunction) + item = make_objecttreeitem("%r:" % (key,), value, setfunction) sublist.append(item) return sublist diff --git a/Lib/idlelib/ParenMatch.py b/Lib/idlelib/ParenMatch.py index bd4e077..407f468 100644 --- a/Lib/idlelib/ParenMatch.py +++ b/Lib/idlelib/ParenMatch.py @@ -142,7 +142,7 @@ class LastOpenBracketFinder: y = PyParse.Parser(self.indentwidth, self.tabwidth) for context in self.num_context_lines: startat = max(lno - context, 1) - startatindex = `startat` + ".0" + startatindex = repr(startat) + ".0" # rawtext needs to contain everything up to the last # character, which was the close paren. the parser also # requires that the last line ends with "\n" diff --git a/Lib/idlelib/PyShell.py b/Lib/idlelib/PyShell.py index 0605285..c619b7f 100644 --- a/Lib/idlelib/PyShell.py +++ b/Lib/idlelib/PyShell.py @@ -335,9 +335,9 @@ class ModifiedInterpreter(InteractiveInterpreter): del_exitf = idleConf.GetOption('main', 'General', 'delete-exitfunc', default=False, type='bool') if __name__ == 'idlelib.PyShell': - command = "__import__('idlelib.run').run.main(" + `del_exitf` +")" + command = "__import__('idlelib.run').run.main(%r)" % (del_exitf,) else: - command = "__import__('run').main(" + `del_exitf` + ")" + command = "__import__('run').main(%r)" % (del_exitf,) if sys.platform[:3] == 'win' and ' ' in sys.executable: # handle embedded space in path by quoting the argument decorated_exec = '"%s"' % sys.executable @@ -454,12 +454,12 @@ class ModifiedInterpreter(InteractiveInterpreter): def transfer_path(self): self.runcommand("""if 1: import sys as _sys - _sys.path = %s + _sys.path = %r del _sys _msg = 'Use File/Exit or your end-of-file key to quit IDLE' __builtins__.quit = __builtins__.exit = _msg del _msg - \n""" % `sys.path`) + \n""" % (sys.path,)) active_seq = None @@ -483,7 +483,7 @@ class ModifiedInterpreter(InteractiveInterpreter): console = self.tkconsole.console if how == "OK": if what is not None: - print >>console, `what` + print >>console, repr(what) elif how == "EXCEPTION": if self.tkconsole.getvar("<<toggle-jit-stack-viewer>>"): self.remote_stack_viewer() @@ -589,14 +589,14 @@ class ModifiedInterpreter(InteractiveInterpreter): def prepend_syspath(self, filename): "Prepend sys.path with file's directory if not already included" self.runcommand("""if 1: - _filename = %s + _filename = %r import sys as _sys from os.path import dirname as _dirname _dir = _dirname(_filename) if not _dir in _sys.path: _sys.path.insert(0, _dir) del _filename, _sys, _dirname, _dir - \n""" % `filename`) + \n""" % (filename,)) def showsyntaxerror(self, filename=None): """Extend base class method: Add Colorizing @@ -1333,9 +1333,9 @@ def main(): if shell and cmd or script: shell.interp.runcommand("""if 1: import sys as _sys - _sys.argv = %s + _sys.argv = %r del _sys - \n""" % `sys.argv`) + \n""" % (sys.argv,)) if cmd: shell.interp.execsource(cmd) elif script: diff --git a/Lib/idlelib/RemoteDebugger.py b/Lib/idlelib/RemoteDebugger.py index bdcef51..74085c3 100644 --- a/Lib/idlelib/RemoteDebugger.py +++ b/Lib/idlelib/RemoteDebugger.py @@ -94,7 +94,7 @@ class IdbAdapter: self.idb.set_return(frame) def get_stack(self, fid, tbid): - ##print >>sys.__stderr__, "get_stack(%s, %s)" % (`fid`, `tbid`) + ##print >>sys.__stderr__, "get_stack(%r, %r)" % (fid, tbid) frame = frametable[fid] if tbid is None: tb = None @@ -295,7 +295,7 @@ class IdbProxy: def call(self, methodname, *args, **kwargs): ##print "**IdbProxy.call %s %s %s" % (methodname, args, kwargs) value = self.conn.remotecall(self.oid, methodname, args, kwargs) - ##print "**IdbProxy.call %s returns %s" % (methodname, `value`) + ##print "**IdbProxy.call %s returns %r" % (methodname, value) return value def run(self, cmd, locals): diff --git a/Lib/idlelib/ScriptBinding.py b/Lib/idlelib/ScriptBinding.py index c0fa88f..a1d937b 100644 --- a/Lib/idlelib/ScriptBinding.py +++ b/Lib/idlelib/ScriptBinding.py @@ -145,16 +145,16 @@ class ScriptBinding: dirname = os.path.dirname(filename) # XXX Too often this discards arguments the user just set... interp.runcommand("""if 1: - _filename = %s + _filename = %r import sys as _sys from os.path import basename as _basename if (not _sys.argv or _basename(_sys.argv[0]) != _basename(_filename)): _sys.argv = [_filename] import os as _os - _os.chdir(%s) + _os.chdir(%r) del _filename, _sys, _basename, _os - \n""" % (`filename`, `dirname`)) + \n""" % (filename, dirname)) interp.prepend_syspath(filename) interp.runcode(code) diff --git a/Lib/idlelib/TreeWidget.py b/Lib/idlelib/TreeWidget.py index 824bdca..1c9eb2e 100644 --- a/Lib/idlelib/TreeWidget.py +++ b/Lib/idlelib/TreeWidget.py @@ -31,7 +31,7 @@ except NameError: if os.path.isdir(_icondir): ICONDIR = _icondir elif not os.path.isdir(ICONDIR): - raise RuntimeError, "can't find icon directory (%s)" % `ICONDIR` + raise RuntimeError, "can't find icon directory (%r)" % (ICONDIR,) def listicons(icondir=ICONDIR): """Utility to display the available icons.""" diff --git a/Lib/idlelib/UndoDelegator.py b/Lib/idlelib/UndoDelegator.py index 2452a98..182a117 100644 --- a/Lib/idlelib/UndoDelegator.py +++ b/Lib/idlelib/UndoDelegator.py @@ -177,7 +177,7 @@ class Command: t = (self.index1, self.index2, self.chars, self.tags) if self.tags is None: t = t[:-1] - return s + `t` + return s + repr(t) def do(self, text): pass @@ -310,7 +310,7 @@ class CommandSequence(Command): s = self.__class__.__name__ strs = [] for cmd in self.cmds: - strs.append(" " + `cmd`) + strs.append(" %r" % (cmd,)) return s + "(\n" + ",\n".join(strs) + "\n)" def __len__(self): diff --git a/Lib/idlelib/WidgetRedirector.py b/Lib/idlelib/WidgetRedirector.py index be74668f..df60cea 100644 --- a/Lib/idlelib/WidgetRedirector.py +++ b/Lib/idlelib/WidgetRedirector.py @@ -69,7 +69,7 @@ class OriginalCommand: self.orig_and_name = (self.orig, self.name) def __repr__(self): - return "OriginalCommand(%s, %s)" % (`self.redir`, `self.name`) + return "OriginalCommand(%r, %r)" % (self.redir, self.name) def __call__(self, *args): return self.tk_call(self.orig_and_name + args) diff --git a/Lib/idlelib/aboutDialog.py b/Lib/idlelib/aboutDialog.py index 3d2bcf6..c121061 100644 --- a/Lib/idlelib/aboutDialog.py +++ b/Lib/idlelib/aboutDialog.py @@ -66,7 +66,7 @@ class AboutDialog(Toplevel): sys.version.split()[0], fg=self.fg, bg=self.bg) labelPythonVer.grid(row=9, column=0, sticky=W, padx=10, pady=0) # handle weird tk version num in windoze python >= 1.6 (?!?) - tkVer = `TkVersion`.split('.') + tkVer = repr(TkVersion).split('.') tkVer[len(tkVer)-1] = str('%.3g' % (float('.'+tkVer[len(tkVer)-1])))[2:] if tkVer[len(tkVer)-1] == '': tkVer[len(tkVer)-1] = '0' @@ -141,8 +141,7 @@ class AboutDialog(Toplevel): except IOError: import tkMessageBox tkMessageBox.showerror(title='File Load Error', - message='Unable to load file '+ - `fn`+' .', + message='Unable to load file %r .' % (fn,), parent=self) return else: diff --git a/Lib/idlelib/configDialog.py b/Lib/idlelib/configDialog.py index 8c3eb3e..4e4e564 100644 --- a/Lib/idlelib/configDialog.py +++ b/Lib/idlelib/configDialog.py @@ -718,7 +718,7 @@ class ConfigDialog(Toplevel): def DeleteCustomKeys(self): keySetName=self.customKeys.get() if not tkMessageBox.askyesno('Delete Key Set','Are you sure you wish '+ - 'to delete the key set '+`keySetName`+' ?', + 'to delete the key set %r ?' % (keySetName), parent=self): return #remove key set from config @@ -745,7 +745,7 @@ class ConfigDialog(Toplevel): def DeleteCustomTheme(self): themeName=self.customTheme.get() if not tkMessageBox.askyesno('Delete Theme','Are you sure you wish '+ - 'to delete the theme '+`themeName`+' ?', + 'to delete the theme %r ?' % (themeName,), parent=self): return #remove theme from config diff --git a/Lib/idlelib/configHandler.py b/Lib/idlelib/configHandler.py index 3d79fb9..d1c2b3c 100644 --- a/Lib/idlelib/configHandler.py +++ b/Lib/idlelib/configHandler.py @@ -231,10 +231,11 @@ class IdleConf: elif self.defaultCfg[configType].has_option(section,option): return self.defaultCfg[configType].Get(section, option, type=type) else: #returning default, print warning - warning=('\n Warning: configHandler.py - IdleConf.GetOption -\n'+ - ' problem retrieving configration option '+`option`+'\n'+ - ' from section '+`section`+'.\n'+ - ' returning default value: '+`default`+'\n') + warning=('\n Warning: configHandler.py - IdleConf.GetOption -\n' + ' problem retrieving configration option %r\n' + ' from section %r.\n' + ' returning default value: %r\n' % + (option, section, default)) sys.stderr.write(warning) return default @@ -331,10 +332,11 @@ class IdleConf: for element in theme.keys(): if not cfgParser.has_option(themeName,element): #we are going to return a default, print warning - warning=('\n Warning: configHandler.py - IdleConf.GetThemeDict'+ - ' -\n problem retrieving theme element '+`element`+ - '\n from theme '+`themeName`+'.\n'+ - ' returning default value: '+`theme[element]`+'\n') + warning=('\n Warning: configHandler.py - IdleConf.GetThemeDict' + ' -\n problem retrieving theme element %r' + '\n from theme %r.\n' + ' returning default value: %r\n' % + (element, themeName, theme[element])) sys.stderr.write(warning) colour=cfgParser.Get(themeName,element,default=theme[element]) theme[element]=colour @@ -561,10 +563,11 @@ class IdleConf: if binding: keyBindings[event]=binding else: #we are going to return a default, print warning - warning=('\n Warning: configHandler.py - IdleConf.GetCoreKeys'+ - ' -\n problem retrieving key binding for event '+ - `event`+'\n from key set '+`keySetName`+'.\n'+ - ' returning default value: '+`keyBindings[event]`+'\n') + 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' % + (event, keySetName, keyBindings[event])) sys.stderr.write(warning) return keyBindings diff --git a/Lib/idlelib/rpc.py b/Lib/idlelib/rpc.py index d3a9fd8..d097f9b 100644 --- a/Lib/idlelib/rpc.py +++ b/Lib/idlelib/rpc.py @@ -58,7 +58,7 @@ def pickle_code(co): # def pickle_function(fn): # assert isinstance(fn, type.FunctionType) -# return `fn` +# return repr(fn) copy_reg.pickle(types.CodeType, pickle_code, unpickle_code) # copy_reg.pickle(types.FunctionType, pickle_function, unpickle_function) @@ -170,7 +170,7 @@ class SocketIO: except TypeError: return ("ERROR", "Bad request format") if not self.objtable.has_key(oid): - return ("ERROR", "Unknown object id: %s" % `oid`) + return ("ERROR", "Unknown object id: %r" % (oid,)) obj = self.objtable[oid] if methodname == "__methods__": methods = {} @@ -181,7 +181,7 @@ class SocketIO: _getattributes(obj, attributes) return ("OK", attributes) if not hasattr(obj, methodname): - return ("ERROR", "Unsupported method name: %s" % `methodname`) + return ("ERROR", "Unsupported method name: %r" % (methodname,)) method = getattr(obj, methodname) try: if how == 'CALL': @@ -321,7 +321,7 @@ class SocketIO: try: s = pickle.dumps(message) except pickle.PicklingError: - print >>sys.__stderr__, "Cannot pickle:", `message` + print >>sys.__stderr__, "Cannot pickle:", repr(message) raise s = struct.pack("<i", len(s)) + s while len(s) > 0: @@ -377,7 +377,7 @@ class SocketIO: message = pickle.loads(packet) except pickle.UnpicklingError: print >>sys.__stderr__, "-----------------------" - print >>sys.__stderr__, "cannot unpickle packet:", `packet` + print >>sys.__stderr__, "cannot unpickle packet:", repr(packet) traceback.print_stack(file=sys.__stderr__) print >>sys.__stderr__, "-----------------------" raise diff --git a/Lib/idlelib/textView.py b/Lib/idlelib/textView.py index be3ade0..917a6cc 100644 --- a/Lib/idlelib/textView.py +++ b/Lib/idlelib/textView.py @@ -46,7 +46,7 @@ class TextViewer(Toplevel): textFile = open(fileName, 'r') except IOError: tkMessageBox.showerror(title='File Load Error', - message='Unable to load file '+`fileName`+' .') + message='Unable to load file %r .' % (fileName,)) else: self.textView.insert(0.0,textFile.read()) |