Replace backticks with repr() or "%r"

From SF patch #852334.
diff --git a/Mac/Tools/IDE/FontSettings.py b/Mac/Tools/IDE/FontSettings.py
index a41fcbd..af2bd80 100644
--- a/Mac/Tools/IDE/FontSettings.py
+++ b/Mac/Tools/IDE/FontSettings.py
@@ -51,7 +51,7 @@
 			self.lasttab, self.tabmode = tabsettings
 			self.w.tabsizetitle = W.TextBox((10, -26, leftmargin2, 14), "Tabsize:", TextEdit.teJustRight)
 			self.w.tabsizeedit = W.EditText((leftmargin, -29, 40, 20), "", self.checktab)
-			self.w.tabsizeedit.set(`self.lasttab`)
+			self.w.tabsizeedit.set(repr(self.lasttab))
 			radiobuttons = []
 			self.w.tabsizechars = W.RadioButton((leftmargin + 48, -26, 55, 14), "Spaces", 
 					radiobuttons, self.toggletabmode)
@@ -97,7 +97,7 @@
 			else:
 				# convert spaces to pixels
 				self.lasttab = spacewidth * tabsize
-			self.w.tabsizeedit.set(`self.lasttab`)
+			self.w.tabsizeedit.set(repr(self.lasttab))
 			self.tabmode = tabmode
 			self.doit()
 	
@@ -139,7 +139,7 @@
 			for i in range(1, len(_stylenames)):
 				if self.w[i].get():
 					style = style | 2 ** (i - 1)
-		#self.w.sample.set(`style`)
+		#self.w.sample.set(repr(style))
 		fontsettings, tabsettings = self.get()
 		self.w.sample.setfontsettings(fontsettings)
 		self.w.sample.settabsettings(tabsettings)
@@ -161,7 +161,7 @@
 				self.doit()
 		else:
 			SysBeep(0)
-			self.w.tabsizeedit.set(`self.lasttab`)
+			self.w.tabsizeedit.set(repr(self.lasttab))
 			self.w.tabsizeedit.selectall()
 	
 	def checksize(self):
@@ -181,7 +181,7 @@
 				self.doit()
 		else:
 			SysBeep(0)
-			self.w.sizeedit.set(`self.lastsize`)
+			self.w.sizeedit.set(repr(self.lastsize))
 			self.w.sizeedit.selectall()
 	
 	def doplain(self):
diff --git a/Mac/Tools/IDE/PyDebugger.py b/Mac/Tools/IDE/PyDebugger.py
index 18a089e..51ba753 100644
--- a/Mac/Tools/IDE/PyDebugger.py
+++ b/Mac/Tools/IDE/PyDebugger.py
@@ -511,7 +511,7 @@
 					return self.dispatch_return(frame, arg)
 				if event == 'exception':
 					return self.dispatch_exception(frame, arg)
-				print 'bdb.Bdb.dispatch: unknown debugging event:', `event`
+				print 'bdb.Bdb.dispatch: unknown debugging event:', repr(event)
 				return self.trace_dispatch
 			finally:
 				if hasattr(MacOS, 'EnableAppswitch'):
diff --git a/Mac/Tools/IDE/PyDocSearch.py b/Mac/Tools/IDE/PyDocSearch.py
index f9d2cb5..1abd4cd 100644
--- a/Mac/Tools/IDE/PyDocSearch.py
+++ b/Mac/Tools/IDE/PyDocSearch.py
@@ -75,7 +75,7 @@
 	
 	def set(self, path, hits):
 		self.w.searching.set(path)
-		self.w.hits.set('Hits: ' + `hits`)
+		self.w.hits.set('Hits: %r' % (hits,))
 		app.breathe()
 	
 	def close(self):
diff --git a/Mac/Tools/IDE/PyEdit.py b/Mac/Tools/IDE/PyEdit.py
index 0ad7a8a..6826c65 100644
--- a/Mac/Tools/IDE/PyEdit.py
+++ b/Mac/Tools/IDE/PyEdit.py
@@ -43,7 +43,7 @@
 			if title:
 				self.title = title
 			else:
-				self.title = "Untitled Script " + `_scriptuntitledcounter`
+				self.title = "Untitled Script %r" % (_scriptuntitledcounter,)
 				_scriptuntitledcounter = _scriptuntitledcounter + 1
 			text = ""
 			self._creator = W._signature
@@ -444,7 +444,7 @@
 		try:
 			code = compile(pytext, filename, "exec")
 		except (SyntaxError, EOFError):
-			raise buildtools.BuildError, "Syntax error in script %s" % `filename`
+			raise buildtools.BuildError, "Syntax error in script %r" % (filename,)
 			
 		import tempfile
 		tmpdir = tempfile.mkdtemp()
@@ -1262,8 +1262,8 @@
 		self.w.picksizebutton = W.Button((8, 50, 80, 16), "Front window", self.picksize)
 		self.w.xsizelabel = W.TextBox((98, 32, 40, 14), "Width:")
 		self.w.ysizelabel = W.TextBox((148, 32, 40, 14), "Height:")
-		self.w.xsize = W.EditText((98, 48, 40, 20), `self.windowsize[0]`)
-		self.w.ysize = W.EditText((148, 48, 40, 20), `self.windowsize[1]`)
+		self.w.xsize = W.EditText((98, 48, 40, 20), repr(self.windowsize[0]))
+		self.w.ysize = W.EditText((148, 48, 40, 20), repr(self.windowsize[1]))
 		
 		self.w.cancelbutton = W.Button((-180, -26, 80, 16), "Cancel", self.cancel)
 		self.w.okbutton = W.Button((-90, -26, 80, 16), "Done", self.ok)
@@ -1276,8 +1276,8 @@
 		editor = findeditor(self)
 		if editor is not None:
 			width, height = editor._parentwindow._bounds[2:]
-			self.w.xsize.set(`width`)
-			self.w.ysize.set(`height`)
+			self.w.xsize.set(repr(width))
+			self.w.ysize.set(repr(height))
 		else:
 			raise W.AlertError, "No edit window found"
 	
diff --git a/Mac/Tools/IDE/PyFontify.py b/Mac/Tools/IDE/PyFontify.py
index 5680aa8..eb37ad3 100644
--- a/Mac/Tools/IDE/PyFontify.py
+++ b/Mac/Tools/IDE/PyFontify.py
@@ -152,4 +152,4 @@
 	f.close()
 	tags = fontify(text)
 	for tag, start, end, sublist in tags:
-		print tag, `text[start:end]`
+		print tag, repr(text[start:end])
diff --git a/Mac/Tools/IDE/PythonIDEMain.py b/Mac/Tools/IDE/PythonIDEMain.py
index 29e9bef..111a0b0 100644
--- a/Mac/Tools/IDE/PythonIDEMain.py
+++ b/Mac/Tools/IDE/PythonIDEMain.py
@@ -394,7 +394,7 @@
 			if arg[0] == -50:
 				W.Message("Developer documentation not installed")
 			else:
-				W.Message("AppleHelp Error: %s" % `arg`)
+				W.Message("AppleHelp Error: %r" % (arg,))
 		
 	def domenu_lookuppython(self, *args):
 		from Carbon import AH
@@ -404,7 +404,7 @@
 		try:
 			AH.AHSearch("Python Documentation", searchstring)
 		except AH.Error, arg:
-			W.Message("AppleHelp Error: %s" % `arg`)
+			W.Message("AppleHelp Error: %r" % (arg,))
 			
 	def domenu_lookupcarbon(self, *args):
 		from Carbon import AH
@@ -414,7 +414,7 @@
 		try:
 			AH.AHSearch("Carbon", searchstring)
 		except AH.Error, arg:
-			W.Message("AppleHelp Error: %s" % `arg`)
+			W.Message("AppleHelp Error: %r" % (arg,))
 			
 	def _getsearchstring(self):
 		# First we get the frontmost window
diff --git a/Mac/Tools/IDE/Wapplication.py b/Mac/Tools/IDE/Wapplication.py
index ada4419..a63be2a 100644
--- a/Mac/Tools/IDE/Wapplication.py
+++ b/Mac/Tools/IDE/Wapplication.py
@@ -118,7 +118,7 @@
 					func()
 				except:
 					import sys
-					sys.stderr.write("exception in idle function %s; killed:\n" % `func`)
+					sys.stderr.write("exception in idle function %r; killed:\n" % (func,))
 					traceback.print_exc()
 					self._idlefuncs.remove(func)
 					break
@@ -175,7 +175,7 @@
 				self.do_rawmenu(id, item, None, event)
 				return	# here! we had a menukey! 
 			#else:
-			#	print "XXX Command-" +`ch`
+			#	print "XXX Command-%r" % ch
 		# See whether the front window wants it
 		if wid and self._windows.has_key(wid):
 			window = self._windows[wid]
diff --git a/Mac/Tools/IDE/Wbase.py b/Mac/Tools/IDE/Wbase.py
index 4c78b88..a5d556b 100644
--- a/Mac/Tools/IDE/Wbase.py
+++ b/Mac/Tools/IDE/Wbase.py
@@ -229,7 +229,7 @@
 	
 	def _removewidget(self, key):
 		if not self._widgetsdict.has_key(key):
-			raise KeyError, "no widget with key " + `key`
+			raise KeyError, "no widget with key %r" % (key,)
 		widget = self._widgetsdict[key]
 		for k in widget._widgetsdict.keys():
 			widget._removewidget(k)
@@ -502,8 +502,8 @@
 		self._panebounds = []
 		for i in range(len(self._panesizes)):
 			panestart, paneend = self._panesizes[i]
-			boundsstring = self.boundstemplate % (`panestart`, panestart and halfgutter, 
-							`paneend`, (paneend <> 1.0) and -halfgutter)
+			boundsstring = self.boundstemplate % (repr(panestart), panestart and halfgutter, 
+							repr(paneend), (paneend <> 1.0) and -halfgutter)
 			self._panebounds.append(eval(boundsstring))
 	
 	def installbounds(self):
@@ -684,9 +684,9 @@
 		return callback()
 	else:
 		if mustfit:
-			raise TypeError, "callback accepts wrong number of arguments: " + `len(args)`
+			raise TypeError, "callback accepts wrong number of arguments: %r" % len(args)
 		else:
-			raise TypeError, "callback accepts wrong number of arguments: 0 or " + `len(args)`
+			raise TypeError, "callback accepts wrong number of arguments: 0 or %r" % len(args)
 
 
 def HasBaseClass(obj, class_):
diff --git a/Mac/Tools/IDE/Wsocket.py b/Mac/Tools/IDE/Wsocket.py
index e0077b2..913797c 100644
--- a/Mac/Tools/IDE/Wsocket.py
+++ b/Mac/Tools/IDE/Wsocket.py
@@ -129,14 +129,14 @@
 		data = asyncore.dispatcher.recv(self, BUFSIZE)
 		if data:
 			if VERBOSE > 2:
-				print "incoming ->", "%x" % id(self), `data`
+				print "incoming -> %x %r" % (id(self), data)
 			self.handle_incoming_data(data)
 	
 	def handle_write(self):
 		if self._out_buffer:
 			sent = self.socket.send(self._out_buffer[:BUFSIZE])
 			if VERBOSE > 2:
-				print "outgoing ->", "%x" % id(self), `self._out_buffer[:sent]`
+				print "outgoing -> %x %r" % (id(self), self._out_buffer[:sent])
 			self._out_buffer = self._out_buffer[sent:]
 	
 	def close(self):
@@ -144,7 +144,7 @@
 			self.readfunc(self._in_buffer)
 			self._in_buffer = ""
 		#elif VERBOSE > 1 and self._in_buffer:
-		#	print "--- there is unread data:", `self._in_buffer`
+		#	print "--- there is unread data: %r", (self._in_buffer,)
 		asyncore.dispatcher.close(self)
 	
 	def handle_close(self):
@@ -290,7 +290,7 @@
 				self.currentmessage = PyMessage()
 	
 	def handle_object(self, object):
-		print 'unhandled object:', `object`
+		print 'unhandled object:', repr(object)
 	
 	def send(self, object):
 		import cPickle, zlib, struct
@@ -356,7 +356,7 @@
 	
 	def connectproxy(self, data):
 		if VERBOSE:
-			print "--- proxy request", `data`
+			print "--- proxy request", repr(data)
 		addr, data = de_proxify(data)
 		other = Proxy(addr)
 		self.other = other
diff --git a/Mac/Tools/IDE/Wtraceback.py b/Mac/Tools/IDE/Wtraceback.py
index 51b54f3..90a25fe 100644
--- a/Mac/Tools/IDE/Wtraceback.py
+++ b/Mac/Tools/IDE/Wtraceback.py
@@ -147,9 +147,7 @@
 			tbline = ""
 			if os.path.exists(filename):
 				filename = os.path.split(filename)[1]
-				tbline = 'File "' + filename + '", line ' + `lineno` + ', in ' + func
-			else:
-				tbline = 'File "' + filename + '", line ' + `lineno` + ', in ' + func
+			tbline = 'File "%s", line %r, in %r' % (filename, lineno, func)
 			if line:
 				tbline = tbline + '\r      ' + line
 			self.textlist.append(tbline[:255])