summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWalter Dörwald <walter@livinglogic.de>2004-02-12 17:35:32 +0000
committerWalter Dörwald <walter@livinglogic.de>2004-02-12 17:35:32 +0000
commit70a6b49821a3226f55e9716f32d802d06640cb89 (patch)
tree3c8ca10c1fa09e025bd266cf855a00d7d96c55aa
parentecfeb7f095dfd9c1c8929bf3df858ee35e0d9e9e (diff)
downloadcpython-git-70a6b49821a3226f55e9716f32d802d06640cb89.tar.gz
Replace backticks with repr() or "%r"
From SF patch #852334.
-rwxr-xr-xDemo/classes/Complex.py8
-rwxr-xr-xDemo/classes/Dates.py15
-rwxr-xr-xDemo/classes/Dbm.py10
-rwxr-xr-xDemo/classes/Range.py4
-rwxr-xr-xDemo/classes/bitvec.py34
-rw-r--r--Demo/metaclasses/Enum.py6
-rw-r--r--Demo/metaclasses/Meta.py2
-rw-r--r--Demo/metaclasses/Trace.py2
-rw-r--r--Demo/newmetaclasses/Enum.py4
-rwxr-xr-xDemo/pdist/RCSProxy.py2
-rwxr-xr-xDemo/pdist/client.py2
-rwxr-xr-xDemo/pdist/cmdfw.py6
-rwxr-xr-xDemo/pdist/cmptree.py10
-rwxr-xr-xDemo/pdist/cvslock.py2
-rwxr-xr-xDemo/pdist/rcslib.py4
-rwxr-xr-xDemo/pdist/server.py4
-rw-r--r--Demo/rpc/T.py2
-rw-r--r--Demo/rpc/rnusersclient.py2
-rw-r--r--Demo/rpc/rpc.py30
-rw-r--r--Demo/rpc/xdr.py3
-rwxr-xr-xDemo/scripts/eqfix.py19
-rwxr-xr-xDemo/scripts/from.py2
-rwxr-xr-xDemo/scripts/ftpstats.py2
-rwxr-xr-xDemo/scripts/lpwatch.py16
-rwxr-xr-xDemo/scripts/markov.py4
-rwxr-xr-xDemo/scripts/mboxconvert.py4
-rwxr-xr-xDemo/scripts/mkrcs.py20
-rwxr-xr-xDemo/scripts/mpzpi.py2
-rwxr-xr-xDemo/scripts/newslist.py2
-rwxr-xr-xDemo/scripts/pp.py2
-rwxr-xr-xDemo/sockets/broadcast.py2
-rwxr-xr-xDemo/sockets/ftp.py2
-rwxr-xr-xDemo/sockets/gopher.py24
-rwxr-xr-xDemo/sockets/mcast.py4
-rwxr-xr-xDemo/sockets/radio.py2
-rwxr-xr-xDemo/sockets/telnet.py2
-rwxr-xr-xDemo/sockets/udpecho.py4
-rw-r--r--Demo/sockets/unicast.py2
-rw-r--r--Demo/sockets/unixclient.py2
-rw-r--r--Demo/threads/Coroutine.py7
-rw-r--r--Demo/threads/find.py6
-rw-r--r--Demo/threads/sync.py4
-rw-r--r--Demo/threads/telnet.py8
-rwxr-xr-xDemo/tix/samples/DirList.py2
-rwxr-xr-xDemo/tkinter/guido/mbox.py2
-rwxr-xr-xDemo/tkinter/guido/solitaire.py2
-rw-r--r--Demo/tkinter/matt/animation-w-velocity-ctrl.py2
-rw-r--r--Demo/tkinter/matt/pong-demo-1.py2
-rwxr-xr-xDoc/lib/caseless.py8
-rw-r--r--Doc/tools/cvsinfo.py2
-rw-r--r--Doc/tools/refcounts.py2
-rw-r--r--Doc/tools/sgmlconv/esistools.py6
-rwxr-xr-xDoc/tools/sgmlconv/latex2esis.py18
-rw-r--r--Lib/BaseHTTPServer.py10
-rw-r--r--Lib/Bastion.py2
-rw-r--r--Lib/CGIHTTPServer.py14
-rw-r--r--Lib/ConfigParser.py10
-rw-r--r--Lib/HTMLParser.py8
-rw-r--r--Lib/StringIO.py4
-rw-r--r--Lib/aifc.py4
-rw-r--r--Lib/atexit.py4
-rwxr-xr-xLib/base64.py2
-rw-r--r--Lib/bdb.py4
-rw-r--r--Lib/binhex.py4
-rw-r--r--Lib/bsddb/dbrecio.py4
-rw-r--r--Lib/bsddb/dbtables.py10
-rw-r--r--Lib/bsddb/test/test_associate.py4
-rw-r--r--Lib/bsddb/test/test_basics.py8
-rw-r--r--Lib/bsddb/test/test_dbtables.py2
-rw-r--r--Lib/calendar.py8
-rwxr-xr-xLib/cgi.py19
-rw-r--r--Lib/difflib.py8
-rw-r--r--Lib/dis.py16
-rw-r--r--Lib/distutils/cmd.py4
-rw-r--r--Lib/distutils/core.py2
-rw-r--r--Lib/distutils/dir_util.py2
-rw-r--r--Lib/distutils/dist.py4
-rw-r--r--Lib/distutils/fancy_getopt.py2
-rw-r--r--Lib/distutils/util.py16
-rw-r--r--Lib/doctest.py24
-rw-r--r--Lib/formatter.py18
-rw-r--r--Lib/fpformat.py6
-rw-r--r--Lib/ftplib.py8
-rw-r--r--Lib/gopherlib.py6
-rw-r--r--Lib/gzip.py2
-rw-r--r--Lib/idlelib/ColorDelegator.py2
-rw-r--r--Lib/idlelib/EditorWindow.py10
-rw-r--r--Lib/idlelib/FileList.py6
-rw-r--r--Lib/idlelib/GrepDialog.py2
-rw-r--r--Lib/idlelib/ObjectBrowser.py2
-rw-r--r--Lib/idlelib/ParenMatch.py2
-rw-r--r--Lib/idlelib/PyShell.py18
-rw-r--r--Lib/idlelib/RemoteDebugger.py4
-rw-r--r--Lib/idlelib/ScriptBinding.py6
-rw-r--r--Lib/idlelib/TreeWidget.py2
-rw-r--r--Lib/idlelib/UndoDelegator.py4
-rw-r--r--Lib/idlelib/WidgetRedirector.py2
-rw-r--r--Lib/idlelib/aboutDialog.py5
-rw-r--r--Lib/idlelib/configDialog.py4
-rw-r--r--Lib/idlelib/configHandler.py27
-rw-r--r--Lib/idlelib/rpc.py10
-rw-r--r--Lib/idlelib/textView.py2
-rw-r--r--Lib/ihooks.py8
-rw-r--r--Lib/imaplib.py6
-rw-r--r--Lib/lib-tk/FileDialog.py2
-rwxr-xr-xLib/lib-tk/Tix.py4
-rw-r--r--Lib/lib-tk/Tkinter.py12
-rw-r--r--Lib/lib-tk/turtle.py10
-rw-r--r--Lib/macurl2path.py4
-rw-r--r--Lib/markupbase.py11
-rw-r--r--Lib/mhlib.py21
-rw-r--r--Lib/mimetools.py4
-rw-r--r--Lib/modulefinder.py8
-rw-r--r--Lib/nntplib.py10
-rw-r--r--Lib/opcode.py2
-rwxr-xr-xLib/pdb.py16
-rw-r--r--Lib/pickle.py22
-rw-r--r--Lib/pipes.py10
-rwxr-xr-xLib/plat-irix5/cddb.py8
-rwxr-xr-xLib/plat-irix5/cdplayer.py3
-rwxr-xr-xLib/plat-irix5/flp.py4
-rwxr-xr-xLib/plat-irix5/panel.py2
-rwxr-xr-xLib/plat-irix5/readcd.py4
-rwxr-xr-xLib/plat-irix5/torgb.py5
-rw-r--r--Lib/plat-irix6/cddb.py8
-rw-r--r--Lib/plat-irix6/cdplayer.py3
-rw-r--r--Lib/plat-irix6/flp.py4
-rw-r--r--Lib/plat-irix6/panel.py2
-rw-r--r--Lib/plat-irix6/readcd.py4
-rw-r--r--Lib/plat-irix6/torgb.py5
-rw-r--r--Lib/plat-mac/EasyDialogs.py4
-rw-r--r--Lib/plat-mac/FrameWork.py6
-rw-r--r--Lib/plat-mac/MiniAEFrame.py3
-rw-r--r--Lib/plat-mac/aetypes.py55
-rw-r--r--Lib/plat-mac/argvemulator.py3
-rw-r--r--Lib/plat-mac/buildtools.py2
-rw-r--r--Lib/plat-mac/gensuitemodule.py58
-rw-r--r--Lib/plat-mac/ic.py4
-rw-r--r--Lib/plat-riscos/rourl2path.py4
-rw-r--r--Lib/popen2.py6
-rw-r--r--Lib/poplib.py16
-rw-r--r--Lib/posixfile.py2
-rw-r--r--Lib/pprint.py6
-rw-r--r--Lib/pre.py10
-rwxr-xr-xLib/profile.py4
-rw-r--r--Lib/pstats.py13
-rw-r--r--Lib/regsub.py6
-rw-r--r--Lib/repr.py12
-rw-r--r--Lib/rexec.py2
-rw-r--r--Lib/sgmllib.py6
-rw-r--r--Lib/shlex.py8
-rw-r--r--Lib/site.py2
-rwxr-xr-xLib/smtplib.py8
-rw-r--r--Lib/stringold.py2
-rw-r--r--Lib/sunaudio.py2
-rwxr-xr-xLib/tabnanny.py17
-rw-r--r--Lib/telnetlib.py4
-rw-r--r--Lib/test/test_asynchat.py2
-rw-r--r--Lib/test/test_builtin.py4
-rw-r--r--Lib/test/test_contains.py12
-rw-r--r--Lib/test/test_copy.py4
-rw-r--r--Lib/test/test_descr.py28
-rwxr-xr-xLib/test/test_fcntl.py4
-rw-r--r--Lib/test/test_generators.py2
-rw-r--r--Lib/test/test_grammar.py4
-rw-r--r--Lib/test/test_hash.py2
-rw-r--r--Lib/test/test_math.py8
-rw-r--r--Lib/test/test_minidom.py2
-rw-r--r--Lib/test/test_mpz.py2
-rw-r--r--Lib/test/test_poll.py2
-rw-r--r--Lib/test/test_popen2.py6
-rw-r--r--Lib/test/test_pprint.py26
-rw-r--r--Lib/test/test_pty.py2
-rw-r--r--Lib/test/test_pyexpat.py6
-rw-r--r--Lib/test/test_repr.py8
-rw-r--r--Lib/test/test_rotor.py4
-rw-r--r--Lib/test/test_select.py2
-rw-r--r--Lib/test/test_set.py4
-rw-r--r--Lib/test/test_sets.py4
-rw-r--r--Lib/test/test_socketserver.py2
-rw-r--r--Lib/test/test_struct.py18
-rw-r--r--Lib/test/test_syntax.py2
-rw-r--r--Lib/test/test_types.py4
-rw-r--r--Lib/test/test_univnewlines.py6
-rw-r--r--Lib/test/test_weakref.py2
-rw-r--r--Lib/toaiff.py5
-rw-r--r--Lib/trace.py2
-rw-r--r--Lib/unittest.py8
-rw-r--r--Lib/urllib.py10
-rw-r--r--Lib/warnings.py22
-rw-r--r--Lib/wave.py2
-rw-r--r--Lib/xdrlib.py2
-rw-r--r--Lib/xml/dom/domreg.py2
-rw-r--r--Lib/xml/dom/minidom.py4
-rw-r--r--Lib/xml/dom/xmlbuilder.py2
-rw-r--r--Lib/xmllib.py12
-rw-r--r--Mac/Demo/PICTbrowse/ICONbrowse.py6
-rw-r--r--Mac/Demo/PICTbrowse/PICTbrowse.py8
-rw-r--r--Mac/Demo/PICTbrowse/PICTbrowse2.py6
-rw-r--r--Mac/Demo/PICTbrowse/cicnbrowse.py6
-rw-r--r--Mac/Demo/PICTbrowse/oldPICTbrowse.py8
-rw-r--r--Mac/Demo/calldll/testcalldll.py4
-rw-r--r--Mac/Demo/imgbrowse/imgbrowse.py2
-rw-r--r--Mac/Demo/mlte/mlted.py2
-rw-r--r--Mac/Demo/resources/listres.py4
-rw-r--r--Mac/Demo/textedit/ped.py2
-rw-r--r--Mac/Demo/waste/htmled.py8
-rw-r--r--Mac/Demo/waste/swed.py4
-rw-r--r--Mac/Demo/waste/wed.py2
-rw-r--r--Mac/IDE scripts/Widget demos/KeyTester.py2
-rw-r--r--Mac/IDE scripts/Widget demos/WidgetTest.py2
-rw-r--r--Mac/Tools/IDE/FontSettings.py10
-rw-r--r--Mac/Tools/IDE/PyDebugger.py2
-rw-r--r--Mac/Tools/IDE/PyDocSearch.py2
-rw-r--r--Mac/Tools/IDE/PyEdit.py12
-rw-r--r--Mac/Tools/IDE/PyFontify.py2
-rw-r--r--Mac/Tools/IDE/PythonIDEMain.py6
-rw-r--r--Mac/Tools/IDE/Wapplication.py4
-rw-r--r--Mac/Tools/IDE/Wbase.py10
-rw-r--r--Mac/Tools/IDE/Wsocket.py10
-rw-r--r--Mac/Tools/IDE/Wtraceback.py4
-rw-r--r--Mac/Tools/macfreeze/macfreezegui.py2
-rw-r--r--Mac/Tools/macfreeze/macgen_info.py2
-rw-r--r--Mac/Tools/macfreeze/macgenerate.py2
-rw-r--r--Modules/cgen.py40
-rw-r--r--Tools/bgen/bgen/scantools.py64
-rw-r--r--Tools/compiler/compile.py3
-rw-r--r--Tools/faqwiz/faqwiz.py8
-rw-r--r--Tools/freeze/makefreeze.py2
-rw-r--r--Tools/freeze/winmakemakefile.py2
-rwxr-xr-xTools/modulator/modulator.py30
-rwxr-xr-xTools/scripts/byteyears.py2
-rwxr-xr-xTools/scripts/checkappend.py12
-rwxr-xr-xTools/scripts/checkpyc.py18
-rwxr-xr-xTools/scripts/classfix.py19
-rwxr-xr-xTools/scripts/dutree.py2
-rwxr-xr-xTools/scripts/fixcid.py18
-rwxr-xr-xTools/scripts/fixps.py2
-rwxr-xr-xTools/scripts/ftpmirror.py72
-rwxr-xr-xTools/scripts/methfix.py19
-rwxr-xr-xTools/scripts/pathfix.py16
-rw-r--r--Tools/scripts/redemo.py2
-rwxr-xr-xTools/scripts/suff.py2
-rwxr-xr-xTools/scripts/texi2html.py20
-rwxr-xr-xTools/scripts/untabify.py2
-rwxr-xr-xTools/scripts/which.py2
246 files changed, 926 insertions, 962 deletions
diff --git a/Demo/classes/Complex.py b/Demo/classes/Complex.py
index 4585f62f44..a9f5c2e00b 100755
--- a/Demo/classes/Complex.py
+++ b/Demo/classes/Complex.py
@@ -117,15 +117,15 @@ class Complex:
def __repr__(self):
if not self.im:
- return 'Complex(%s)' % `self.re`
+ return 'Complex(%r)' % (self.re,)
else:
- return 'Complex(%s, %s)' % (`self.re`, `self.im`)
+ return 'Complex(%r, %r)' % (self.re, self.im)
def __str__(self):
if not self.im:
- return `self.re`
+ return repr(self.re)
else:
- return 'Complex(%s, %s)' % (`self.re`, `self.im`)
+ return 'Complex(%r, %r)' % (self.re, self.im)
def __neg__(self):
return Complex(-self.re, -self.im)
diff --git a/Demo/classes/Dates.py b/Demo/classes/Dates.py
index 06ffa36fa9..f8f0634758 100755
--- a/Demo/classes/Dates.py
+++ b/Demo/classes/Dates.py
@@ -86,7 +86,7 @@ _DI400Y = _days_before_year( 400 ) # number of days in 400 years
def _num2date( n ): # return date with ordinal n
if type(n) not in _INT_TYPES:
- raise TypeError, 'argument must be integer: ' + `type(n)`
+ raise TypeError, 'argument must be integer: %r' % type(n)
ans = Date(1,1,1) # arguments irrelevant; just getting a Date obj
del ans.ord, ans.month, ans.day, ans.year # un-initialize it
@@ -120,10 +120,10 @@ def _num2day( n ): # return weekday name of day with ordinal n
class Date:
def __init__( self, month, day, year ):
if not 1 <= month <= 12:
- raise ValueError, 'month must be in 1..12: ' + `month`
+ raise ValueError, 'month must be in 1..12: %r' % (month,)
dim = _days_in_month( month, year )
if not 1 <= day <= dim:
- raise ValueError, 'day must be in 1..' + `dim` + ': ' + `day`
+ raise ValueError, 'day must be in 1..%r: %r' % (dim, day)
self.month, self.day, self.year = month, day, year
self.ord = _date2num( self )
@@ -142,15 +142,16 @@ class Date:
# print as, e.g., Mon 16 Aug 1993
def __repr__( self ):
- return '%.3s %2d %.3s ' % (
+ return '%.3s %2d %.3s %r' % (
self.weekday(),
self.day,
- _MONTH_NAMES[self.month-1] ) + `self.year`
+ _MONTH_NAMES[self.month-1],
+ self.year)
# Python 1.1 coerces neither int+date nor date+int
def __add__( self, n ):
if type(n) not in _INT_TYPES:
- raise TypeError, 'can\'t add ' + `type(n)` + ' to date'
+ raise TypeError, 'can\'t add %r to date' % type(n)
return _num2date( self.ord + n )
__radd__ = __add__ # handle int+date
@@ -177,7 +178,7 @@ DateTestError = 'DateTestError'
def test( firstyear, lastyear ):
a = Date(9,30,1913)
b = Date(9,30,1914)
- if `a` != 'Tue 30 Sep 1913':
+ if repr(a) != 'Tue 30 Sep 1913':
raise DateTestError, '__repr__ failure'
if (not a < b) or a == b or a > b or b != b:
raise DateTestError, '__cmp__ failure'
diff --git a/Demo/classes/Dbm.py b/Demo/classes/Dbm.py
index 5566f999ad..482806a4ee 100755
--- a/Demo/classes/Dbm.py
+++ b/Demo/classes/Dbm.py
@@ -13,7 +13,7 @@ class Dbm:
def __repr__(self):
s = ''
for key in self.keys():
- t = `key` + ': ' + `self[key]`
+ t = repr(key) + ': ' + repr(self[key])
if s: t = ', ' + t
s = s + t
return '{' + s + '}'
@@ -22,13 +22,13 @@ class Dbm:
return len(self.db)
def __getitem__(self, key):
- return eval(self.db[`key`])
+ return eval(self.db[repr(key)])
def __setitem__(self, key, value):
- self.db[`key`] = `value`
+ self.db[repr(key)] = repr(value)
def __delitem__(self, key):
- del self.db[`key`]
+ del self.db[repr(key)]
def keys(self):
res = []
@@ -37,7 +37,7 @@ class Dbm:
return res
def has_key(self, key):
- return self.db.has_key(`key`)
+ return self.db.has_key(repr(key))
def test():
diff --git a/Demo/classes/Range.py b/Demo/classes/Range.py
index ebd18177b2..68f3c61263 100755
--- a/Demo/classes/Range.py
+++ b/Demo/classes/Range.py
@@ -34,9 +34,9 @@ class Range:
self.step = step
self.len = max(0, int((self.stop - self.start) / self.step))
- # implement `x` and is also used by print x
+ # implement repr(x) and is also used by print x
def __repr__(self):
- return 'range' + `self.start, self.stop, self.step`
+ return 'range(%r, %r, %r)' % (self.start, self.stop, self.step)
# implement len(x)
def __len__(self):
diff --git a/Demo/classes/bitvec.py b/Demo/classes/bitvec.py
index ed89d67666..2894a56ae7 100755
--- a/Demo/classes/bitvec.py
+++ b/Demo/classes/bitvec.py
@@ -20,7 +20,7 @@ def _compute_len(param):
mant, l = math.frexp(float(param))
bitmask = 1L << l
if bitmask <= param:
- raise 'FATAL', '(param, l) = ' + `param, l`
+ raise 'FATAL', '(param, l) = %r' % ((param, l),)
while l:
bitmask = bitmask >> 1
if param & bitmask:
@@ -167,10 +167,10 @@ class BitVec:
def __repr__(self):
##rprt('<bitvec class instance object>.' + '__repr__()\n')
- return 'bitvec' + `self._data, self._len`
+ return 'bitvec(%r, %r)' % (self._data, self._len)
def __cmp__(self, other, *rest):
- #rprt(`self`+'.__cmp__'+`(other, ) + rest`+'\n')
+ #rprt('%r.__cmp__%r\n' % (self, (other,) + rest))
if type(other) != type(self):
other = apply(bitvec, (other, ) + rest)
#expensive solution... recursive binary, with slicing
@@ -193,16 +193,16 @@ class BitVec:
def __len__(self):
- #rprt(`self`+'.__len__()\n')
+ #rprt('%r.__len__()\n' % (self,))
return self._len
def __getitem__(self, key):
- #rprt(`self`+'.__getitem__('+`key`+')\n')
+ #rprt('%r.__getitem__(%r)\n' % (self, key))
key = _check_key(self._len, key)
return self._data & (1L << key) != 0
def __setitem__(self, key, value):
- #rprt(`self`+'.__setitem__'+`key, value`+'\n')
+ #rprt('%r.__setitem__(%r, %r)\n' % (self, key, value))
key = _check_key(self._len, key)
#_check_value(value)
if value:
@@ -211,14 +211,14 @@ class BitVec:
self._data = self._data & ~(1L << key)
def __delitem__(self, key):
- #rprt(`self`+'.__delitem__('+`key`+')\n')
+ #rprt('%r.__delitem__(%r)\n' % (self, key))
key = _check_key(self._len, key)
#el cheapo solution...
self._data = self[:key]._data | self[key+1:]._data >> key
self._len = self._len - 1
def __getslice__(self, i, j):
- #rprt(`self`+'.__getslice__'+`i, j`+'\n')
+ #rprt('%r.__getslice__(%r, %r)\n' % (self, i, j))
i, j = _check_slice(self._len, i, j)
if i >= j:
return BitVec(0L, 0)
@@ -234,7 +234,7 @@ class BitVec:
return BitVec(ndata, nlength)
def __setslice__(self, i, j, sequence, *rest):
- #rprt(`self`+'.__setslice__'+`(i, j, sequence) + rest`+'\n')
+ #rprt('%s.__setslice__%r\n' % (self, (i, j, sequence) + rest))
i, j = _check_slice(self._len, i, j)
if type(sequence) != type(self):
sequence = apply(bitvec, (sequence, ) + rest)
@@ -247,7 +247,7 @@ class BitVec:
self._len = self._len - j + i + sequence._len
def __delslice__(self, i, j):
- #rprt(`self`+'.__delslice__'+`i, j`+'\n')
+ #rprt('%r.__delslice__(%r, %r)\n' % (self, i, j))
i, j = _check_slice(self._len, i, j)
if i == 0 and j == self._len:
self._data, self._len = 0L, 0
@@ -256,13 +256,13 @@ class BitVec:
self._len = self._len - j + i
def __add__(self, other):
- #rprt(`self`+'.__add__('+`other`+')\n')
+ #rprt('%r.__add__(%r)\n' % (self, other))
retval = self.copy()
retval[self._len:self._len] = other
return retval
def __mul__(self, multiplier):
- #rprt(`self`+'.__mul__('+`multiplier`+')\n')
+ #rprt('%r.__mul__(%r)\n' % (self, multiplier))
if type(multiplier) != type(0):
raise TypeError, 'sequence subscript not int'
if multiplier <= 0:
@@ -281,7 +281,7 @@ class BitVec:
return retval
def __and__(self, otherseq, *rest):
- #rprt(`self`+'.__and__'+`(otherseq, ) + rest`+'\n')
+ #rprt('%r.__and__%r\n' % (self, (otherseq,) + rest))
if type(otherseq) != type(self):
otherseq = apply(bitvec, (otherseq, ) + rest)
#sequence is now of our own type
@@ -290,7 +290,7 @@ class BitVec:
def __xor__(self, otherseq, *rest):
- #rprt(`self`+'.__xor__'+`(otherseq, ) + rest`+'\n')
+ #rprt('%r.__xor__%r\n' % (self, (otherseq,) + rest))
if type(otherseq) != type(self):
otherseq = apply(bitvec, (otherseq, ) + rest)
#sequence is now of our own type
@@ -299,7 +299,7 @@ class BitVec:
def __or__(self, otherseq, *rest):
- #rprt(`self`+'.__or__'+`(otherseq, ) + rest`+'\n')
+ #rprt('%r.__or__%r\n' % (self, (otherseq,) + rest))
if type(otherseq) != type(self):
otherseq = apply(bitvec, (otherseq, ) + rest)
#sequence is now of our own type
@@ -308,13 +308,13 @@ class BitVec:
def __invert__(self):
- #rprt(`self`+'.__invert__()\n')
+ #rprt('%r.__invert__()\n' % (self,))
return BitVec(~self._data & ((1L << self._len) - 1), \
self._len)
def __coerce__(self, otherseq, *rest):
#needed for *some* of the arithmetic operations
- #rprt(`self`+'.__coerce__'+`(otherseq, ) + rest`+'\n')
+ #rprt('%r.__coerce__%r\n' % (self, (otherseq,) + rest))
if type(otherseq) != type(self):
otherseq = apply(bitvec, (otherseq, ) + rest)
return self, otherseq
diff --git a/Demo/metaclasses/Enum.py b/Demo/metaclasses/Enum.py
index 13a3ed7d6d..df1d8143e6 100644
--- a/Demo/metaclasses/Enum.py
+++ b/Demo/metaclasses/Enum.py
@@ -107,9 +107,9 @@ class EnumInstance:
return self.__value
def __repr__(self):
- return "EnumInstance(%s, %s, %s)" % (`self.__classname`,
- `self.__enumname`,
- `self.__value`)
+ return "EnumInstance(%r, %r, %r)" % (self.__classname,
+ self.__enumname,
+ self.__value)
def __str__(self):
return "%s.%s" % (self.__classname, self.__enumname)
diff --git a/Demo/metaclasses/Meta.py b/Demo/metaclasses/Meta.py
index 39cbef6266..55340749af 100644
--- a/Demo/metaclasses/Meta.py
+++ b/Demo/metaclasses/Meta.py
@@ -98,7 +98,7 @@ def _test():
def __init__(self, *args):
print "__init__, args =", args
def m1(self, x):
- print "m1(x=%s)" %`x`
+ print "m1(x=%r)" % (x,)
print C
x = C()
print x
diff --git a/Demo/metaclasses/Trace.py b/Demo/metaclasses/Trace.py
index 86e199d602..ea12cd9deb 100644
--- a/Demo/metaclasses/Trace.py
+++ b/Demo/metaclasses/Trace.py
@@ -117,7 +117,7 @@ def _test():
def m2(self, y): return self.x + y
__trace_output__ = sys.stdout
class D(C):
- def m2(self, y): print "D.m2(%s)" % `y`; return C.m2(self, y)
+ def m2(self, y): print "D.m2(%r)" % (y,); return C.m2(self, y)
__trace_output__ = None
x = C(4321)
print x
diff --git a/Demo/newmetaclasses/Enum.py b/Demo/newmetaclasses/Enum.py
index 8a00b59f21..5d490a9fc0 100644
--- a/Demo/newmetaclasses/Enum.py
+++ b/Demo/newmetaclasses/Enum.py
@@ -97,7 +97,7 @@ def _test():
print Color.red
- print `Color.red`
+ print repr(Color.red)
print Color.red == Color.red
print Color.red == Color.blue
print Color.red == 1
@@ -139,7 +139,7 @@ def _test2():
print Color.red
- print `Color.red`
+ print repr(Color.red)
print Color.red == Color.red
print Color.red == Color.blue
print Color.red == 1
diff --git a/Demo/pdist/RCSProxy.py b/Demo/pdist/RCSProxy.py
index 7212ca6224..87c65ccf0e 100755
--- a/Demo/pdist/RCSProxy.py
+++ b/Demo/pdist/RCSProxy.py
@@ -188,7 +188,7 @@ def test():
if callable(attr):
print apply(attr, tuple(sys.argv[2:]))
else:
- print `attr`
+ print repr(attr)
else:
print "%s: no such attribute" % what
sys.exit(2)
diff --git a/Demo/pdist/client.py b/Demo/pdist/client.py
index 3e93f1ce8e..a00f005bbc 100755
--- a/Demo/pdist/client.py
+++ b/Demo/pdist/client.py
@@ -139,7 +139,7 @@ class SecureClient(Client, Security):
line = self._rf.readline()
challenge = string.atoi(string.strip(line))
response = self._encode_challenge(challenge)
- line = `long(response)`
+ line = repr(long(response))
if line[-1] in 'Ll': line = line[:-1]
self._wf.write(line + '\n')
self._wf.flush()
diff --git a/Demo/pdist/cmdfw.py b/Demo/pdist/cmdfw.py
index a0c6f5d8ec..25584b78f8 100755
--- a/Demo/pdist/cmdfw.py
+++ b/Demo/pdist/cmdfw.py
@@ -55,7 +55,7 @@ class CommandFrameWork:
try:
method = getattr(self, mname)
except AttributeError:
- return self.usage("command %s unknown" % `cmd`)
+ return self.usage("command %r unknown" % (cmd,))
try:
flags = getattr(self, fname)
except AttributeError:
@@ -75,7 +75,7 @@ class CommandFrameWork:
print "-"*40
print "Options:"
for o, a in opts:
- print 'option', o, 'value', `a`
+ print 'option', o, 'value', repr(a)
print "-"*40
def ready(self):
@@ -137,7 +137,7 @@ def test():
for t in tests:
print '-'*10, t, '-'*10
sts = x.run(t)
- print "Exit status:", `sts`
+ print "Exit status:", repr(sts)
if __name__ == '__main__':
diff --git a/Demo/pdist/cmptree.py b/Demo/pdist/cmptree.py
index 7eaa6c3697..8a34f3f681 100755
--- a/Demo/pdist/cmptree.py
+++ b/Demo/pdist/cmptree.py
@@ -49,7 +49,7 @@ def askint(prompt, default):
def compare(local, remote, mode):
print
- print "PWD =", `os.getcwd()`
+ print "PWD =", repr(os.getcwd())
sums_id = remote._send('sumlist')
subdirs_id = remote._send('listsubdirs')
remote._flush()
@@ -64,13 +64,13 @@ def compare(local, remote, mode):
for name, rsum in sums:
rsumdict[name] = rsum
if not lsumdict.has_key(name):
- print `name`, "only remote"
+ print repr(name), "only remote"
if 'r' in mode and 'c' in mode:
recvfile(local, remote, name)
else:
lsum = lsumdict[name]
if lsum != rsum:
- print `name`,
+ print repr(name),
rmtime = remote.mtime(name)
lmtime = local.mtime(name)
if rmtime > lmtime:
@@ -86,7 +86,7 @@ def compare(local, remote, mode):
print
for name in lsumdict.keys():
if not rsumdict.keys():
- print `name`, "only locally",
+ print repr(name), "only locally",
fl()
if 'w' in mode and 'c' in mode:
sendfile(local, remote, name)
@@ -160,7 +160,7 @@ def recvfile(local, remote, name):
return rv
finally:
if not ok:
- print "*** recvfile of %s failed, deleting" % `name`
+ print "*** recvfile of %r failed, deleting" % (name,)
local.delete(name)
def recvfile_real(local, remote, name):
diff --git a/Demo/pdist/cvslock.py b/Demo/pdist/cvslock.py
index a421e1a943..75f866ee35 100755
--- a/Demo/pdist/cvslock.py
+++ b/Demo/pdist/cvslock.py
@@ -114,7 +114,7 @@ class Lock:
self.delay = delay
self.lockdir = None
self.lockfile = None
- pid = `os.getpid()`
+ pid = repr(os.getpid())
self.cvslck = self.join(CVSLCK)
self.cvsrfl = self.join(CVSRFL + pid)
self.cvswfl = self.join(CVSWFL + pid)
diff --git a/Demo/pdist/rcslib.py b/Demo/pdist/rcslib.py
index 4e72766d24..78de111b14 100755
--- a/Demo/pdist/rcslib.py
+++ b/Demo/pdist/rcslib.py
@@ -232,7 +232,7 @@ class RCS:
"""
name, rev = self._unmangle(name_rev)
if not self.isvalid(name):
- raise os.error, 'not an rcs file %s' % `name`
+ raise os.error, 'not an rcs file %r' % (name,)
return name, rev
# --- Internal methods ---
@@ -252,7 +252,7 @@ class RCS:
namev = self.rcsname(name)
if rev:
cmd = cmd + ' ' + rflag + rev
- return os.popen("%s %s" % (cmd, `namev`))
+ return os.popen("%s %r" % (cmd, namev))
def _unmangle(self, name_rev):
"""INTERNAL: Normalize NAME_REV argument to (NAME, REV) tuple.
diff --git a/Demo/pdist/server.py b/Demo/pdist/server.py
index 423d583007..4e4ab0d252 100755
--- a/Demo/pdist/server.py
+++ b/Demo/pdist/server.py
@@ -134,11 +134,11 @@ class SecureServer(Server, Security):
response = string.atol(string.strip(response))
except string.atol_error:
if self._verbose > 0:
- print "Invalid response syntax", `response`
+ print "Invalid response syntax", repr(response)
return 0
if not self._compare_challenge_response(challenge, response):
if self._verbose > 0:
- print "Invalid response value", `response`
+ print "Invalid response value", repr(response)
return 0
if self._verbose > 1:
print "Response matches challenge. Go ahead!"
diff --git a/Demo/rpc/T.py b/Demo/rpc/T.py
index abf3a06d05..2adf486607 100644
--- a/Demo/rpc/T.py
+++ b/Demo/rpc/T.py
@@ -18,5 +18,5 @@ def TSTOP(*label):
[u, s, r] = tt
msg = ''
for x in label: msg = msg + (x + ' ')
- msg = msg + `u` + ' user, ' + `s` + ' sys, ' + `r` + ' real\n'
+ msg = msg + '%r user, %r sys, %r real\n' % (u, s, r)
sys.stderr.write(msg)
diff --git a/Demo/rpc/rnusersclient.py b/Demo/rpc/rnusersclient.py
index e9cad620fd..90cbd6dae0 100644
--- a/Demo/rpc/rnusersclient.py
+++ b/Demo/rpc/rnusersclient.py
@@ -77,7 +77,7 @@ def test():
line = strip0(line)
name = strip0(name)
host = strip0(host)
- print `name`, `host`, `line`, time, idle
+ print "%r %r %r %s %s" % (name, host, line, time, idle)
def testbcast():
c = BroadcastRnusersClient('<broadcast>')
diff --git a/Demo/rpc/rpc.py b/Demo/rpc/rpc.py
index f44b3e4426..6b15db423e 100644
--- a/Demo/rpc/rpc.py
+++ b/Demo/rpc/rpc.py
@@ -93,10 +93,10 @@ class Unpacker(xdr.Unpacker):
xid = self.unpack_uint(xid)
temp = self.unpack_enum()
if temp <> CALL:
- raise BadRPCFormat, 'no CALL but ' + `temp`
+ raise BadRPCFormat, 'no CALL but %r' % (temp,)
temp = self.unpack_uint()
if temp <> RPCVERSION:
- raise BadRPCVerspion, 'bad RPC version ' + `temp`
+ raise BadRPCVerspion, 'bad RPC version %r' % (temp,)
prog = self.unpack_uint()
vers = self.unpack_uint()
proc = self.unpack_uint()
@@ -109,7 +109,7 @@ class Unpacker(xdr.Unpacker):
xid = self.unpack_uint()
mtype = self.unpack_enum()
if mtype <> REPLY:
- raise RuntimeError, 'no REPLY but ' + `mtype`
+ raise RuntimeError, 'no REPLY but %r' % (mtype,)
stat = self.unpack_enum()
if stat == MSG_DENIED:
stat = self.unpack_enum()
@@ -117,15 +117,15 @@ class Unpacker(xdr.Unpacker):
low = self.unpack_uint()
high = self.unpack_uint()
raise RuntimeError, \
- 'MSG_DENIED: RPC_MISMATCH: ' + `low, high`
+ 'MSG_DENIED: RPC_MISMATCH: %r' % ((low, high),)
if stat == AUTH_ERROR:
stat = self.unpack_uint()
raise RuntimeError, \
- 'MSG_DENIED: AUTH_ERROR: ' + `stat`
- raise RuntimeError, 'MSG_DENIED: ' + `stat`
+ 'MSG_DENIED: AUTH_ERROR: %r' % (stat,)
+ raise RuntimeError, 'MSG_DENIED: %r' % (stat,)
if stat <> MSG_ACCEPTED:
raise RuntimeError, \
- 'Neither MSG_DENIED nor MSG_ACCEPTED: ' + `stat`
+ 'Neither MSG_DENIED nor MSG_ACCEPTED: %r' % (stat,)
verf = self.unpack_auth()
stat = self.unpack_enum()
if stat == PROG_UNAVAIL:
@@ -134,13 +134,13 @@ class Unpacker(xdr.Unpacker):
low = self.unpack_uint()
high = self.unpack_uint()
raise RuntimeError, \
- 'call failed: PROG_MISMATCH: ' + `low, high`
+ 'call failed: PROG_MISMATCH: %r' % ((low, high),)
if stat == PROC_UNAVAIL:
raise RuntimeError, 'call failed: PROC_UNAVAIL'
if stat == GARBAGE_ARGS:
raise RuntimeError, 'call failed: GARBAGE_ARGS'
if stat <> SUCCESS:
- raise RuntimeError, 'call failed: ' + `stat`
+ raise RuntimeError, 'call failed: %r' % (stat,)
return xid, verf
# Caller must get procedure-specific part of reply
@@ -350,8 +350,8 @@ class RawTCPClient(Client):
xid, verf = u.unpack_replyheader()
if xid <> self.lastxid:
# Can't really happen since this is TCP...
- raise RuntimeError, 'wrong xid in reply ' + `xid` + \
- ' instead of ' + `self.lastxid`
+ raise RuntimeError, 'wrong xid in reply %r instead of %r' % (
+ xid, self.lastxid)
# Client using UDP to a specific port
@@ -701,7 +701,7 @@ class Server:
self.packer.pack_uint(self.vers)
return self.packer.get_buf()
proc = self.unpacker.unpack_uint()
- methname = 'handle_' + `proc`
+ methname = 'handle_' + repr(proc)
try:
meth = getattr(self, methname)
except AttributeError:
@@ -840,7 +840,7 @@ def testbcast():
bcastaddr = '<broadcast>'
def rh(reply, fromaddr):
host, port = fromaddr
- print host + '\t' + `reply`
+ print host + '\t' + repr(reply)
pmap = BroadcastUDPPortMapperClient(bcastaddr)
pmap.set_reply_handler(rh)
pmap.set_timeout(5)
@@ -858,7 +858,7 @@ def testsvr():
def handle_1(self):
arg = self.unpacker.unpack_string()
self.turn_around()
- print 'RPC function 1 called, arg', `arg`
+ print 'RPC function 1 called, arg', repr(arg)
self.packer.pack_string(arg + arg)
#
s = S('', 0x20000000, 1, 0)
@@ -888,4 +888,4 @@ def testclt():
c = C(host, 0x20000000, 1)
print 'making call...'
reply = c.call_1('hello, world, ')
- print 'call returned', `reply`
+ print 'call returned', repr(reply)
diff --git a/Demo/rpc/xdr.py b/Demo/rpc/xdr.py
index 41c970ae91..5338aef629 100644
--- a/Demo/rpc/xdr.py
+++ b/Demo/rpc/xdr.py
@@ -184,8 +184,7 @@ class Unpacker:
x = self.unpack_uint()
if x == 0: break
if x <> 1:
- raise RuntimeError, \
- '0 or 1 expected, got ' + `x`
+ raise RuntimeError, '0 or 1 expected, got %r' % (x, )
item = unpack_item()
list.append(item)
return list
diff --git a/Demo/scripts/eqfix.py b/Demo/scripts/eqfix.py
index 583d54e0e7..2139d2bce6 100755
--- a/Demo/scripts/eqfix.py
+++ b/Demo/scripts/eqfix.py
@@ -58,12 +58,12 @@ def ispython(name):
return ispythonprog.match(name) >= 0
def recursedown(dirname):
- dbg('recursedown(' + `dirname` + ')\n')
+ dbg('recursedown(%r)\n' % (dirname,))
bad = 0
try:
names = os.listdir(dirname)
except os.error, msg:
- err(dirname + ': cannot list directory: ' + `msg` + '\n')
+ err('%s: cannot list directory: %r\n' % (dirname, msg))
return 1
names.sort()
subdirs = []
@@ -80,11 +80,11 @@ def recursedown(dirname):
return bad
def fix(filename):
-## dbg('fix(' + `filename` + ')\n')
+## dbg('fix(%r)\n' % (dirname,))
try:
f = open(filename, 'r')
except IOError, msg:
- err(filename + ': cannot open: ' + `msg` + '\n')
+ err('%s: cannot open: %r\n' % (filename, msg))
return 1
head, tail = os.path.split(filename)
tempname = os.path.join(head, '@' + tail)
@@ -122,14 +122,13 @@ def fix(filename):
g = open(tempname, 'w')
except IOError, msg:
f.close()
- err(tempname+': cannot create: '+\
- `msg`+'\n')
+ err('%s: cannot create: %r\n' % (tempname, msg))
return 1
f.seek(0)
lineno = 0
rep(filename + ':\n')
continue # restart from the beginning
- rep(`lineno` + '\n')
+ rep(repr(lineno) + '\n')
rep('< ' + line)
rep('> ' + newline)
if g is not None:
@@ -146,17 +145,17 @@ def fix(filename):
statbuf = os.stat(filename)
os.chmod(tempname, statbuf[ST_MODE] & 07777)
except os.error, msg:
- err(tempname + ': warning: chmod failed (' + `msg` + ')\n')
+ err('%s: warning: chmod failed (%r)\n' % (tempname, msg))
# Then make a backup of the original file as filename~
try:
os.rename(filename, filename + '~')
except os.error, msg:
- err(filename + ': warning: backup failed (' + `msg` + ')\n')
+ err('%s: warning: backup failed (%r)\n' % (filename, msg))
# Now move the temp file to the original file
try:
os.rename(tempname, filename)
except os.error, msg:
- err(filename + ': rename failed (' + `msg` + ')\n')
+ err('%s: rename failed (%r)\n' % (filename, msg))
return 1
# Return succes
return 0
diff --git a/Demo/scripts/from.py b/Demo/scripts/from.py
index d61afde06e..3c04fcd497 100755
--- a/Demo/scripts/from.py
+++ b/Demo/scripts/from.py
@@ -31,5 +31,5 @@ while 1:
if not line or line == '\n':
break
if line.startswith('Subject: '):
- print `line[9:-1]`,
+ print repr(line[9:-1]),
print
diff --git a/Demo/scripts/ftpstats.py b/Demo/scripts/ftpstats.py
index 28b1d8bdfd..79cbee63a4 100755
--- a/Demo/scripts/ftpstats.py
+++ b/Demo/scripts/ftpstats.py
@@ -60,7 +60,7 @@ def main():
if search and string.find(line, search) < 0:
continue
if prog.match(line) < 0:
- print 'Bad line', lineno, ':', `line`
+ print 'Bad line', lineno, ':', repr(line)
continue
items = prog.group(1, 2, 3, 4, 5, 6)
(logtime, loguser, loghost, logfile, logbytes,
diff --git a/Demo/scripts/lpwatch.py b/Demo/scripts/lpwatch.py
index 9f051ebbf3..00afba9d6b 100755
--- a/Demo/scripts/lpwatch.py
+++ b/Demo/scripts/lpwatch.py
@@ -83,24 +83,24 @@ def makestatus(name, thisuser):
lines.append(line)
#
if totaljobs:
- line = `(totalbytes+1023)/1024` + ' K'
+ line = '%d K' % ((totalbytes+1023)/1024)
if totaljobs <> len(users):
- line = line + ' (' + `totaljobs` + ' jobs)'
+ line = line + ' (%d jobs)' % totaljobs
if len(users) == 1:
- line = line + ' for ' + users.keys()[0]
+ line = line + ' for %s' % (users.keys()[0],)
else:
- line = line + ' for ' + `len(users)` + ' users'
+ line = line + ' for %d users' % len(users)
if userseen:
if aheadjobs == 0:
- line = line + ' (' + thisuser + ' first)'
+ line = line + ' (%s first)' % thisuser
else:
- line = line + ' (' + `(aheadbytes+1023)/1024`
- line = line + ' K before ' + thisuser + ')'
+ line = line + ' (%d K before %s)' % (
+ (aheadbytes+1023)/1024, thisuser)
lines.append(line)
#
sts = pipe.close()
if sts:
- lines.append('lpq exit status ' + `sts`)
+ lines.append('lpq exit status %r' % (sts,))
return string.joinfields(lines, ': ')
try:
diff --git a/Demo/scripts/markov.py b/Demo/scripts/markov.py
index e1649f1e9d..b0583d1a5a 100755
--- a/Demo/scripts/markov.py
+++ b/Demo/scripts/markov.py
@@ -89,8 +89,8 @@ def test():
if debug > 1:
for key in m.trans.keys():
if key is None or len(key) < histsize:
- print `key`, m.trans[key]
- if histsize == 0: print `''`, m.trans['']
+ print repr(key), m.trans[key]
+ if histsize == 0: print repr(''), m.trans['']
print
while 1:
data = m.get()
diff --git a/Demo/scripts/mboxconvert.py b/Demo/scripts/mboxconvert.py
index 08e0d0cbe5..996537d392 100755
--- a/Demo/scripts/mboxconvert.py
+++ b/Demo/scripts/mboxconvert.py
@@ -73,7 +73,7 @@ def mmdf(f):
sts = message(f, line) or sts
else:
sys.stderr.write(
- 'Bad line in MMFD mailbox: %s\n' % `line`)
+ 'Bad line in MMFD mailbox: %r\n' % (line,))
return sts
counter = 0 # for generating unique Message-ID headers
@@ -89,7 +89,7 @@ def message(f, delimiter = ''):
t = time.mktime(tt)
else:
sys.stderr.write(
- 'Unparseable date: %s\n' % `m.getheader('Date')`)
+ 'Unparseable date: %r\n' % (m.getheader('Date'),))
t = os.fstat(f.fileno())[stat.ST_MTIME]
print 'From', email, time.ctime(t)
# Copy RFC822 header
diff --git a/Demo/scripts/mkrcs.py b/Demo/scripts/mkrcs.py
index 36a35eace2..917b4fe2cb 100755
--- a/Demo/scripts/mkrcs.py
+++ b/Demo/scripts/mkrcs.py
@@ -12,13 +12,13 @@ def main():
rcstree = 'RCStree'
rcs = 'RCS'
if os.path.islink(rcs):
- print `rcs`, 'is a symlink to', `os.readlink(rcs)`
+ print '%r is a symlink to %r' % (rcs, os.readlink(rcs))
return
if os.path.isdir(rcs):
- print `rcs`, 'is an ordinary directory'
+ print '%r is an ordinary directory' % (rcs,)
return
if os.path.exists(rcs):
- print `rcs`, 'is a file?!?!'
+ print '%r is a file?!?!' % (rcs,)
return
#
p = os.getcwd()
@@ -29,26 +29,26 @@ def main():
# (2) up is the same directory as p
# Ergo:
# (3) join(up, down) is the current directory
- #print 'p =', `p`
+ #print 'p =', repr(p)
while not os.path.isdir(os.path.join(p, rcstree)):
head, tail = os.path.split(p)
- #print 'head =', `head`, '; tail =', `tail`
+ #print 'head = %r; tail = %r' % (head, tail)
if not tail:
- print 'Sorry, no ancestor dir contains', `rcstree`
+ print 'Sorry, no ancestor dir contains %r' % (rcstree,)
return
p = head
up = os.path.join(os.pardir, up)
down = os.path.join(tail, down)
- #print 'p =', `p`, '; up =', `up`, '; down =', `down`
+ #print 'p = %r; up = %r; down = %r' % (p, up, down)
there = os.path.join(up, rcstree)
there = os.path.join(there, down)
there = os.path.join(there, rcs)
if os.path.isdir(there):
- print `there`, 'already exists'
+ print '%r already exists' % (there, )
else:
- print 'making', `there`
+ print 'making %r' % (there,)
makedirs(there)
- print 'making symlink', `rcs`, '->', `there`
+ print 'making symlink %r -> %r' % (rcs, there)
os.symlink(there, rcs)
def makedirs(p):
diff --git a/Demo/scripts/mpzpi.py b/Demo/scripts/mpzpi.py
index 93c74aa398..ccf591d79d 100755
--- a/Demo/scripts/mpzpi.py
+++ b/Demo/scripts/mpzpi.py
@@ -27,7 +27,7 @@ def main():
def output(d):
# Use write() to avoid spaces between the digits
# Use int(d) to avoid a trailing L after each digit
- sys.stdout.write(`int(d)`)
+ sys.stdout.write(repr(int(d)))
# Flush so the output is seen immediately
sys.stdout.flush()
diff --git a/Demo/scripts/newslist.py b/Demo/scripts/newslist.py
index f78ca30271..b06b452e36 100755
--- a/Demo/scripts/newslist.py
+++ b/Demo/scripts/newslist.py
@@ -304,7 +304,7 @@ def getallgroups(server):
def getnewgroups(server, treedate):
print 'Getting list of new groups since start of '+treedate+'...',
info = server.newgroups(treedate,'000001')[1]
- print 'got '+`len(info)`+'.'
+ print 'got %d.' % len(info)
print 'Processing...',
groups = []
for i in info:
diff --git a/Demo/scripts/pp.py b/Demo/scripts/pp.py
index 64e57ee15f..92a1104b0b 100755
--- a/Demo/scripts/pp.py
+++ b/Demo/scripts/pp.py
@@ -125,6 +125,6 @@ fp.write(program)
fp.flush()
if DFLAG:
import pdb
- pdb.run('execfile(' + `tfn` + ')')
+ pdb.run('execfile(%r)' % (tfn,))
else:
execfile(tfn)
diff --git a/Demo/sockets/broadcast.py b/Demo/sockets/broadcast.py
index a02b081a2e..010162c05d 100755
--- a/Demo/sockets/broadcast.py
+++ b/Demo/sockets/broadcast.py
@@ -10,7 +10,7 @@ s.bind(('', 0))
s.setsockopt(SOL_SOCKET, SO_BROADCAST, 1)
while 1:
- data = `time.time()` + '\n'
+ data = repr(time.time()) + '\n'
s.sendto(data, ('<broadcast>', MYPORT))
time.sleep(2)
diff --git a/Demo/sockets/ftp.py b/Demo/sockets/ftp.py
index 8260c52f9c..9e1d5a14f8 100755
--- a/Demo/sockets/ftp.py
+++ b/Demo/sockets/ftp.py
@@ -91,7 +91,7 @@ def sendportcmd(s, f, port):
hostname = gethostname()
hostaddr = gethostbyname(hostname)
hbytes = string.splitfields(hostaddr, '.')
- pbytes = [`port/256`, `port%256`]
+ pbytes = [repr(port/256), repr(port%256)]
bytes = hbytes + pbytes
cmd = 'PORT ' + string.joinfields(bytes, ',')
s.send(cmd + '\r\n')
diff --git a/Demo/sockets/gopher.py b/Demo/sockets/gopher.py
index a2ab3a2f6c..4e1cb30c2e 100755
--- a/Demo/sockets/gopher.py
+++ b/Demo/sockets/gopher.py
@@ -75,10 +75,10 @@ def get_menu(selector, host, port):
typechar = line[0]
parts = string.splitfields(line[1:], TAB)
if len(parts) < 4:
- print '(Bad line from server:', `line`, ')'
+ print '(Bad line from server: %r)' % (line,)
continue
if len(parts) > 4:
- print '(Extra info from server:', parts[4:], ')'
+ print '(Extra info from server: %r)' % (parts[4:],)
parts.insert(0, typechar)
list.append(parts)
f.close()
@@ -154,17 +154,17 @@ def browse_menu(selector, host, port):
list = get_menu(selector, host, port)
while 1:
print '----- MENU -----'
- print 'Selector:', `selector`
+ print 'Selector:', repr(selector)
print 'Host:', host, ' Port:', port
print
for i in range(len(list)):
item = list[i]
typechar, description = item[0], item[1]
- print string.rjust(`i+1`, 3) + ':', description,
+ print string.rjust(repr(i+1), 3) + ':', description,
if typename.has_key(typechar):
print typename[typechar]
else:
- print '<TYPE=' + `typechar` + '>'
+ print '<TYPE=' + repr(typechar) + '>'
print
while 1:
try:
@@ -221,7 +221,7 @@ def browse_textfile(selector, host, port):
def browse_search(selector, host, port):
while 1:
print '----- SEARCH -----'
- print 'Selector:', `selector`
+ print 'Selector:', repr(selector)
print 'Host:', host, ' Port:', port
print
try:
@@ -240,9 +240,9 @@ def browse_search(selector, host, port):
# "Browse" telnet-based information, i.e. open a telnet session
def browse_telnet(selector, host, port):
if selector:
- print 'Log in as', `selector`
+ print 'Log in as', repr(selector)
if type(port) <> type(''):
- port = `port`
+ port = repr(port)
sts = os.system('set -x; exec telnet ' + host + ' ' + port)
if sts:
print 'Exit status:', sts
@@ -307,18 +307,18 @@ def open_savefile():
try:
p = os.popen(cmd, 'w')
except IOError, msg:
- print `cmd`, ':', msg
+ print repr(cmd), ':', msg
return None
- print 'Piping through', `cmd`, '...'
+ print 'Piping through', repr(cmd), '...'
return p
if savefile[0] == '~':
savefile = os.path.expanduser(savefile)
try:
f = open(savefile, 'w')
except IOError, msg:
- print `savefile`, ':', msg
+ print repr(savefile), ':', msg
return None
- print 'Saving to', `savefile`, '...'
+ print 'Saving to', repr(savefile), '...'
return f
# Test program
diff --git a/Demo/sockets/mcast.py b/Demo/sockets/mcast.py
index cc7a7e07d4..71bcc755aa 100755
--- a/Demo/sockets/mcast.py
+++ b/Demo/sockets/mcast.py
@@ -38,7 +38,7 @@ def sender(flag):
ttl = struct.pack('b', 1) # Time-to-live
s.setsockopt(IPPROTO_IP, IP_MULTICAST_TTL, ttl)
while 1:
- data = `time.time()`
+ data = repr(time.time())
## data = data + (1400 - len(data)) * '\0'
s.sendto(data, (mygroup, MYPORT))
time.sleep(1)
@@ -53,7 +53,7 @@ def receiver():
while 1:
data, sender = s.recvfrom(1500)
while data[-1:] == '\0': data = data[:-1] # Strip trailing \0's
- print sender, ':', `data`
+ print sender, ':', repr(data)
# Open a UDP socket, bind it to a port and select a multicast group
diff --git a/Demo/sockets/radio.py b/Demo/sockets/radio.py
index 6131d40053..b68a4ecd1e 100755
--- a/Demo/sockets/radio.py
+++ b/Demo/sockets/radio.py
@@ -10,5 +10,5 @@ s.bind(('', MYPORT))
while 1:
data, wherefrom = s.recvfrom(1500, 0)
- sys.stderr.write(`wherefrom` + '\n')
+ sys.stderr.write(repr(wherefrom) + '\n')
sys.stdout.write(data)
diff --git a/Demo/sockets/telnet.py b/Demo/sockets/telnet.py
index ee7c43b874..d86cbeb695 100755
--- a/Demo/sockets/telnet.py
+++ b/Demo/sockets/telnet.py
@@ -53,7 +53,7 @@ def main():
try:
s.connect((host, port))
except error, msg:
- sys.stderr.write('connect failed: ' + `msg` + '\n')
+ sys.stderr.write('connect failed: ' + repr(msg) + '\n')
sys.exit(1)
#
pid = posix.fork()
diff --git a/Demo/sockets/udpecho.py b/Demo/sockets/udpecho.py
index 4410165e3a..720cfe113f 100755
--- a/Demo/sockets/udpecho.py
+++ b/Demo/sockets/udpecho.py
@@ -37,7 +37,7 @@ def server():
print 'udp echo server ready'
while 1:
data, addr = s.recvfrom(BUFSIZE)
- print 'server received', `data`, 'from', `addr`
+ print 'server received %r from %r' % (data, addr)
s.sendto(data, addr)
def client():
@@ -58,6 +58,6 @@ def client():
break
s.sendto(line, addr)
data, fromaddr = s.recvfrom(BUFSIZE)
- print 'client received', `data`, 'from', `fromaddr`
+ print 'client received %r from %r' % (data, fromaddr)
main()
diff --git a/Demo/sockets/unicast.py b/Demo/sockets/unicast.py
index 1e9caebd2a..0a30f3560f 100644
--- a/Demo/sockets/unicast.py
+++ b/Demo/sockets/unicast.py
@@ -9,7 +9,7 @@ s = socket(AF_INET, SOCK_DGRAM)
s.bind(('', 0))
while 1:
- data = `time.time()` + '\n'
+ data = repr(time.time()) + '\n'
s.sendto(data, ('', MYPORT))
time.sleep(2)
diff --git a/Demo/sockets/unixclient.py b/Demo/sockets/unixclient.py
index a0d80f6083..cccd617e97 100644
--- a/Demo/sockets/unixclient.py
+++ b/Demo/sockets/unixclient.py
@@ -7,4 +7,4 @@ s.connect(FILE)
s.send('Hello, world')
data = s.recv(1024)
s.close()
-print 'Received', `data`
+print 'Received', repr(data)
diff --git a/Demo/threads/Coroutine.py b/Demo/threads/Coroutine.py
index 0cf9255362..4cc65f7bf8 100644
--- a/Demo/threads/Coroutine.py
+++ b/Demo/threads/Coroutine.py
@@ -138,10 +138,9 @@ class Coroutine:
def tran(self, target, data=None):
if not self.invokedby.has_key(target):
- raise TypeError, '.tran target ' + `target` + \
- ' is not an active coroutine'
+ raise TypeError, '.tran target %r is not an active coroutine' % (target,)
if self.killed:
- raise TypeError, '.tran target ' + `target` + ' is killed'
+ raise TypeError, '.tran target %r is killed' % (target,)
self.value = data
me = self.active
self.invokedby[target] = me
@@ -153,7 +152,7 @@ class Coroutine:
if self.main is not me:
raise Killed
if self.terminated_by is not None:
- raise EarlyExit, `self.terminated_by` + ' terminated early'
+ raise EarlyExit, '%r terminated early' % (self.terminated_by,)
return self.value
diff --git a/Demo/threads/find.py b/Demo/threads/find.py
index ab581e3473..7d5edc1c50 100644
--- a/Demo/threads/find.py
+++ b/Demo/threads/find.py
@@ -116,7 +116,7 @@ def main():
wq.run(nworkers)
t2 = time.time()
- sys.stderr.write('Total time ' + `t2-t1` + ' sec.\n')
+ sys.stderr.write('Total time %r sec.\n' % (t2-t1))
# The predicate -- defines what files we look for.
@@ -133,7 +133,7 @@ def find(dir, pred, wq):
try:
names = os.listdir(dir)
except os.error, msg:
- print `dir`, ':', msg
+ print repr(dir), ':', msg
return
for name in names:
if name not in (os.curdir, os.pardir):
@@ -141,7 +141,7 @@ def find(dir, pred, wq):
try:
stat = os.lstat(fullname)
except os.error, msg:
- print `fullname`, ':', msg
+ print repr(fullname), ':', msg
continue
if pred(dir, name, fullname, stat):
print fullname
diff --git a/Demo/threads/sync.py b/Demo/threads/sync.py
index a8556c48ef..1688403b7f 100644
--- a/Demo/threads/sync.py
+++ b/Demo/threads/sync.py
@@ -336,7 +336,7 @@ class condition:
def broadcast(self, num = -1):
if num < -1:
- raise ValueError, '.broadcast called with num ' + `num`
+ raise ValueError, '.broadcast called with num %r' % (num,)
if num == 0:
return
self.idlock.acquire()
@@ -418,7 +418,7 @@ class semaphore:
self.nonzero.acquire()
if self.count == self.maxcount:
raise ValueError, '.v() tried to raise semaphore count above ' \
- 'initial value ' + `maxcount`
+ 'initial value %r' % (maxcount,))
self.count = self.count + 1
self.nonzero.signal()
self.nonzero.release()
diff --git a/Demo/threads/telnet.py b/Demo/threads/telnet.py
index 3c70cb0038..707a35386f 100644
--- a/Demo/threads/telnet.py
+++ b/Demo/threads/telnet.py
@@ -57,7 +57,7 @@ def main():
try:
s.connect((host, port))
except error, msg:
- sys.stderr.write('connect failed: ' + `msg` + '\n')
+ sys.stderr.write('connect failed: %r\n' % (msg,))
sys.exit(1)
#
thread.start_new(child, (s,))
@@ -77,7 +77,7 @@ def parent(s):
for c in data:
if opt:
print ord(c)
-## print '(replying: ' + `opt+c` + ')'
+## print '(replying: %r)' % (opt+c,)
s.send(opt + c)
opt = ''
elif iac:
@@ -101,13 +101,13 @@ def parent(s):
cleandata = cleandata + c
sys.stdout.write(cleandata)
sys.stdout.flush()
-## print 'Out:', `cleandata`
+## print 'Out:', repr(cleandata)
def child(s):
# read stdin, write socket
while 1:
line = sys.stdin.readline()
-## print 'Got:', `line`
+## print 'Got:', repr(line)
if not line: break
s.send(line)
diff --git a/Demo/tix/samples/DirList.py b/Demo/tix/samples/DirList.py
index b2aad336fc..8d7536c7bd 100755
--- a/Demo/tix/samples/DirList.py
+++ b/Demo/tix/samples/DirList.py
@@ -75,7 +75,7 @@ class DemoDirList:
top.btn['command'] = lambda dir=top.dir, ent=top.ent, self=self: \
self.copy_name(dir,ent)
- # top.ent.entry.insert(0,'tix'+`self`)
+ # top.ent.entry.insert(0,'tix'+repr(self))
top.ent.entry.bind('<Return>', lambda self=self: self.okcmd () )
top.pack( expand='yes', fill='both', side=TOP)
diff --git a/Demo/tkinter/guido/mbox.py b/Demo/tkinter/guido/mbox.py
index 9aea7ee5b1..6d7a4106cc 100755
--- a/Demo/tkinter/guido/mbox.py
+++ b/Demo/tkinter/guido/mbox.py
@@ -253,7 +253,7 @@ def refile_message(e=None):
def fixfocus(near, itop):
n = scanbox.size()
for i in range(n):
- line = scanbox.get(`i`)
+ line = scanbox.get(repr(i))
if scanparser.match(line) >= 0:
num = string.atoi(scanparser.group(1))
if num >= near:
diff --git a/Demo/tkinter/guido/solitaire.py b/Demo/tkinter/guido/solitaire.py
index bd7328da59..a205afd3ba 100755
--- a/Demo/tkinter/guido/solitaire.py
+++ b/Demo/tkinter/guido/solitaire.py
@@ -183,7 +183,7 @@ class Card:
def __repr__(self):
"""Return a string for debug print statements."""
- return "Card(%s, %s)" % (`self.suit`, `self.value`)
+ return "Card(%r, %r)" % (self.suit, self.value)
def moveto(self, x, y):
"""Move the card to absolute position (x, y)."""
diff --git a/Demo/tkinter/matt/animation-w-velocity-ctrl.py b/Demo/tkinter/matt/animation-w-velocity-ctrl.py
index a45f3f0e8a..f3332f2c48 100644
--- a/Demo/tkinter/matt/animation-w-velocity-ctrl.py
+++ b/Demo/tkinter/matt/animation-w-velocity-ctrl.py
@@ -28,7 +28,7 @@ class Test(Frame):
def moveThing(self, *args):
velocity = self.speed.get()
str = float(velocity) / 1000.0
- str = `str` + "i"
+ str = "%ri" % (str,)
self.draw.move("thing", str, str)
self.after(10, self.moveThing)
diff --git a/Demo/tkinter/matt/pong-demo-1.py b/Demo/tkinter/matt/pong-demo-1.py
index dacaa38272..a27f334f8a 100644
--- a/Demo/tkinter/matt/pong-demo-1.py
+++ b/Demo/tkinter/matt/pong-demo-1.py
@@ -39,7 +39,7 @@ class Pong(Frame):
self.x = self.x + deltax
self.y = self.y + deltay
- self.draw.move(self.ball, `deltax` + "i", `deltay` + "i")
+ self.draw.move(self.ball, "%ri" % deltax, "%ri" % deltay)
self.after(10, self.moveBall)
def __init__(self, master=None):
diff --git a/Doc/lib/caseless.py b/Doc/lib/caseless.py
index 107fed68e3..b128219337 100755
--- a/Doc/lib/caseless.py
+++ b/Doc/lib/caseless.py
@@ -47,10 +47,10 @@ if __name__ == "__main__":
print "not ok: no conflict between -h and -H"
parser.add_option("-f", "--file", dest="file")
- #print `parser.get_option("-f")`
- #print `parser.get_option("-F")`
- #print `parser.get_option("--file")`
- #print `parser.get_option("--fIlE")`
+ #print repr(parser.get_option("-f"))
+ #print repr(parser.get_option("-F"))
+ #print repr(parser.get_option("--file"))
+ #print repr(parser.get_option("--fIlE"))
(options, args) = parser.parse_args(["--FiLe", "foo"])
assert options.file == "foo", options.file
print "ok: case insensitive long options work"
diff --git a/Doc/tools/cvsinfo.py b/Doc/tools/cvsinfo.py
index 58a32c2538..cc90fe5e2a 100644
--- a/Doc/tools/cvsinfo.py
+++ b/Doc/tools/cvsinfo.py
@@ -78,4 +78,4 @@ class RepositoryInfo:
return fn[len(self.cvsroot_path)+1:]
def __repr__(self):
- return "<RepositoryInfo for %s>" % `self.get_cvsroot()`
+ return "<RepositoryInfo for %r>" % self.get_cvsroot()
diff --git a/Doc/tools/refcounts.py b/Doc/tools/refcounts.py
index d82def7a7d..ccfc8c609e 100644
--- a/Doc/tools/refcounts.py
+++ b/Doc/tools/refcounts.py
@@ -32,7 +32,7 @@ def loadfile(fp):
continue
parts = line.split(":", 4)
if len(parts) != 5:
- raise ValueError("Not enough fields in " + `line`)
+ raise ValueError("Not enough fields in %r" % line)
function, type, arg, refcount, comment = parts
if refcount == "null":
refcount = None
diff --git a/Doc/tools/sgmlconv/esistools.py b/Doc/tools/sgmlconv/esistools.py
index b9c029b08d..833fea171c 100644
--- a/Doc/tools/sgmlconv/esistools.py
+++ b/Doc/tools/sgmlconv/esistools.py
@@ -29,7 +29,7 @@ def decode(s):
n, s = s.split(";", 1)
r = r + unichr(int(n))
else:
- raise ValueError, "can't handle " + `s`
+ raise ValueError, "can't handle %r" % s
return r
@@ -220,8 +220,8 @@ class ESISReader(xml.sax.xmlreader.XMLReader):
return self._decl_handler
else:
- raise xml.sax.SAXNotRecognizedException("unknown property %s"
- % `property`)
+ raise xml.sax.SAXNotRecognizedException("unknown property %r"
+ % (property, ))
def setProperty(self, property, value):
if property == xml.sax.handler.property_lexical_handler:
diff --git a/Doc/tools/sgmlconv/latex2esis.py b/Doc/tools/sgmlconv/latex2esis.py
index 47739a6610..b30aaa5631 100755
--- a/Doc/tools/sgmlconv/latex2esis.py
+++ b/Doc/tools/sgmlconv/latex2esis.py
@@ -73,8 +73,8 @@ def popping(name, point, depth):
class _Stack(list):
def append(self, entry):
if not isinstance(entry, str):
- raise LaTeXFormatError("cannot push non-string on stack: "
- + `entry`)
+ raise LaTeXFormatError("cannot push non-string on stack: %r"
+ % (entry, ))
#dbgmsg("%s<%s>" % (" "*len(self.data), entry))
list.append(self, entry)
@@ -208,8 +208,8 @@ class Conversion:
m = _parameter_rx.match(line)
if not m:
raise LaTeXFormatError(
- "could not extract parameter %s for %s: %s"
- % (pentry.name, macroname, `line[:100]`))
+ "could not extract parameter %s for %s: %r"
+ % (pentry.name, macroname, line[:100]))
if entry.outputname:
self.dump_attr(pentry, m.group(1))
line = line[m.end():]
@@ -259,7 +259,7 @@ class Conversion:
opened = 1
stack.append(entry.name)
self.write("(%s\n" % entry.outputname)
- #dbgmsg("--- text: %s" % `pentry.text`)
+ #dbgmsg("--- text: %r" % pentry.text)
self.write("-%s\n" % encode(pentry.text))
elif pentry.type == "entityref":
self.write("&%s\n" % pentry.name)
@@ -326,8 +326,8 @@ class Conversion:
extra = ""
if len(line) > 100:
extra = "..."
- raise LaTeXFormatError("could not identify markup: %s%s"
- % (`line[:100]`, extra))
+ raise LaTeXFormatError("could not identify markup: %r%s"
+ % (line[:100], extra))
while stack:
entry = self.get_entry(stack[-1])
if entry.closes:
@@ -361,7 +361,7 @@ class Conversion:
def get_entry(self, name):
entry = self.table.get(name)
if entry is None:
- dbgmsg("get_entry(%s) failing; building default entry!" % `name`)
+ dbgmsg("get_entry(%r) failing; building default entry!" % (name, ))
# not defined; build a default entry:
entry = TableEntry(name)
entry.has_content = 1
@@ -486,7 +486,7 @@ class TableHandler(xml.sax.handler.ContentHandler):
def end_macro(self):
name = self.__current.name
if self.__table.has_key(name):
- raise ValueError("name %s already in use" % `name`)
+ raise ValueError("name %r already in use" % (name,))
self.__table[name] = self.__current
self.__current = None
diff --git a/Lib/BaseHTTPServer.py b/Lib/BaseHTTPServer.py
index 15e7525e0b..27ac513802 100644
--- a/Lib/BaseHTTPServer.py
+++ b/Lib/BaseHTTPServer.py
@@ -238,7 +238,7 @@ class BaseHTTPRequestHandler(SocketServer.StreamRequestHandler):
if len(words) == 3:
[command, path, version] = words
if version[:5] != 'HTTP/':
- self.send_error(400, "Bad request version (%s)" % `version`)
+ self.send_error(400, "Bad request version (%r)" % version)
return False
try:
base_version_number = version.split('/', 1)[1]
@@ -253,7 +253,7 @@ class BaseHTTPRequestHandler(SocketServer.StreamRequestHandler):
raise ValueError
version_number = int(version_number[0]), int(version_number[1])
except (ValueError, IndexError):
- self.send_error(400, "Bad request version (%s)" % `version`)
+ self.send_error(400, "Bad request version (%r)" % version)
return False
if version_number >= (1, 1) and self.protocol_version >= "HTTP/1.1":
self.close_connection = 0
@@ -266,12 +266,12 @@ class BaseHTTPRequestHandler(SocketServer.StreamRequestHandler):
self.close_connection = 1
if command != 'GET':
self.send_error(400,
- "Bad HTTP/0.9 request type (%s)" % `command`)
+ "Bad HTTP/0.9 request type (%r)" % command)
return False
elif not words:
return False
else:
- self.send_error(400, "Bad request syntax (%s)" % `requestline`)
+ self.send_error(400, "Bad request syntax (%r)" % requestline)
return False
self.command, self.path, self.request_version = command, path, version
@@ -302,7 +302,7 @@ class BaseHTTPRequestHandler(SocketServer.StreamRequestHandler):
return
mname = 'do_' + self.command
if not hasattr(self, mname):
- self.send_error(501, "Unsupported method (%s)" % `self.command`)
+ self.send_error(501, "Unsupported method (%r)" % self.command)
return
method = getattr(self, mname)
method()
diff --git a/Lib/Bastion.py b/Lib/Bastion.py
index ae2db74ca3..58cce978ce 100644
--- a/Lib/Bastion.py
+++ b/Lib/Bastion.py
@@ -124,7 +124,7 @@ def Bastion(object, filter = lambda name: name[:1] != '_',
return get1(name)
if name is None:
- name = `object`
+ name = repr(object)
return bastionclass(get2, name)
diff --git a/Lib/CGIHTTPServer.py b/Lib/CGIHTTPServer.py
index 7f481b7b3c..52e04e9902 100644
--- a/Lib/CGIHTTPServer.py
+++ b/Lib/CGIHTTPServer.py
@@ -117,21 +117,21 @@ class CGIHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
scriptname = dir + '/' + script
scriptfile = self.translate_path(scriptname)
if not os.path.exists(scriptfile):
- self.send_error(404, "No such CGI script (%s)" % `scriptname`)
+ self.send_error(404, "No such CGI script (%r)" % scriptname)
return
if not os.path.isfile(scriptfile):
- self.send_error(403, "CGI script is not a plain file (%s)" %
- `scriptname`)
+ self.send_error(403, "CGI script is not a plain file (%r)" %
+ scriptname)
return
ispy = self.is_python(scriptname)
if not ispy:
if not (self.have_fork or self.have_popen2 or self.have_popen3):
- self.send_error(403, "CGI script is not a Python script (%s)" %
- `scriptname`)
+ self.send_error(403, "CGI script is not a Python script (%r)" %
+ scriptname)
return
if not self.is_executable(scriptfile):
- self.send_error(403, "CGI script is not executable (%s)" %
- `scriptname`)
+ self.send_error(403, "CGI script is not executable (%r)" %
+ scriptname)
return
# Reference: http://hoohoo.ncsa.uiuc.edu/cgi/env.html
diff --git a/Lib/ConfigParser.py b/Lib/ConfigParser.py
index d98993af33..e12717dbf0 100644
--- a/Lib/ConfigParser.py
+++ b/Lib/ConfigParser.py
@@ -118,7 +118,7 @@ class NoSectionError(Error):
"""Raised when no section matches a requested option."""
def __init__(self, section):
- Error.__init__(self, 'No section: ' + `section`)
+ Error.__init__(self, 'No section: %r' % (section,))
self.section = section
class DuplicateSectionError(Error):
@@ -191,7 +191,7 @@ class MissingSectionHeaderError(ParsingError):
def __init__(self, filename, lineno, line):
Error.__init__(
self,
- 'File contains no section headers.\nfile: %s, line: %d\n%s' %
+ 'File contains no section headers.\nfile: %s, line: %d\n%r' %
(filename, lineno, line))
self.filename = filename
self.lineno = lineno
@@ -453,7 +453,7 @@ class RawConfigParser:
optname = None
# no section header in the file?
elif cursect is None:
- raise MissingSectionHeaderError(fpname, lineno, `line`)
+ raise MissingSectionHeaderError(fpname, lineno, line)
# an option line?
else:
mo = self.OPTCRE.match(line)
@@ -478,7 +478,7 @@ class RawConfigParser:
# list of all bogus lines
if not e:
e = ParsingError(fpname)
- e.append(lineno, `line`)
+ e.append(lineno, repr(line))
# if any parsing errors occurred, raise an exception
if e:
raise e
@@ -613,4 +613,4 @@ class SafeConfigParser(ConfigParser):
else:
raise InterpolationSyntaxError(
option, section,
- "'%' must be followed by '%' or '(', found: " + `rest`)
+ "'%%' must be followed by '%%' or '(', found: %r" % (rest,))
diff --git a/Lib/HTMLParser.py b/Lib/HTMLParser.py
index c082fde527..733458126b 100644
--- a/Lib/HTMLParser.py
+++ b/Lib/HTMLParser.py
@@ -272,8 +272,8 @@ class HTMLParser(markupbase.ParserBase):
- self.__starttag_text.rfind("\n")
else:
offset = offset + len(self.__starttag_text)
- self.error("junk characters in start tag: %s"
- % `rawdata[k:endpos][:20]`)
+ self.error("junk characters in start tag: %r"
+ % (rawdata[k:endpos][:20],))
if end.endswith('/>'):
# XHTML-style empty tag: <span attr="value" />
self.handle_startendtag(tag, attrs)
@@ -324,7 +324,7 @@ class HTMLParser(markupbase.ParserBase):
j = match.end()
match = endtagfind.match(rawdata, i) # </ + tag + >
if not match:
- self.error("bad end tag: %s" % `rawdata[i:j]`)
+ self.error("bad end tag: %r" % (rawdata[i:j],))
tag = match.group(1)
self.handle_endtag(tag.lower())
self.clear_cdata_mode()
@@ -368,7 +368,7 @@ class HTMLParser(markupbase.ParserBase):
pass
def unknown_decl(self, data):
- self.error("unknown declaration: " + `data`)
+ self.error("unknown declaration: %r" % (data,))
# Internal -- helper to remove special character quoting
def unescape(self, s):
diff --git a/Lib/StringIO.py b/Lib/StringIO.py
index 4739d1395d..f35054e800 100644
--- a/Lib/StringIO.py
+++ b/Lib/StringIO.py
@@ -222,10 +222,10 @@ def test():
f.seek(len(lines[0]))
f.write(lines[1])
f.seek(0)
- print 'First line =', `f.readline()`
+ print 'First line =', repr(f.readline())
print 'Position =', f.tell()
line = f.readline()
- print 'Second line =', `line`
+ print 'Second line =', repr(line)
f.seek(-len(line), 1)
line2 = f.read(len(line))
if line != line2:
diff --git a/Lib/aifc.py b/Lib/aifc.py
index 0275e42720..781d77cee4 100644
--- a/Lib/aifc.py
+++ b/Lib/aifc.py
@@ -392,7 +392,7 @@ class Aifc_read:
for marker in self._markers:
if id == marker[0]:
return marker
- raise Error, 'marker ' + `id` + ' does not exist'
+ raise Error, 'marker %r does not exist' % (id,)
def setpos(self, pos):
if pos < 0 or pos > self._nframes:
@@ -697,7 +697,7 @@ class Aifc_write:
for marker in self._markers:
if id == marker[0]:
return marker
- raise Error, 'marker ' + `id` + ' does not exist'
+ raise Error, 'marker %r does not exist' % (id,)
def getmarkers(self):
if len(self._markers) == 0:
diff --git a/Lib/atexit.py b/Lib/atexit.py
index 59d5cf37fe..85ccb248e4 100644
--- a/Lib/atexit.py
+++ b/Lib/atexit.py
@@ -40,9 +40,9 @@ if __name__ == "__main__":
def x1():
print "running x1"
def x2(n):
- print "running x2(%s)" % `n`
+ print "running x2(%r)" % (n,)
def x3(n, kwd=None):
- print "running x3(%s, kwd=%s)" % (`n`, `kwd`)
+ print "running x3(%r, kwd=%r)" % (n, kwd)
register(x1)
register(x2, 12)
diff --git a/Lib/base64.py b/Lib/base64.py
index 54ee623aac..f90b91d994 100755
--- a/Lib/base64.py
+++ b/Lib/base64.py
@@ -348,7 +348,7 @@ def test1():
s0 = "Aladdin:open sesame"
s1 = encodestring(s0)
s2 = decodestring(s1)
- print s0, `s1`, s2
+ print s0, repr(s1), s2
if __name__ == '__main__':
diff --git a/Lib/bdb.py b/Lib/bdb.py
index 45e9d038ef..11ed212f2b 100644
--- a/Lib/bdb.py
+++ b/Lib/bdb.py
@@ -52,7 +52,7 @@ class Bdb:
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
def dispatch_line(self, frame):
@@ -311,7 +311,7 @@ class Bdb:
import linecache, repr
frame, lineno = frame_lineno
filename = self.canonic(frame.f_code.co_filename)
- s = filename + '(' + `lineno` + ')'
+ s = '%s(%r)' % (filename, lineno)
if frame.f_code.co_name:
s = s + frame.f_code.co_name
else:
diff --git a/Lib/binhex.py b/Lib/binhex.py
index 5700659bf7..9735f2eda3 100644
--- a/Lib/binhex.py
+++ b/Lib/binhex.py
@@ -229,7 +229,7 @@ class BinHex:
def close_data(self):
if self.dlen != 0:
- raise Error, 'Incorrect data size, diff='+`self.rlen`
+ raise Error, 'Incorrect data size, diff=%r' % (self.rlen,)
self._writecrc()
self.state = _DID_DATA
@@ -248,7 +248,7 @@ class BinHex:
raise Error, 'Close at the wrong time'
if self.rlen != 0:
raise Error, \
- "Incorrect resource-datasize, diff="+`self.rlen`
+ "Incorrect resource-datasize, diff=%r" % (self.rlen,)
self._writecrc()
self.ofp.close()
self.state = None
diff --git a/Lib/bsddb/dbrecio.py b/Lib/bsddb/dbrecio.py
index 470fb419ab..22e382a39e 100644
--- a/Lib/bsddb/dbrecio.py
+++ b/Lib/bsddb/dbrecio.py
@@ -164,10 +164,10 @@ def _test():
f.seek(len(lines[0]))
f.write(lines[1])
f.seek(0)
- print 'First line =', `f.readline()`
+ print 'First line =', repr(f.readline())
here = f.tell()
line = f.readline()
- print 'Second line =', `line`
+ print 'Second line =', repr(line)
f.seek(-len(line), 1)
line2 = f.read(len(line))
if line != line2:
diff --git a/Lib/bsddb/dbtables.py b/Lib/bsddb/dbtables.py
index 6edfd29bce..e1d2c43884 100644
--- a/Lib/bsddb/dbtables.py
+++ b/Lib/bsddb/dbtables.py
@@ -206,7 +206,7 @@ class bsdTableDB :
try:
key, data = cur.first()
while 1:
- print `{key: data}`
+ print repr({key: data})
next = cur.next()
if next:
key, data = next
@@ -341,9 +341,9 @@ class bsdTableDB :
try:
tcolpickles = self.db.get(_columns_key(table))
except DBNotFoundError:
- raise TableDBError, "unknown table: " + `table`
+ raise TableDBError, "unknown table: %r" % (table,)
if not tcolpickles:
- raise TableDBError, "unknown table: " + `table`
+ raise TableDBError, "unknown table: %r" % (table,)
self.__tablecolumns[table] = pickle.loads(tcolpickles)
def __new_rowid(self, table, txn) :
@@ -384,7 +384,7 @@ class bsdTableDB :
self.__load_column_info(table)
for column in rowdict.keys() :
if not self.__tablecolumns[table].count(column):
- raise TableDBError, "unknown column: "+`column`
+ raise TableDBError, "unknown column: %r" % (column,)
# get a unique row identifier for this row
txn = self.env.txn_begin()
@@ -535,7 +535,7 @@ class bsdTableDB :
columns = self.tablecolumns[table]
for column in (columns + conditions.keys()):
if not self.__tablecolumns[table].count(column):
- raise TableDBError, "unknown column: "+`column`
+ raise TableDBError, "unknown column: %r" % (column,)
# keyed on rows that match so far, containings dicts keyed on
# column names containing the data for that row and column.
diff --git a/Lib/bsddb/test/test_associate.py b/Lib/bsddb/test/test_associate.py
index f810eb0146..fc92c2236a 100644
--- a/Lib/bsddb/test/test_associate.py
+++ b/Lib/bsddb/test/test_associate.py
@@ -200,7 +200,7 @@ class AssociateTestCase(unittest.TestCase):
def getGenre(self, priKey, priData):
assert type(priData) == type("")
if verbose:
- print 'getGenre key:', `priKey`, 'data:', `priData`
+ print 'getGenre key: %r data: %r' % (priKey, priData)
genre = string.split(priData, '|')[2]
if genre == 'Blues':
return db.DB_DONOTINDEX
@@ -242,7 +242,7 @@ class ShelveAssociateTestCase(AssociateTestCase):
def getGenre(self, priKey, priData):
assert type(priData) == type(())
if verbose:
- print 'getGenre key:', `priKey`, 'data:', `priData`
+ print 'getGenre key: %r data: %r' % (priKey, priData)
genre = priData[2]
if genre == 'Blues':
return db.DB_DONOTINDEX
diff --git a/Lib/bsddb/test/test_basics.py b/Lib/bsddb/test/test_basics.py
index d757b34185..da7e18f8ae 100644
--- a/Lib/bsddb/test/test_basics.py
+++ b/Lib/bsddb/test/test_basics.py
@@ -361,7 +361,7 @@ class BasicTestCase(unittest.TestCase):
if set_raises_error:
self.fail("expected exception")
if n != None:
- self.fail("expected None: "+`n`)
+ self.fail("expected None: %r" % (n,))
rec = c.get_both('0404', self.makeData('0404'))
assert rec == ('0404', self.makeData('0404'))
@@ -375,7 +375,7 @@ class BasicTestCase(unittest.TestCase):
if get_raises_error:
self.fail("expected exception")
if n != None:
- self.fail("expected None: "+`n`)
+ self.fail("expected None: %r" % (n,))
if self.d.get_type() == db.DB_BTREE:
rec = c.set_range('011')
@@ -548,7 +548,7 @@ class BasicTestCase(unittest.TestCase):
num = d.truncate()
assert num >= 1, "truncate returned <= 0 on non-empty database"
num = d.truncate()
- assert num == 0, "truncate on empty DB returned nonzero (%s)" % `num`
+ assert num == 0, "truncate on empty DB returned nonzero (%r)" % (num,)
#----------------------------------------------------------------------
@@ -674,7 +674,7 @@ class BasicTransactionTestCase(BasicTestCase):
num = d.truncate(txn)
assert num >= 1, "truncate returned <= 0 on non-empty database"
num = d.truncate(txn)
- assert num == 0, "truncate on empty DB returned nonzero (%s)" % `num`
+ assert num == 0, "truncate on empty DB returned nonzero (%r)" % (num,)
txn.commit()
#----------------------------------------
diff --git a/Lib/bsddb/test/test_dbtables.py b/Lib/bsddb/test/test_dbtables.py
index eb5758f94b..1128a5a44e 100644
--- a/Lib/bsddb/test/test_dbtables.py
+++ b/Lib/bsddb/test/test_dbtables.py
@@ -109,7 +109,7 @@ class TableDBTestCase(unittest.TestCase):
assert values[1]['Species'] == 'Penguin'
else :
if verbose:
- print "values=", `values`
+ print "values= %r" % (values,)
raise "Wrong values returned!"
def test03(self):
diff --git a/Lib/calendar.py b/Lib/calendar.py
index fb56826f6f..321059d055 100644
--- a/Lib/calendar.py
+++ b/Lib/calendar.py
@@ -151,9 +151,9 @@ def month(theyear, themonth, w=0, l=0):
"""Return a month's calendar string (multi-line)."""
w = max(2, w)
l = max(1, l)
- s = ((month_name[themonth] + ' ' + `theyear`).center(
- 7 * (w + 1) - 1).rstrip() +
- '\n' * l + weekheader(w).rstrip() + '\n' * l)
+ s = ("%s %r" % (month_name[themonth], theyear)).center(
+ 7 * (w + 1) - 1).rstrip() + \
+ '\n' * l + weekheader(w).rstrip() + '\n' * l
for aweek in monthcalendar(theyear, themonth):
s = s + week(aweek, w).rstrip() + '\n' * l
return s[:-l] + '\n'
@@ -181,7 +181,7 @@ def calendar(year, w=0, l=0, c=_spacing):
l = max(1, l)
c = max(2, c)
colwidth = (w + 1) * 7 - 1
- s = `year`.center(colwidth * 3 + c * 2).rstrip() + '\n' * l
+ s = repr(year).center(colwidth * 3 + c * 2).rstrip() + '\n' * l
header = weekheader(w)
header = format3cstring(header, header, header, colwidth, c).rstrip()
for q in range(January, January+12, 3):
diff --git a/Lib/cgi.py b/Lib/cgi.py
index ac7192b84f..2576e75aaf 100755
--- a/Lib/cgi.py
+++ b/Lib/cgi.py
@@ -212,7 +212,7 @@ def parse_qsl(qs, keep_blank_values=0, strict_parsing=0):
nv = name_value.split('=', 1)
if len(nv) != 2:
if strict_parsing:
- raise ValueError, "bad query field: %s" % `name_value`
+ raise ValueError, "bad query field: %r" % (name_value,)
continue
if len(nv[1]) or keep_blank_values:
name = urllib.unquote(nv[0].replace('+', ' '))
@@ -247,8 +247,8 @@ def parse_multipart(fp, pdict):
if 'boundary' in pdict:
boundary = pdict['boundary']
if not valid_boundary(boundary):
- raise ValueError, ('Invalid boundary in multipart form: %s'
- % `boundary`)
+ raise ValueError, ('Invalid boundary in multipart form: %r'
+ % (boundary,))
nextpart = "--" + boundary
lastpart = "--" + boundary + "--"
@@ -361,7 +361,7 @@ class MiniFieldStorage:
def __repr__(self):
"""Return printable representation."""
- return "MiniFieldStorage(%s, %s)" % (`self.name`, `self.value`)
+ return "MiniFieldStorage(%r, %r)" % (self.name, self.value)
class FieldStorage:
@@ -522,8 +522,8 @@ class FieldStorage:
def __repr__(self):
"""Return a printable representation."""
- return "FieldStorage(%s, %s, %s)" % (
- `self.name`, `self.filename`, `self.value`)
+ return "FieldStorage(%r, %r, %r)" % (
+ self.name, self.filename, self.value)
def __iter__(self):
return iter(self.keys())
@@ -632,8 +632,7 @@ class FieldStorage:
"""Internal: read a part that is itself multipart."""
ib = self.innerboundary
if not valid_boundary(ib):
- raise ValueError, ('Invalid boundary in multipart form: %s'
- % `ib`)
+ raise ValueError, 'Invalid boundary in multipart form: %r' % (ib,)
self.list = []
klass = self.FieldStorageClass or self.__class__
part = klass(self.fp, {}, ib,
@@ -957,8 +956,8 @@ def print_form(form):
for key in keys:
print "<DT>" + escape(key) + ":",
value = form[key]
- print "<i>" + escape(`type(value)`) + "</i>"
- print "<DD>" + escape(`value`)
+ print "<i>" + escape(repr(type(value))) + "</i>"
+ print "<DD>" + escape(repr(value))
print "</DL>"
print
diff --git a/Lib/difflib.py b/Lib/difflib.py
index 699845c0d1..c074b19065 100644
--- a/Lib/difflib.py
+++ b/Lib/difflib.py
@@ -689,9 +689,9 @@ def get_close_matches(word, possibilities, n=3, cutoff=0.6):
"""
if not n > 0:
- raise ValueError("n must be > 0: " + `n`)
+ raise ValueError("n must be > 0: %r" % (n,))
if not 0.0 <= cutoff <= 1.0:
- raise ValueError("cutoff must be in [0.0, 1.0]: " + `cutoff`)
+ raise ValueError("cutoff must be in [0.0, 1.0]: %r" % (cutoff,))
result = []
s = SequenceMatcher()
s.set_seq2(word)
@@ -876,7 +876,7 @@ class Differ:
elif tag == 'equal':
g = self._dump(' ', a, alo, ahi)
else:
- raise ValueError, 'unknown tag ' + `tag`
+ raise ValueError, 'unknown tag %r' % (tag,)
for line in g:
yield line
@@ -988,7 +988,7 @@ class Differ:
atags += ' ' * la
btags += ' ' * lb
else:
- raise ValueError, 'unknown tag ' + `tag`
+ raise ValueError, 'unknown tag %r' % (tag,)
for line in self._qformat(aelt, belt, atags, btags):
yield line
else:
diff --git a/Lib/dis.py b/Lib/dis.py
index 3208011ea9..5a74b3ae89 100644
--- a/Lib/dis.py
+++ b/Lib/dis.py
@@ -80,7 +80,7 @@ def disassemble(co, lasti=-1):
else: print ' ',
if i in labels: print '>>',
else: print ' ',
- print `i`.rjust(4),
+ print repr(i).rjust(4),
print opname[op].ljust(20),
i = i+1
if op >= HAVE_ARGUMENT:
@@ -89,13 +89,13 @@ def disassemble(co, lasti=-1):
i = i+2
if op == EXTENDED_ARG:
extended_arg = oparg*65536L
- print `oparg`.rjust(5),
+ print repr(oparg).rjust(5),
if op in hasconst:
- print '(' + `co.co_consts[oparg]` + ')',
+ print '(' + repr(co.co_consts[oparg]) + ')',
elif op in hasname:
print '(' + co.co_names[oparg] + ')',
elif op in hasjrel:
- print '(to ' + `i + oparg` + ')',
+ print '(to ' + repr(i + oparg) + ')',
elif op in haslocal:
print '(' + co.co_varnames[oparg] + ')',
elif op in hascompare:
@@ -118,16 +118,16 @@ def disassemble_string(code, lasti=-1, varnames=None, names=None,
else: print ' ',
if i in labels: print '>>',
else: print ' ',
- print `i`.rjust(4),
+ print repr(i).rjust(4),
print opname[op].ljust(15),
i = i+1
if op >= HAVE_ARGUMENT:
oparg = ord(code[i]) + ord(code[i+1])*256
i = i+2
- print `oparg`.rjust(5),
+ print repr(oparg).rjust(5),
if op in hasconst:
if constants:
- print '(' + `constants[oparg]` + ')',
+ print '(' + repr(constants[oparg]) + ')',
else:
print '(%d)'%oparg,
elif op in hasname:
@@ -136,7 +136,7 @@ def disassemble_string(code, lasti=-1, varnames=None, names=None,
else:
print '(%d)'%oparg,
elif op in hasjrel:
- print '(to ' + `i + oparg` + ')',
+ print '(to ' + repr(i + oparg) + ')',
elif op in haslocal:
if varnames:
print '(' + varnames[oparg] + ')',
diff --git a/Lib/distutils/cmd.py b/Lib/distutils/cmd.py
index 6e44221eb5..fef49390da 100644
--- a/Lib/distutils/cmd.py
+++ b/Lib/distutils/cmd.py
@@ -253,8 +253,8 @@ class Command:
if not ok:
raise DistutilsOptionError, \
- "'%s' must be a list of strings (got %s)" % \
- (option, `val`)
+ "'%s' must be a list of strings (got %r)" % \
+ (option, val)
def _ensure_tested_string (self, option, tester,
what, error_fmt, default=None):
diff --git a/Lib/distutils/core.py b/Lib/distutils/core.py
index a463272c2f..eb419721e4 100644
--- a/Lib/distutils/core.py
+++ b/Lib/distutils/core.py
@@ -202,7 +202,7 @@ def run_setup (script_name, script_args=None, stop_after="run"):
used to drive the Distutils.
"""
if stop_after not in ('init', 'config', 'commandline', 'run'):
- raise ValueError, "invalid value for 'stop_after': %s" % `stop_after`
+ raise ValueError, "invalid value for 'stop_after': %r" % (stop_after,)
global _setup_stop_after, _setup_distribution
_setup_stop_after = stop_after
diff --git a/Lib/distutils/dir_util.py b/Lib/distutils/dir_util.py
index bd1ea0f243..e479b62415 100644
--- a/Lib/distutils/dir_util.py
+++ b/Lib/distutils/dir_util.py
@@ -33,7 +33,7 @@ def mkpath (name, mode=0777, verbose=0, dry_run=0):
# Detect a common bug -- name is None
if type(name) is not StringType:
raise DistutilsInternalError, \
- "mkpath: 'name' must be a string (got %s)" % `name`
+ "mkpath: 'name' must be a string (got %r)" % (name,)
# XXX what's the better way to handle verbosity? print as we create
# each directory in the path (the current behaviour), or only announce
diff --git a/Lib/distutils/dist.py b/Lib/distutils/dist.py
index d313e7d116..f63ea97331 100644
--- a/Lib/distutils/dist.py
+++ b/Lib/distutils/dist.py
@@ -525,9 +525,9 @@ class Distribution:
func()
else:
raise DistutilsClassError(
- "invalid help function %s for help option '%s': "
+ "invalid help function %r for help option '%s': "
"must be a callable object (function, etc.)"
- % (`func`, help_option))
+ % (func, help_option))
if help_option_found:
return
diff --git a/Lib/distutils/fancy_getopt.py b/Lib/distutils/fancy_getopt.py
index a4a4e7979e..512bc9b665 100644
--- a/Lib/distutils/fancy_getopt.py
+++ b/Lib/distutils/fancy_getopt.py
@@ -162,7 +162,7 @@ class FancyGetopt:
else:
# the option table is part of the code, so simply
# assert that it is correct
- assert "invalid option tuple: %s" % `option`
+ assert "invalid option tuple: %r" % (option,)
# Type- and value-check the option names
if type(long) is not StringType or len(long) < 2:
diff --git a/Lib/distutils/util.py b/Lib/distutils/util.py
index dc3183b691..8c3c8df979 100644
--- a/Lib/distutils/util.py
+++ b/Lib/distutils/util.py
@@ -285,7 +285,7 @@ def execute (func, args, msg=None, verbose=0, dry_run=0):
print.
"""
if msg is None:
- msg = "%s%s" % (func.__name__, `args`)
+ msg = "%s%r" % (func.__name__, args)
if msg[-2:] == ',)': # correct for singleton tuple
msg = msg[0:-2] + ')'
@@ -307,7 +307,7 @@ def strtobool (val):
elif val in ('n', 'no', 'f', 'false', 'off', '0'):
return 0
else:
- raise ValueError, "invalid truth value %s" % `val`
+ raise ValueError, "invalid truth value %r" % (val,)
def byte_compile (py_files,
@@ -394,11 +394,11 @@ files = [
script.write(string.join(map(repr, py_files), ",\n") + "]\n")
script.write("""
-byte_compile(files, optimize=%s, force=%s,
- prefix=%s, base_dir=%s,
- verbose=%s, dry_run=0,
+byte_compile(files, optimize=%r, force=%r,
+ prefix=%r, base_dir=%r,
+ verbose=%r, dry_run=0,
direct=1)
-""" % (`optimize`, `force`, `prefix`, `base_dir`, `verbose`))
+""" % (optimize, force, prefix, base_dir, verbose))
script.close()
@@ -432,8 +432,8 @@ byte_compile(files, optimize=%s, force=%s,
if prefix:
if file[:len(prefix)] != prefix:
raise ValueError, \
- ("invalid prefix: filename %s doesn't start with %s"
- % (`file`, `prefix`))
+ ("invalid prefix: filename %r doesn't start with %r"
+ % (file, prefix))
dfile = dfile[len(prefix):]
if base_dir:
dfile = os.path.join(base_dir, dfile)
diff --git a/Lib/doctest.py b/Lib/doctest.py
index caac69135d..5020684645 100644
--- a/Lib/doctest.py
+++ b/Lib/doctest.py
@@ -334,8 +334,8 @@ def _extract_examples(s):
continue
lineno = i - 1
if line[j] != " ":
- raise ValueError("line " + `lineno` + " of docstring lacks "
- "blank after " + PS1 + ": " + line)
+ raise ValueError("line %r of docstring lacks blank after %s: %s" %
+ (lineno, PS1, line))
j = j + 1
blanks = m.group(1)
nblanks = len(blanks)
@@ -348,7 +348,7 @@ def _extract_examples(s):
if m:
if m.group(1) != blanks:
raise ValueError("inconsistent leading whitespace "
- "in line " + `i` + " of docstring: " + line)
+ "in line %r of docstring: %s" % (i, line))
i = i + 1
else:
break
@@ -367,7 +367,7 @@ def _extract_examples(s):
while 1:
if line[:nblanks] != blanks:
raise ValueError("inconsistent leading whitespace "
- "in line " + `i` + " of docstring: " + line)
+ "in line %r of docstring: %s" % (i, line))
expect.append(line[nblanks:])
i = i + 1
line = lines[i]
@@ -475,7 +475,7 @@ def _run_examples_inner(out, fakeout, examples, globs, verbose, name,
failures = failures + 1
out("*" * 65 + "\n")
_tag_out(out, ("Failure in example", source))
- out("from line #" + `lineno` + " of " + name + "\n")
+ out("from line #%r of %s\n" % (lineno, name))
if state == FAIL:
_tag_out(out, ("Expected", want or NADA), ("Got", got))
else:
@@ -686,8 +686,7 @@ See doctest.testmod docs for the meaning of optionflags.
if mod is None and globs is None:
raise TypeError("Tester.__init__: must specify mod or globs")
if mod is not None and not _ismodule(mod):
- raise TypeError("Tester.__init__: mod must be a module; " +
- `mod`)
+ raise TypeError("Tester.__init__: mod must be a module; %r" % (mod,))
if globs is None:
globs = mod.__dict__
self.globs = globs
@@ -775,7 +774,7 @@ See doctest.testmod docs for the meaning of optionflags.
name = object.__name__
except AttributeError:
raise ValueError("Tester.rundoc: name must be given "
- "when object.__name__ doesn't exist; " + `object`)
+ "when object.__name__ doesn't exist; %r" % (object,))
if self.verbose:
print "Running", name + ".__doc__"
f, t = run_docstring_examples(object, self.globs, self.verbose, name,
@@ -893,8 +892,7 @@ See doctest.testmod docs for the meaning of optionflags.
"""
if not hasattr(d, "items"):
- raise TypeError("Tester.rundict: d must support .items(); " +
- `d`)
+ raise TypeError("Tester.rundict: d must support .items(); %r" % (d,))
f = t = 0
# Run the tests by alpha order of names, for consistency in
# verbose-mode output.
@@ -936,7 +934,7 @@ See doctest.testmod docs for the meaning of optionflags.
else:
raise TypeError("Tester.run__test__: values in "
"dict must be strings, functions, methods, "
- "or classes; " + `v`)
+ "or classes; %r" % (v,))
failures = failures + f
tries = tries + t
finally:
@@ -1139,7 +1137,7 @@ def testmod(m=None, name=None, globs=None, verbose=None, isprivate=None,
m = sys.modules.get('__main__')
if not _ismodule(m):
- raise TypeError("testmod: module required; " + `m`)
+ raise TypeError("testmod: module required; %r" % (m,))
if name is None:
name = m.__name__
tester = Tester(m, globs=globs, verbose=verbose, isprivate=isprivate,
@@ -1153,7 +1151,7 @@ def testmod(m=None, name=None, globs=None, verbose=None, isprivate=None,
if testdict:
if not hasattr(testdict, "items"):
raise TypeError("testmod: module.__test__ must support "
- ".items(); " + `testdict`)
+ ".items(); %r" % (testdict,))
f, t = tester.run__test__(testdict, name + ".__test__")
failures += f
tries += t
diff --git a/Lib/formatter.py b/Lib/formatter.py
index 3868b1b6b6..109d66cac6 100644
--- a/Lib/formatter.py
+++ b/Lib/formatter.py
@@ -325,22 +325,22 @@ class AbstractWriter(NullWriter):
"""
def new_alignment(self, align):
- print "new_alignment(%s)" % `align`
+ print "new_alignment(%r)" % (align,)
def new_font(self, font):
- print "new_font(%s)" % `font`
+ print "new_font(%r)" % (font,)
def new_margin(self, margin, level):
- print "new_margin(%s, %d)" % (`margin`, level)
+ print "new_margin(%r, %d)" % (margin, level)
def new_spacing(self, spacing):
- print "new_spacing(%s)" % `spacing`
+ print "new_spacing(%r)" % (spacing,)
def new_styles(self, styles):
- print "new_styles(%s)" % `styles`
+ print "new_styles(%r)" % (styles,)
def send_paragraph(self, blankline):
- print "send_paragraph(%s)" % `blankline`
+ print "send_paragraph(%r)" % (blankline,)
def send_line_break(self):
print "send_line_break()"
@@ -349,13 +349,13 @@ class AbstractWriter(NullWriter):
print "send_hor_rule()"
def send_label_data(self, data):
- print "send_label_data(%s)" % `data`
+ print "send_label_data(%r)" % (data,)
def send_flowing_data(self, data):
- print "send_flowing_data(%s)" % `data`
+ print "send_flowing_data(%r)" % (data,)
def send_literal_data(self, data):
- print "send_literal_data(%s)" % `data`
+ print "send_literal_data(%r)" % (data,)
class DumbWriter(NullWriter):
diff --git a/Lib/fpformat.py b/Lib/fpformat.py
index 7319e2ae30..0ae86a913f 100644
--- a/Lib/fpformat.py
+++ b/Lib/fpformat.py
@@ -88,7 +88,7 @@ def fix(x, digs):
"""Format x as [-]ddd.ddd with 'digs' digits after the point
and at least one digit before.
If digs <= 0, the point is suppressed."""
- if type(x) != type(''): x = `x`
+ if type(x) != type(''): x = repr(x)
try:
sign, intpart, fraction, expo = extract(x)
except NotANumber:
@@ -104,7 +104,7 @@ def sci(x, digs):
"""Format x as [-]d.dddE[+-]ddd with 'digs' digits after the point
and exactly one digit before.
If digs is <= 0, one digit is kept and the point is suppressed."""
- if type(x) != type(''): x = `x`
+ if type(x) != type(''): x = repr(x)
sign, intpart, fraction, expo = extract(x)
if not intpart:
while fraction and fraction[0] == '0':
@@ -126,7 +126,7 @@ def sci(x, digs):
expo + len(intpart) - 1
s = sign + intpart
if digs > 0: s = s + '.' + fraction
- e = `abs(expo)`
+ e = repr(abs(expo))
e = '0'*(3-len(e)) + e
if expo < 0: e = '-' + e
else: e = '+' + e
diff --git a/Lib/ftplib.py b/Lib/ftplib.py
index d67a0aa8cc..9486918fdc 100644
--- a/Lib/ftplib.py
+++ b/Lib/ftplib.py
@@ -161,7 +161,7 @@ class FTP:
while i > 5 and s[i-1] in '\r\n':
i = i-1
s = s[:5] + '*'*(i-5) + s[i:]
- return `s`
+ return repr(s)
# Internal: send one line to the server, appending CRLF
def putline(self, line):
@@ -250,7 +250,7 @@ class FTP:
port number.
'''
hbytes = host.split('.')
- pbytes = [`port/256`, `port%256`]
+ pbytes = [repr(port/256), repr(port%256)]
bytes = hbytes + pbytes
cmd = 'PORT ' + ','.join(bytes)
return self.voidcmd(cmd)
@@ -264,7 +264,7 @@ class FTP:
af = 2
if af == 0:
raise error_proto, 'unsupported address family'
- fields = ['', `af`, host, `port`, '']
+ fields = ['', repr(af), host, repr(port), '']
cmd = 'EPRT ' + '|'.join(fields)
return self.voidcmd(cmd)
@@ -397,7 +397,7 @@ class FTP:
fp = conn.makefile('rb')
while 1:
line = fp.readline()
- if self.debugging > 2: print '*retr*', `line`
+ if self.debugging > 2: print '*retr*', repr(line)
if not line:
break
if line[-2:] == CRLF:
diff --git a/Lib/gopherlib.py b/Lib/gopherlib.py
index 03801d0b34..01eab0a3d9 100644
--- a/Lib/gopherlib.py
+++ b/Lib/gopherlib.py
@@ -47,7 +47,7 @@ def type_to_name(gtype):
_type_to_name_map[eval(name)] = name[2:]
if gtype in _type_to_name_map:
return _type_to_name_map[gtype]
- return 'TYPE=' + `gtype`
+ return 'TYPE=%r' % (gtype,)
# Names for characters and strings
CRLF = '\r\n'
@@ -113,7 +113,7 @@ def get_directory(f):
gtype = line[0]
parts = line[1:].split(TAB)
if len(parts) < 4:
- print '(Bad line from server:', `line`, ')'
+ print '(Bad line from server: %r)' % (line,)
continue
if len(parts) > 4:
if parts[4:] != ['+']:
@@ -198,7 +198,7 @@ def test():
for item in entries: print item
else:
data = get_binary(f)
- print 'binary data:', len(data), 'bytes:', `data[:100]`[:40]
+ print 'binary data:', len(data), 'bytes:', repr(data[:100])[:40]
# Run the test when run as script
if __name__ == '__main__':
diff --git a/Lib/gzip.py b/Lib/gzip.py
index a5d4087f8e..d51b7dbe8d 100644
--- a/Lib/gzip.py
+++ b/Lib/gzip.py
@@ -442,7 +442,7 @@ def _test():
g = sys.stdout
else:
if arg[-3:] != ".gz":
- print "filename doesn't end in .gz:", `arg`
+ print "filename doesn't end in .gz:", repr(arg)
continue
f = open(arg, "rb")
g = __builtin__.open(arg[:-3], "wb")
diff --git a/Lib/idlelib/ColorDelegator.py b/Lib/idlelib/ColorDelegator.py
index d72d90c96e..7b7be228cc 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 0f0961cd75..65ffe54afd 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 4e08e705d6..198055a2f1 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 79fad31a74..ab136bc112 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 416be5a15f..a2a6cee498 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 bd4e0776eb..407f4686cc 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 060528512f..c619b7fce7 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 bdcef51c04..74085c36f5 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 c0fa88f426..a1d937ba0a 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 824bdca1fb..1c9eb2ef14 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 2452a98a5c..182a1170e8 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 be74668f95..df60cea4f5 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 3d2bcf694d..c1210612e6 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 8c3eb3eb5a..4e4e564cb6 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 3d79fb9b3a..d1c2b3c5f8 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 d3a9fd8e68..d097f9b100 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 be3ade02a0..917a6cc0c0 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())
diff --git a/Lib/ihooks.py b/Lib/ihooks.py
index 19faac9d26..936a950de0 100644
--- a/Lib/ihooks.py
+++ b/Lib/ihooks.py
@@ -273,8 +273,8 @@ class ModuleLoader(BasicModuleLoader):
elif type == PKG_DIRECTORY:
m = self.hooks.load_package(name, filename, file)
else:
- raise ImportError, "Unrecognized module type (%s) for %s" % \
- (`type`, name)
+ raise ImportError, "Unrecognized module type (%r) for %s" % \
+ (type, name)
finally:
if file: file.close()
m.__file__ = filename
@@ -299,8 +299,8 @@ class FancyModuleLoader(ModuleLoader):
if inittype not in (PY_COMPILED, PY_SOURCE):
if initfile: initfile.close()
raise ImportError, \
- "Bad type (%s) for __init__ module in package %s" % (
- `inittype`, name)
+ "Bad type (%r) for __init__ module in package %s" % (
+ inittype, name)
path = [filename]
file = initfile
realfilename = initfilename
diff --git a/Lib/imaplib.py b/Lib/imaplib.py
index 80049828ed..0112ddc484 100644
--- a/Lib/imaplib.py
+++ b/Lib/imaplib.py
@@ -192,7 +192,7 @@ class IMAP4:
if __debug__:
if self.debug >= 3:
- self._mesg('CAPABILITIES: %s' % `self.capabilities`)
+ self._mesg('CAPABILITIES: %r' % (self.capabilities,))
for version in AllowedVersions:
if not version in self.capabilities:
@@ -972,7 +972,7 @@ class IMAP4:
self.mo = cre.match(s)
if __debug__:
if self.mo is not None and self.debug >= 5:
- self._mesg("\tmatched r'%s' => %s" % (cre.pattern, `self.mo.groups()`))
+ self._mesg("\tmatched r'%s' => %r" % (cre.pattern, self.mo.groups()))
return self.mo is not None
@@ -1416,7 +1416,7 @@ if __name__ == '__main__':
if M.state == 'AUTH':
test_seq1 = test_seq1[1:] # Login not needed
M._mesg('PROTOCOL_VERSION = %s' % M.PROTOCOL_VERSION)
- M._mesg('CAPABILITIES = %s' % `M.capabilities`)
+ M._mesg('CAPABILITIES = %r' % (M.capabilities,))
for cmd,args in test_seq1:
run(cmd, args)
diff --git a/Lib/lib-tk/FileDialog.py b/Lib/lib-tk/FileDialog.py
index 323dc29704..5e848daa73 100644
--- a/Lib/lib-tk/FileDialog.py
+++ b/Lib/lib-tk/FileDialog.py
@@ -244,7 +244,7 @@ class SaveFileDialog(FileDialog):
return
d = Dialog(self.top,
title="Overwrite Existing File Question",
- text="Overwrite existing file %s?" % `file`,
+ text="Overwrite existing file %r?" % (file,),
bitmap='questhead',
default=1,
strings=("Yes", "Cancel"))
diff --git a/Lib/lib-tk/Tix.py b/Lib/lib-tk/Tix.py
index 99731cdcbf..91145386d3 100755
--- a/Lib/lib-tk/Tix.py
+++ b/Lib/lib-tk/Tix.py
@@ -374,9 +374,9 @@ class TixWidget(Tkinter.Widget):
if option == '':
return
elif not isinstance(option, StringType):
- option = `option`
+ option = repr(option)
if not isinstance(value, StringType):
- value = `value`
+ value = repr(value)
names = self._subwidget_names()
for name in names:
self.tk.call(name, 'configure', '-' + option, value)
diff --git a/Lib/lib-tk/Tkinter.py b/Lib/lib-tk/Tkinter.py
index b5b0af3a9f..67e942e18a 100644
--- a/Lib/lib-tk/Tkinter.py
+++ b/Lib/lib-tk/Tkinter.py
@@ -177,7 +177,7 @@ class Variable:
master = _default_root
self._master = master
self._tk = master.tk
- self._name = 'PY_VAR' + `_varnum`
+ self._name = 'PY_VAR' + repr(_varnum)
_varnum = _varnum + 1
self.set(self._default)
def __del__(self):
@@ -1022,7 +1022,7 @@ class Misc:
be executed. An optional function SUBST can
be given which will be executed before FUNC."""
f = CallWrapper(func, subst, self).__call__
- name = `id(f)`
+ name = repr(id(f))
try:
func = func.im_func
except AttributeError:
@@ -1810,7 +1810,7 @@ class BaseWidget(Misc):
name = cnf['name']
del cnf['name']
if not name:
- name = `id(self)`
+ name = repr(id(self))
self._name = name
if master._w=='.':
self._w = '.' + name
@@ -1957,9 +1957,9 @@ def AtSelLast():
return 'sel.last'
def At(x, y=None):
if y is None:
- return '@' + `x`
+ return '@%r' % (x,)
else:
- return '@' + `x` + ',' + `y`
+ return '@%r,%r' % (x, y)
class Canvas(Widget):
"""Canvas widget to display graphical elements like lines or text."""
@@ -3118,7 +3118,7 @@ class Image:
self.tk = master.tk
if not name:
Image._last_id += 1
- name = "pyimage" +`Image._last_id` # tk itself would use image<x>
+ name = "pyimage%r" % (Image._last_id,) # tk itself would use image<x>
# The following is needed for systems where id(x)
# can return a negative number, such as Linux/m68k:
if name[0] == '-': name = '_' + name[1:]
diff --git a/Lib/lib-tk/turtle.py b/Lib/lib-tk/turtle.py
index b56d91c83f..a395613c7a 100644
--- a/Lib/lib-tk/turtle.py
+++ b/Lib/lib-tk/turtle.py
@@ -95,18 +95,18 @@ class RawPen:
try:
id = self._canvas.create_line(0, 0, 0, 0, fill=color)
except Tkinter.TclError:
- raise Error, "bad color string: %s" % `color`
+ raise Error, "bad color string: %r" % (color,)
self._set_color(color)
return
try:
r, g, b = color
except:
- raise Error, "bad color sequence: %s" % `color`
+ raise Error, "bad color sequence: %r" % (color,)
else:
try:
r, g, b = args
except:
- raise Error, "bad color arguments: %s" % `args`
+ raise Error, "bad color arguments: %r" % (args,)
assert 0 <= r <= 1
assert 0 <= g <= 1
assert 0 <= b <= 1
@@ -240,12 +240,12 @@ class RawPen:
try:
x, y = args[0]
except:
- raise Error, "bad point argument: %s" % `args[0]`
+ raise Error, "bad point argument: %r" % (args[0],)
else:
try:
x, y = args
except:
- raise Error, "bad coordinates: %s" % `args[0]`
+ raise Error, "bad coordinates: %r" % (args[0],)
x0, y0 = self._origin
self._goto(x0+x, y0-y)
diff --git a/Lib/macurl2path.py b/Lib/macurl2path.py
index 3c1acc02b7..ed23883cfd 100644
--- a/Lib/macurl2path.py
+++ b/Lib/macurl2path.py
@@ -80,7 +80,7 @@ def test():
"/foo/bar/index.html",
"/foo/bar/",
"/"]:
- print `url`, '->', `url2pathname(url)`
+ print '%r -> %r' % (url, url2pathname(url))
for path in ["drive:",
"drive:dir:",
"drive:dir:file",
@@ -89,7 +89,7 @@ def test():
":file",
":dir:",
":dir:file"]:
- print `path`, '->', `pathname2url(path)`
+ print '%r -> %r' % (path, pathname2url(path))
if __name__ == '__main__':
test()
diff --git a/Lib/markupbase.py b/Lib/markupbase.py
index 62587e0883..c1e5acdcf1 100644
--- a/Lib/markupbase.py
+++ b/Lib/markupbase.py
@@ -124,7 +124,7 @@ class ParserBase:
self.error("unexpected '[' char in declaration")
else:
self.error(
- "unexpected %s char in declaration" % `rawdata[j]`)
+ "unexpected %r char in declaration" % rawdata[j])
if j < 0:
return j
return -1 # incomplete
@@ -144,7 +144,7 @@ class ParserBase:
# look for MS Office ]> ending
match= _msmarkedsectionclose.search(rawdata, i+3)
else:
- self.error('unknown status keyword %s in marked section' % `rawdata[i+3:j]`)
+ self.error('unknown status keyword %r in marked section' % rawdata[i+3:j])
if not match:
return -1
if report:
@@ -180,8 +180,7 @@ class ParserBase:
return -1
if s != "<!":
self.updatepos(declstartpos, j + 1)
- self.error("unexpected char in internal subset (in %s)"
- % `s`)
+ self.error("unexpected char in internal subset (in %r)" % s)
if (j + 2) == n:
# end of buffer; incomplete
return -1
@@ -199,7 +198,7 @@ class ParserBase:
if name not in ("attlist", "element", "entity", "notation"):
self.updatepos(declstartpos, j + 2)
self.error(
- "unknown declaration %s in internal subset" % `name`)
+ "unknown declaration %r in internal subset" % name)
# handle the individual names
meth = getattr(self, "_parse_doctype_" + name)
j = meth(j, declstartpos)
@@ -230,7 +229,7 @@ class ParserBase:
j = j + 1
else:
self.updatepos(declstartpos, j)
- self.error("unexpected char %s in internal subset" % `c`)
+ self.error("unexpected char %r in internal subset" % c)
# end of buffer reached
return -1
diff --git a/Lib/mhlib.py b/Lib/mhlib.py
index 899939a493..0a8c444f2c 100644
--- a/Lib/mhlib.py
+++ b/Lib/mhlib.py
@@ -109,7 +109,7 @@ class MH:
def __repr__(self):
"""String representation."""
- return 'MH(%s, %s)' % (`self.path`, `self.profile`)
+ return 'MH(%r, %r)' % (self.path, self.profile)
def error(self, msg, *args):
"""Routine to print an error. May be overridden by a derived class."""
@@ -247,7 +247,7 @@ class Folder:
def __repr__(self):
"""String representation."""
- return 'Folder(%s, %s)' % (`self.mh`, `self.name`)
+ return 'Folder(%r, %r)' % (self.mh, self.name)
def error(self, *args):
"""Error message handler."""
@@ -716,7 +716,7 @@ class Message(mimetools.Message):
mf.push(bdry)
parts = []
while mf.next():
- n = str(self.number) + '.' + `1 + len(parts)`
+ n = "%s.%r" % (self.number, 1 + len(parts))
part = SubMessage(self.folder, n, mf)
parts.append(part)
mf.pop()
@@ -800,8 +800,7 @@ class IntSet:
return hash(self.pairs)
def __repr__(self):
- return 'IntSet(%s, %s, %s)' % (`self.tostring()`,
- `self.sep`, `self.rng`)
+ return 'IntSet(%r, %r, %r)' % (self.tostring(), self.sep, self.rng)
def normalize(self):
self.pairs.sort()
@@ -817,8 +816,8 @@ class IntSet:
def tostring(self):
s = ''
for lo, hi in self.pairs:
- if lo == hi: t = `lo`
- else: t = `lo` + self.rng + `hi`
+ if lo == hi: t = repr(lo)
+ else: t = repr(lo) + self.rng + repr(hi)
if s: s = s + (self.sep + t)
else: s = t
return s
@@ -963,7 +962,7 @@ def test():
testfolders = ['@test', '@test/test1', '@test/test2',
'@test/test1/test11', '@test/test1/test12',
'@test/test1/test11/test111']
- for t in testfolders: do('mh.makefolder(%s)' % `t`)
+ for t in testfolders: do('mh.makefolder(%r)' % (t,))
do('mh.listsubfolders(\'@test\')')
do('mh.listallsubfolders(\'@test\')')
f = mh.openfolder('@test')
@@ -975,7 +974,7 @@ def test():
print seqs
f.putsequences(seqs)
do('f.getsequences()')
- for t in reversed(testfolders): do('mh.deletefolder(%s)' % `t`)
+ for t in reversed(testfolders): do('mh.deletefolder(%r)' % (t,))
do('mh.getcontext()')
context = mh.getcontext()
f = mh.openfolder(context)
@@ -986,10 +985,10 @@ def test():
'1:3', '1:-3', '100:3', '100:-3', '10000:3', '10000:-3',
'all']:
try:
- do('f.parsesequence(%s)' % `seq`)
+ do('f.parsesequence(%r)' % (seq,))
except Error, msg:
print "Error:", msg
- stuff = os.popen("pick %s 2>/dev/null" % `seq`).read()
+ stuff = os.popen("pick %r 2>/dev/null" % (seq,)).read()
list = map(int, stuff.split())
print list, "<-- pick"
do('f.listmessages()')
diff --git a/Lib/mimetools.py b/Lib/mimetools.py
index 067a2cd70f..0b698ac679 100644
--- a/Lib/mimetools.py
+++ b/Lib/mimetools.py
@@ -129,11 +129,11 @@ def choose_boundary():
import socket
hostid = socket.gethostbyname(socket.gethostname())
try:
- uid = `os.getuid()`
+ uid = repr(os.getuid())
except AttributeError:
uid = '1'
try:
- pid = `os.getpid()`
+ pid = repr(os.getpid())
except AttributeError:
pid = '1'
_prefix = hostid + '.' + uid + '.' + pid
diff --git a/Lib/modulefinder.py b/Lib/modulefinder.py
index 6dec0e5903..07b260da2f 100644
--- a/Lib/modulefinder.py
+++ b/Lib/modulefinder.py
@@ -62,11 +62,11 @@ class Module:
self.starimports = {}
def __repr__(self):
- s = "Module(%s" % `self.__name__`
+ s = "Module(%r" % % (self.__name__,)
if self.__file__ is not None:
- s = s + ", %s" % `self.__file__`
+ s = s + ", %r" % (self.__file__,)
if self.__path__ is not None:
- s = s + ", %s" % `self.__path__`
+ s = s + ", %r" % (self.__path__,)
s = s + ")"
return s
@@ -564,7 +564,7 @@ def test():
if debug > 1:
print "path:"
for item in path:
- print " ", `item`
+ print " ", repr(item)
# Create the module finder and turn its crank
mf = ModuleFinder(path, debug, exclude)
diff --git a/Lib/nntplib.py b/Lib/nntplib.py
index 6299ba2350..83544b893b 100644
--- a/Lib/nntplib.py
+++ b/Lib/nntplib.py
@@ -175,7 +175,7 @@ class NNTP:
If the response code is 200, posting is allowed;
if it 201, posting is not allowed."""
- if self.debugging: print '*welcome*', `self.welcome`
+ if self.debugging: print '*welcome*', repr(self.welcome)
return self.welcome
def set_debuglevel(self, level):
@@ -190,12 +190,12 @@ class NNTP:
def putline(self, line):
"""Internal: send one line to the server, appending CRLF."""
line = line + CRLF
- if self.debugging > 1: print '*put*', `line`
+ if self.debugging > 1: print '*put*', repr(line)
self.sock.sendall(line)
def putcmd(self, line):
"""Internal: send one command to the server (through putline())."""
- if self.debugging: print '*cmd*', `line`
+ if self.debugging: print '*cmd*', repr(line)
self.putline(line)
def getline(self):
@@ -203,7 +203,7 @@ class NNTP:
Raise EOFError if the connection is closed."""
line = self.file.readline()
if self.debugging > 1:
- print '*get*', `line`
+ print '*get*', repr(line)
if not line: raise EOFError
if line[-2:] == CRLF: line = line[:-2]
elif line[-1:] in CRLF: line = line[:-1]
@@ -213,7 +213,7 @@ class NNTP:
"""Internal: get a response from the server.
Raise various errors if the response indicates an error."""
resp = self.getline()
- if self.debugging: print '*resp*', `resp`
+ if self.debugging: print '*resp*', repr(resp)
c = resp[:1]
if c == '4':
raise NNTPTemporaryError(resp)
diff --git a/Lib/opcode.py b/Lib/opcode.py
index cfde5f803b..39d4bd24ae 100644
--- a/Lib/opcode.py
+++ b/Lib/opcode.py
@@ -21,7 +21,7 @@ hasfree = []
opmap = {}
opname = [''] * 256
-for op in range(256): opname[op] = '<' + `op` + '>'
+for op in range(256): opname[op] = '<%r>' % (op,)
del op
def def_op(name, op):
diff --git a/Lib/pdb.py b/Lib/pdb.py
index 9a08a6a8db..b35164c9ec 100755
--- a/Lib/pdb.py
+++ b/Lib/pdb.py
@@ -219,7 +219,7 @@ class Pdb(bdb.Bdb, cmd.Cmd):
filename = arg[:colon].rstrip()
f = self.lookupmodule(filename)
if not f:
- print '*** ', `filename`,
+ print '*** ', repr(filename),
print 'not found from sys.path'
return
else:
@@ -252,7 +252,7 @@ class Pdb(bdb.Bdb, cmd.Cmd):
(ok, filename, ln) = self.lineinfo(arg)
if not ok:
print '*** The specified object',
- print `arg`,
+ print repr(arg),
print 'is not a function'
print ('or was not found '
'along sys.path.')
@@ -596,7 +596,7 @@ class Pdb(bdb.Bdb, cmd.Cmd):
if isinstance(t, str):
exc_type_name = t
else: exc_type_name = t.__name__
- print '***', exc_type_name + ':', `v`
+ print '***', exc_type_name + ':', repr(v)
raise
def do_p(self, arg):
@@ -627,7 +627,7 @@ class Pdb(bdb.Bdb, cmd.Cmd):
else:
first = max(1, int(x) - 5)
except:
- print '*** Error in argument:', `arg`
+ print '*** Error in argument:', repr(arg)
return
elif self.lineno is None:
first = max(1, self.curframe.f_lineno - 5)
@@ -644,7 +644,7 @@ class Pdb(bdb.Bdb, cmd.Cmd):
print '[EOF]'
break
else:
- s = `lineno`.rjust(3)
+ s = repr(lineno).rjust(3)
if len(s) < 4: s = s + ' '
if lineno in breaklist: s = s + 'B'
else: s = s + ' '
@@ -665,7 +665,7 @@ class Pdb(bdb.Bdb, cmd.Cmd):
if type(t) == type(''):
exc_type_name = t
else: exc_type_name = t.__name__
- print '***', exc_type_name + ':', `v`
+ print '***', exc_type_name + ':', repr(v)
return
code = None
# Is it a function?
@@ -1034,7 +1034,7 @@ if __name__=='__main__':
mainpyfile = filename = sys.argv[1] # Get script filename
if not os.path.exists(filename):
- print 'Error:', `filename`, 'does not exist'
+ print 'Error:', repr(filename), 'does not exist'
sys.exit(1)
mainmodule = os.path.basename(filename)
del sys.argv[0] # Hide "pdb.py" from argument list
@@ -1042,4 +1042,4 @@ if __name__=='__main__':
# Insert script directory in front of module search path
sys.path.insert(0, os.path.dirname(filename))
- run('execfile(' + `filename` + ')')
+ run('execfile(%r)' % (filename,))
diff --git a/Lib/pickle.py b/Lib/pickle.py
index a854948127..69fc2ccaf7 100644
--- a/Lib/pickle.py
+++ b/Lib/pickle.py
@@ -261,7 +261,7 @@ class Pickler:
else:
return LONG_BINPUT + pack("<i", i)
- return PUT + `i` + '\n'
+ return PUT + repr(i) + '\n'
# Return a GET (BINGET, LONG_BINGET) opcode string, with argument i.
def get(self, i, pack=struct.pack):
@@ -271,7 +271,7 @@ class Pickler:
else:
return LONG_BINGET + pack("<i", i)
- return GET + `i` + '\n'
+ return GET + repr(i) + '\n'
def save(self, obj):
# Check for persistent id (defined by a subclass)
@@ -469,7 +469,7 @@ class Pickler:
self.write(BININT + pack("<i", obj))
return
# Text pickle, or int too big to fit in signed 4-byte format.
- self.write(INT + `obj` + '\n')
+ self.write(INT + repr(obj) + '\n')
dispatch[IntType] = save_int
def save_long(self, obj, pack=struct.pack):
@@ -481,14 +481,14 @@ class Pickler:
else:
self.write(LONG4 + pack("<i", n) + bytes)
return
- self.write(LONG + `obj` + '\n')
+ self.write(LONG + repr(obj) + '\n')
dispatch[LongType] = save_long
def save_float(self, obj, pack=struct.pack):
if self.bin:
self.write(BINFLOAT + pack('>d', obj))
else:
- self.write(FLOAT + `obj` + '\n')
+ self.write(FLOAT + repr(obj) + '\n')
dispatch[FloatType] = save_float
def save_string(self, obj, pack=struct.pack):
@@ -499,7 +499,7 @@ class Pickler:
else:
self.write(BINSTRING + pack("<i", n) + obj)
else:
- self.write(STRING + `obj` + '\n')
+ self.write(STRING + repr(obj) + '\n')
self.memoize(obj)
dispatch[StringType] = save_string
@@ -539,7 +539,7 @@ class Pickler:
obj = obj.encode('raw-unicode-escape')
self.write(UNICODE + obj + '\n')
else:
- self.write(STRING + `obj` + '\n')
+ self.write(STRING + repr(obj) + '\n')
self.memoize(obj)
dispatch[StringType] = save_string
@@ -1173,12 +1173,12 @@ class Unpickler:
def load_binget(self):
i = ord(self.read(1))
- self.append(self.memo[`i`])
+ self.append(self.memo[repr(i)])
dispatch[BINGET] = load_binget
def load_long_binget(self):
i = mloads('i' + self.read(4))
- self.append(self.memo[`i`])
+ self.append(self.memo[repr(i)])
dispatch[LONG_BINGET] = load_long_binget
def load_put(self):
@@ -1187,12 +1187,12 @@ class Unpickler:
def load_binput(self):
i = ord(self.read(1))
- self.memo[`i`] = self.stack[-1]
+ self.memo[repr(i)] = self.stack[-1]
dispatch[BINPUT] = load_binput
def load_long_binput(self):
i = mloads('i' + self.read(4))
- self.memo[`i`] = self.stack[-1]
+ self.memo[repr(i)] = self.stack[-1]
dispatch[LONG_BINPUT] = load_long_binput
def load_append(self):
diff --git a/Lib/pipes.py b/Lib/pipes.py
index 9de22e1002..295d9c88b6 100644
--- a/Lib/pipes.py
+++ b/Lib/pipes.py
@@ -89,8 +89,8 @@ class Template:
self.reset()
def __repr__(self):
- """t.__repr__() implements `t`."""
- return '<Template instance, steps=' + `self.steps` + '>'
+ """t.__repr__() implements repr(t)."""
+ return '<Template instance, steps=%r>' % (self.steps,)
def reset(self):
"""t.reset() restores a pipeline template to its initial state."""
@@ -115,7 +115,7 @@ class Template:
'Template.append: cmd must be a string'
if kind not in stepkinds:
raise ValueError, \
- 'Template.append: bad kind ' + `kind`
+ 'Template.append: bad kind %r' % (kind,)
if kind == SOURCE:
raise ValueError, \
'Template.append: SOURCE can only be prepended'
@@ -137,7 +137,7 @@ class Template:
'Template.prepend: cmd must be a string'
if kind not in stepkinds:
raise ValueError, \
- 'Template.prepend: bad kind ' + `kind`
+ 'Template.prepend: bad kind %r' % (kind,)
if kind == SINK:
raise ValueError, \
'Template.prepend: SINK can only be appended'
@@ -160,7 +160,7 @@ class Template:
if rw == 'w':
return self.open_w(file)
raise ValueError, \
- 'Template.open: rw must be \'r\' or \'w\', not ' + `rw`
+ 'Template.open: rw must be \'r\' or \'w\', not %r' % (rw,)
def open_r(self, file):
"""t.open_r(file) and t.open_w(file) implement
diff --git a/Lib/plat-irix5/cddb.py b/Lib/plat-irix5/cddb.py
index e43aea6384..c4a95cdc43 100755
--- a/Lib/plat-irix5/cddb.py
+++ b/Lib/plat-irix5/cddb.py
@@ -111,9 +111,7 @@ class Cddb:
print 'syntax error in ' + file
continue
if trackno > ntracks:
- print 'track number ' + `trackno` + \
- ' in file ' + file + \
- ' out of range'
+ print 'track number %r in file %r out of range' % (trackno, file)
continue
if name2 == 'title':
self.track[trackno] = value
@@ -191,7 +189,7 @@ class Cddb:
prevpref = None
for i in range(1, len(self.track)):
if self.trackartist[i]:
- f.write('track'+`i`+'.artist:\t'+self.trackartist[i]+'\n')
+ f.write('track%r.artist:\t%s\n' % (i, self.trackartist[i]))
track = self.track[i]
try:
off = track.index(',')
@@ -202,5 +200,5 @@ class Cddb:
track = track[off:]
else:
prevpref = track[:off]
- f.write('track' + `i` + '.title:\t' + track + '\n')
+ f.write('track%r.title:\t%s\n' % (i, track))
f.close()
diff --git a/Lib/plat-irix5/cdplayer.py b/Lib/plat-irix5/cdplayer.py
index 278da0365e..3cbd0d8060 100755
--- a/Lib/plat-irix5/cdplayer.py
+++ b/Lib/plat-irix5/cdplayer.py
@@ -82,8 +82,7 @@ class Cdplayer:
new.write(self.id + '.title:\t' + self.title + '\n')
new.write(self.id + '.artist:\t' + self.artist + '\n')
for i in range(1, len(self.track)):
- new.write(self.id + '.track.' + `i` + ':\t' + \
- self.track[i] + '\n')
+ new.write('%s.track.%r:\t%s\n' % (self.id, i, self.track[i])
old.close()
new.close()
posix.rename(filename + '.new', filename)
diff --git a/Lib/plat-irix5/flp.py b/Lib/plat-irix5/flp.py
index 7d5814a8f7..b22bc1ae29 100755
--- a/Lib/plat-irix5/flp.py
+++ b/Lib/plat-irix5/flp.py
@@ -146,7 +146,7 @@ def freeze(filename):
forms = parse_forms(filename)
altforms = _pack_cache(forms)
print 'import flp'
- print 'flp._internal_cache[', `filename`, '] =', altforms
+ print 'flp._internal_cache[', repr(filename), '] =', altforms
#
# Internal: create the data structure to be placed in the cache
@@ -417,7 +417,7 @@ def _select_crfunc(fm, cl):
elif cl == FL.TEXT: return fm.add_text
elif cl == FL.TIMER: return fm.add_timer
else:
- raise error, 'Unknown object type: ' + `cl`
+ raise error, 'Unknown object type: %r' % (cl,)
def test():
diff --git a/Lib/plat-irix5/panel.py b/Lib/plat-irix5/panel.py
index f8388c6d55..3aa7448653 100755
--- a/Lib/plat-irix5/panel.py
+++ b/Lib/plat-irix5/panel.py
@@ -127,7 +127,7 @@ def assign_members(target, attrlist, exclist, prefix):
ok = 0
if ok:
lhs = 'target.' + prefix + name
- stmt = lhs + '=' + `value`
+ stmt = lhs + '=' + repr(value)
if debug: print 'exec', stmt
try:
exec stmt + '\n'
diff --git a/Lib/plat-irix5/readcd.py b/Lib/plat-irix5/readcd.py
index e000d35047..f278ba4bf0 100755
--- a/Lib/plat-irix5/readcd.py
+++ b/Lib/plat-irix5/readcd.py
@@ -9,7 +9,7 @@ class _Stop(Exception):
def _doatime(self, cb_type, data):
if ((data[0] * 60) + data[1]) * 75 + data[2] > self.end:
-## print 'done with list entry',`self.listindex`
+## print 'done with list entry', repr(self.listindex)
raise _Stop
func, arg = self.callbacks[cb_type]
if func:
@@ -17,7 +17,7 @@ def _doatime(self, cb_type, data):
def _dopnum(self, cb_type, data):
if data > self.end:
-## print 'done with list entry',`self.listindex`
+## print 'done with list entry', repr(self.listindex)
raise _Stop
func, arg = self.callbacks[cb_type]
if func:
diff --git a/Lib/plat-irix5/torgb.py b/Lib/plat-irix5/torgb.py
index 6208289956..fa5effb488 100755
--- a/Lib/plat-irix5/torgb.py
+++ b/Lib/plat-irix5/torgb.py
@@ -85,13 +85,12 @@ def _torgb(filename, temps):
type(msg[0]) == type(0) and type(msg[1]) == type(''):
msg = msg[1]
if type(msg) is not type(''):
- msg = `msg`
+ msg = repr(msg)
raise error, filename + ': ' + msg
if ftype == 'rgb':
return fname
if ftype is None or not table.has_key(ftype):
- raise error, \
- filename + ': unsupported image file type ' + `ftype`
+ raise error, '%s: unsupported image file type %r' % (filename, ftype))
(fd, temp) = tempfile.mkstemp()
os.close(fd)
sts = table[ftype].copy(fname, temp)
diff --git a/Lib/plat-irix6/cddb.py b/Lib/plat-irix6/cddb.py
index 96025e74d4..e96e99e3e3 100644
--- a/Lib/plat-irix6/cddb.py
+++ b/Lib/plat-irix6/cddb.py
@@ -111,9 +111,7 @@ class Cddb:
print 'syntax error in ' + file
continue
if trackno > ntracks:
- print 'track number ' + `trackno` + \
- ' in file ' + file + \
- ' out of range'
+ print 'track number %r in file %s out of range' % (trackno, file)
continue
if name2 == 'title':
self.track[trackno] = value
@@ -191,7 +189,7 @@ class Cddb:
prevpref = None
for i in range(1, len(self.track)):
if self.trackartist[i]:
- f.write('track'+`i`+'.artist:\t'+self.trackartist[i]+'\n')
+ f.write('track%r.artist:\t%s\n' % (i, self.trackartist[i])
track = self.track[i]
try:
off = track.index(',')
@@ -202,5 +200,5 @@ class Cddb:
track = track[off:]
else:
prevpref = track[:off]
- f.write('track' + `i` + '.title:\t' + track + '\n')
+ f.write('track%r.title:\t%s\n' % (i, track))
f.close()
diff --git a/Lib/plat-irix6/cdplayer.py b/Lib/plat-irix6/cdplayer.py
index c665a07aab..4ba3f51cd7 100644
--- a/Lib/plat-irix6/cdplayer.py
+++ b/Lib/plat-irix6/cdplayer.py
@@ -82,8 +82,7 @@ class Cdplayer:
new.write(self.id + '.title:\t' + self.title + '\n')
new.write(self.id + '.artist:\t' + self.artist + '\n')
for i in range(1, len(self.track)):
- new.write(self.id + '.track.' + `i` + ':\t' + \
- self.track[i] + '\n')
+ new.write('%s.track.%r:\t%s\n' % (i, track))
old.close()
new.close()
posix.rename(filename + '.new', filename)
diff --git a/Lib/plat-irix6/flp.py b/Lib/plat-irix6/flp.py
index 6530487b07..aa231070a4 100644
--- a/Lib/plat-irix6/flp.py
+++ b/Lib/plat-irix6/flp.py
@@ -145,7 +145,7 @@ def freeze(filename):
forms = parse_forms(filename)
altforms = _pack_cache(forms)
print 'import flp'
- print 'flp._internal_cache[', `filename`, '] =', altforms
+ print 'flp._internal_cache[', repr(filename), '] =', altforms
#
# Internal: create the data structure to be placed in the cache
@@ -416,7 +416,7 @@ def _select_crfunc(fm, cl):
elif cl == FL.TEXT: return fm.add_text
elif cl == FL.TIMER: return fm.add_timer
else:
- raise error, 'Unknown object type: ' + `cl`
+ raise error, 'Unknown object type: %r' % (cl,)
def test():
diff --git a/Lib/plat-irix6/panel.py b/Lib/plat-irix6/panel.py
index f8388c6d55..3aa7448653 100644
--- a/Lib/plat-irix6/panel.py
+++ b/Lib/plat-irix6/panel.py
@@ -127,7 +127,7 @@ def assign_members(target, attrlist, exclist, prefix):
ok = 0
if ok:
lhs = 'target.' + prefix + name
- stmt = lhs + '=' + `value`
+ stmt = lhs + '=' + repr(value)
if debug: print 'exec', stmt
try:
exec stmt + '\n'
diff --git a/Lib/plat-irix6/readcd.py b/Lib/plat-irix6/readcd.py
index e000d35047..f278ba4bf0 100644
--- a/Lib/plat-irix6/readcd.py
+++ b/Lib/plat-irix6/readcd.py
@@ -9,7 +9,7 @@ class _Stop(Exception):
def _doatime(self, cb_type, data):
if ((data[0] * 60) + data[1]) * 75 + data[2] > self.end:
-## print 'done with list entry',`self.listindex`
+## print 'done with list entry', repr(self.listindex)
raise _Stop
func, arg = self.callbacks[cb_type]
if func:
@@ -17,7 +17,7 @@ def _doatime(self, cb_type, data):
def _dopnum(self, cb_type, data):
if data > self.end:
-## print 'done with list entry',`self.listindex`
+## print 'done with list entry', repr(self.listindex)
raise _Stop
func, arg = self.callbacks[cb_type]
if func:
diff --git a/Lib/plat-irix6/torgb.py b/Lib/plat-irix6/torgb.py
index 6208289956..c2b1740f20 100644
--- a/Lib/plat-irix6/torgb.py
+++ b/Lib/plat-irix6/torgb.py
@@ -85,13 +85,12 @@ def _torgb(filename, temps):
type(msg[0]) == type(0) and type(msg[1]) == type(''):
msg = msg[1]
if type(msg) is not type(''):
- msg = `msg`
+ msg = repr(msg)
raise error, filename + ': ' + msg
if ftype == 'rgb':
return fname
if ftype is None or not table.has_key(ftype):
- raise error, \
- filename + ': unsupported image file type ' + `ftype`
+ raise error, '%s: unsupported image file type %r' % (filename, ftype)
(fd, temp) = tempfile.mkstemp()
os.close(fd)
sts = table[ftype].copy(fname, temp)
diff --git a/Lib/plat-mac/EasyDialogs.py b/Lib/plat-mac/EasyDialogs.py
index 0c54ec322e..13df7f307f 100644
--- a/Lib/plat-mac/EasyDialogs.py
+++ b/Lib/plat-mac/EasyDialogs.py
@@ -531,7 +531,7 @@ def GetArgv(optionlist=None, commandlist=None, addoldfile=1, addnewfile=1, addfo
for stringtoadd in stringstoadd:
if '"' in stringtoadd or "'" in stringtoadd or " " in stringtoadd:
- stringtoadd = `stringtoadd`
+ stringtoadd = repr(stringtoadd)
h = d.GetDialogItemAsControl(ARGV_CMDLINE_DATA)
oldstr = GetDialogItemText(h)
if oldstr and oldstr[-1] != ' ':
@@ -791,7 +791,7 @@ def test():
argv = GetArgv(optionlist=optionlist, commandlist=commandlist, addoldfile=0)
Message("Command line: %s"%' '.join(argv))
for i in range(len(argv)):
- print 'arg[%d] = %s'%(i, `argv[i]`)
+ print 'arg[%d] = %r' % (i, argv[i])
ok = AskYesNoCancel("Do you want to proceed?")
ok = AskYesNoCancel("Do you want to identify?", yes="Identify", no="No")
if ok > 0:
diff --git a/Lib/plat-mac/FrameWork.py b/Lib/plat-mac/FrameWork.py
index 849ebdfcc7..7242704fbe 100644
--- a/Lib/plat-mac/FrameWork.py
+++ b/Lib/plat-mac/FrameWork.py
@@ -373,7 +373,7 @@ class Application:
# else it wasn't for us, sigh...
def do_char(self, c, event):
- if DEBUG: print "Character", `c`
+ if DEBUG: print "Character", repr(c)
def do_updateEvt(self, event):
(what, message, when, where, modifiers) = event
@@ -431,13 +431,13 @@ class Application:
def printevent(self, event):
(what, message, when, where, modifiers) = event
- nicewhat = `what`
+ nicewhat = repr(what)
if eventname.has_key(what):
nicewhat = eventname[what]
print nicewhat,
if what == kHighLevelEvent:
h, v = where
- print `ostypecode(message)`, hex(when), `ostypecode(h | (v<<16))`,
+ print repr(ostypecode(message)), hex(when), repr(ostypecode(h | (v<<16))),
else:
print hex(message), hex(when), where,
print hex(modifiers)
diff --git a/Lib/plat-mac/MiniAEFrame.py b/Lib/plat-mac/MiniAEFrame.py
index d6482c61c8..3c5ed9aa5a 100644
--- a/Lib/plat-mac/MiniAEFrame.py
+++ b/Lib/plat-mac/MiniAEFrame.py
@@ -67,8 +67,7 @@ class MiniApplication:
what, message, when, where, modifiers = event
h, v = where
if what == kHighLevelEvent:
- msg = "High Level Event: %s %s" % \
- (`code(message)`, `code(h | (v<<16))`)
+ msg = "High Level Event: %r %r" % (code(message), code(h | (v<<16)))
try:
AE.AEProcessAppleEvent(event)
except AE.Error, err:
diff --git a/Lib/plat-mac/aetypes.py b/Lib/plat-mac/aetypes.py
index 538cf14e64..b9386f3bb0 100644
--- a/Lib/plat-mac/aetypes.py
+++ b/Lib/plat-mac/aetypes.py
@@ -26,7 +26,7 @@ class Unknown:
self.data = data
def __repr__(self):
- return "Unknown(%s, %s)" % (`self.type`, `self.data`)
+ return "Unknown(%r, %r)" % (self.type, self.data)
def __aepack__(self):
return pack(self.data, self.type)
@@ -38,7 +38,7 @@ class Enum:
self.enum = "%-4.4s" % str(enum)
def __repr__(self):
- return "Enum(%s)" % `self.enum`
+ return "Enum(%r)" % (self.enum,)
def __str__(self):
return string.strip(self.enum)
@@ -60,7 +60,7 @@ class InsertionLoc:
self.pos = pos
def __repr__(self):
- return "InsertionLoc(%s, %s)" % (`self.of`, `self.pos`)
+ return "InsertionLoc(%r, %r)" % (self.of, self.pos)
def __aepack__(self):
rec = {'kobj': self.of, 'kpos': self.pos}
@@ -80,7 +80,7 @@ class Boolean:
self.bool = (not not bool)
def __repr__(self):
- return "Boolean(%s)" % `self.bool`
+ return "Boolean(%r)" % (self.bool,)
def __str__(self):
if self.bool:
@@ -105,7 +105,7 @@ class Type:
self.type = "%-4.4s" % str(type)
def __repr__(self):
- return "Type(%s)" % `self.type`
+ return "Type(%r)" % (self.type,)
def __str__(self):
return string.strip(self.type)
@@ -128,7 +128,7 @@ class Keyword:
self.keyword = "%-4.4s" % str(keyword)
def __repr__(self):
- return "Keyword(%s)" % `self.keyword`
+ return "Keyword(%r)" % `self.keyword`
def __str__(self):
return string.strip(self.keyword)
@@ -147,7 +147,7 @@ class Range:
self.stop = stop
def __repr__(self):
- return "Range(%s, %s)" % (`self.start`, `self.stop`)
+ return "Range(%r, %r)" % (self.start, self.stop)
def __str__(self):
return "%s thru %s" % (nice(self.start), nice(self.stop))
@@ -167,7 +167,7 @@ class Comparison:
self.obj2 = obj2
def __repr__(self):
- return "Comparison(%s, %s, %s)" % (`self.obj1`, `self.relo`, `self.obj2`)
+ return "Comparison(%r, %r, %r)" % (self.obj1, self.relo, self.obj2)
def __str__(self):
return "%s %s %s" % (nice(self.obj1), string.strip(self.relo), nice(self.obj2))
@@ -195,7 +195,7 @@ class Ordinal:
self.abso = "%-4.4s" % str(abso)
def __repr__(self):
- return "Ordinal(%s)" % (`self.abso`)
+ return "Ordinal(%r)" % (self.abso,)
def __str__(self):
return "%s" % (string.strip(self.abso))
@@ -220,7 +220,7 @@ class Logical:
self.term = term
def __repr__(self):
- return "Logical(%s, %s)" % (`self.logc`, `self.term`)
+ return "Logical(%r, %r)" % (self.logc, self.term)
def __str__(self):
if type(self.term) == ListType and len(self.term) == 2:
@@ -244,7 +244,7 @@ class StyledText:
self.text = text
def __repr__(self):
- return "StyledText(%s, %s)" % (`self.style`, `self.text`)
+ return "StyledText(%r, %r)" % (self.style, self.text)
def __str__(self):
return self.text
@@ -264,7 +264,7 @@ class AEText:
self.text = text
def __repr__(self):
- return "AEText(%s, %s, %s)" % (`self.script`, `self.style`, `self.text`)
+ return "AEText(%r, %r, %r)" % (self.script, self.style, self.text)
def __str__(self):
return self.text
@@ -285,7 +285,7 @@ class IntlText:
self.text = text
def __repr__(self):
- return "IntlText(%s, %s, %s)" % (`self.script`, `self.language`, `self.text`)
+ return "IntlText(%r, %r, %r)" % (self.script, self.language, self.text)
def __str__(self):
return self.text
@@ -305,7 +305,7 @@ class IntlWritingCode:
self.language = language
def __repr__(self):
- return "IntlWritingCode(%s, %s)" % (`self.script`, `self.language`)
+ return "IntlWritingCode(%r, %r)" % (self.script, self.language)
def __str__(self):
return "script system %d, language %d"%(self.script, self.language)
@@ -325,7 +325,7 @@ class QDPoint:
self.h = h
def __repr__(self):
- return "QDPoint(%s, %s)" % (`self.v`, `self.h`)
+ return "QDPoint(%r, %r)" % (self.v, self.h)
def __str__(self):
return "(%d, %d)"%(self.v, self.h)
@@ -347,8 +347,7 @@ class QDRectangle:
self.h1 = h1
def __repr__(self):
- return "QDRectangle(%s, %s, %s, %s)" % (`self.v0`, `self.h0`,
- `self.v1`, `self.h1`)
+ return "QDRectangle(%r, %r, %r, %r)" % (self.v0, self.h0, self.v1, self.h1)
def __str__(self):
return "(%d, %d)-(%d, %d)"%(self.v0, self.h0, self.v1, self.h1)
@@ -369,7 +368,7 @@ class RGBColor:
self.b = b
def __repr__(self):
- return "RGBColor(%s, %s, %s)" % (`self.r`, `self.g`, `self.b`)
+ return "RGBColor(%r, %r, %r)" % (self.r, self.g, self.b)
def __str__(self):
return "0x%x red, 0x%x green, 0x%x blue"% (self.r, self.g, self.b)
@@ -413,9 +412,9 @@ class ObjectSpecifier:
self.fr = fr
def __repr__(self):
- s = "ObjectSpecifier(%s, %s, %s" % (`self.want`, `self.form`, `self.seld`)
+ s = "ObjectSpecifier(%r, %r, %r" % (self.want, self.form, self.seld)
if self.fr:
- s = s + ", %s)" % `self.fr`
+ s = s + ", %r)" % (self.fr,)
else:
s = s + ")"
return s
@@ -439,9 +438,9 @@ class Property(ObjectSpecifier):
def __repr__(self):
if self.fr:
- return "Property(%s, %s)" % (`self.seld.type`, `self.fr`)
+ return "Property(%r, %r)" % (self.seld.type, self.fr)
else:
- return "Property(%s)" % `self.seld.type`
+ return "Property(%r)" % (self.seld.type,)
def __str__(self):
if self.fr:
@@ -465,11 +464,11 @@ class NProperty(ObjectSpecifier):
mktype(self.which), fr)
def __repr__(self):
- rv = "Property(%s"%`self.seld.type`
+ rv = "Property(%r" % (self.seld.type,)
if self.fr:
- rv = rv + ", fr=%s" % `self.fr`
+ rv = rv + ", fr=%r" % (self.fr,)
if self.want != 'prop':
- rv = rv + ", want=%s" % `self.want`
+ rv = rv + ", want=%r" % (self.want,)
return rv + ")"
def __str__(self):
@@ -510,8 +509,8 @@ class ComponentItem(SelectableItem):
def __repr__(self):
if not self.fr:
- return "%s(%s)" % (self.__class__.__name__, `self.seld`)
- return "%s(%s, %s)" % (self.__class__.__name__, `self.seld`, `self.fr`)
+ return "%s(%r)" % (self.__class__.__name__, self.seld)
+ return "%s(%r, %r)" % (self.__class__.__name__, self.seld, self.fr)
def __str__(self):
seld = self.seld
@@ -549,7 +548,7 @@ class DelayedComponentItem:
return self.compclass(which, self.fr)
def __repr__(self):
- return "%s(???, %s)" % (self.__class__.__name__, `self.fr`)
+ return "%s(???, %r)" % (self.__class__.__name__, self.fr)
def __str__(self):
return "selector for element %s of %s"%(self.__class__.__name__, str(self.fr))
diff --git a/Lib/plat-mac/argvemulator.py b/Lib/plat-mac/argvemulator.py
index 90bf3654ee..6103a8a20d 100644
--- a/Lib/plat-mac/argvemulator.py
+++ b/Lib/plat-mac/argvemulator.py
@@ -52,8 +52,7 @@ class ArgvCollector:
try:
AE.AEProcessAppleEvent(event)
except AE.Error, err:
- msg = "High Level Event: %s %s" % \
- (`hex(message)`, `hex(h | (v<<16))`)
+ msg = "High Level Event: %r %r" % (hex(message), hex(h | (v<<16)))
print 'AE error: ', err
print 'in', msg
traceback.print_exc()
diff --git a/Lib/plat-mac/buildtools.py b/Lib/plat-mac/buildtools.py
index bebab194b3..365772a0d5 100644
--- a/Lib/plat-mac/buildtools.py
+++ b/Lib/plat-mac/buildtools.py
@@ -55,7 +55,7 @@ def findtemplate(template=None):
except (Carbon.File.Error, ValueError):
continue
else:
- raise BuildError, "Template %s not found on sys.path" % `template`
+ raise BuildError, "Template %r not found on sys.path" % (template,)
file = file.as_pathname()
return file
diff --git a/Lib/plat-mac/gensuitemodule.py b/Lib/plat-mac/gensuitemodule.py
index d4140afbbd..ab3c070c81 100644
--- a/Lib/plat-mac/gensuitemodule.py
+++ b/Lib/plat-mac/gensuitemodule.py
@@ -160,7 +160,7 @@ def processfile_fromresource(fullname, output=None, basepkgname=None,
res = Get1IndResource('aeut', 1+i)
resources.append(res)
if verbose:
- print >>verbose, "\nLISTING aete+aeut RESOURCES IN", `fullname`
+ print >>verbose, "\nLISTING aete+aeut RESOURCES IN", repr(fullname)
aetelist = []
for res in resources:
if verbose:
@@ -187,7 +187,7 @@ def processfile(fullname, output=None, basepkgname=None,
if not is_scriptable(fullname) and verbose:
print >>verbose, "Warning: app does not seem scriptable: %s" % fullname
if verbose:
- print >>verbose, "\nASKING FOR aete DICTIONARY IN", `fullname`
+ print >>verbose, "\nASKING FOR aete DICTIONARY IN", repr(fullname)
try:
aedescobj, launched = OSATerminology.GetAppTerminology(fullname)
except MacOS.Error, arg:
@@ -333,7 +333,7 @@ def getalign(f):
if f.tell() & 1:
c = f.read(1)
##if c <> '\0':
- ## print 'align:', `c`
+ ## print align:', repr(c)
def getlist(f, description, getitem):
count = getword(f)
@@ -344,9 +344,9 @@ def getlist(f, description, getitem):
return list
def alt_generic(what, f, *args):
- print "generic", `what`, args
+ print "generic", repr(what), args
res = vageneric(what, f, args)
- print '->', `res`
+ print '->', repr(res)
return res
def generic(what, f, *args):
@@ -358,7 +358,7 @@ def generic(what, f, *args):
item = apply(generic, thing[:1] + (f,) + thing[1:])
record.append((thing[1], item))
return record
- return "BAD GENERIC ARGS: %s" % `what`
+ return "BAD GENERIC ARGS: %r" % (what,)
getdata = [
(getostype, "type"),
@@ -529,7 +529,7 @@ def compileaete(aete, resinfo, fname, output=None, basepkgname=None,
fp.write("_classdeclarations = {\n")
for codenamemapper in allprecompinfo:
for k, v in codenamemapper.getall('class'):
- fp.write(" %s : %s,\n" % (`k`, v))
+ fp.write(" %r : %s,\n" % (k, v))
if k == 'capp':
application_class = v
fp.write("}\n")
@@ -540,7 +540,7 @@ def compileaete(aete, resinfo, fname, output=None, basepkgname=None,
for code, modname in suitelist[1:]:
fp.write(",\n %s_Events"%modname)
fp.write(",\n aetools.TalkTo):\n")
- fp.write(" _signature = %s\n\n"%`creatorsignature`)
+ fp.write(" _signature = %r\n\n"%(creatorsignature,))
fp.write(" _moduleName = '%s'\n\n"%packagename)
if application_class:
fp.write(" _elemdict = %s._elemdict\n" % application_class)
@@ -655,7 +655,7 @@ class SuiteCompiler:
fp.write('import aetools\n')
fp.write('import MacOS\n\n')
- fp.write("_code = %s\n\n"% `code`)
+ fp.write("_code = %r\n\n"% (code,))
if self.basepackage and self.basepackage._code_to_module.has_key(code):
# We are an extension of a baseclass (usually an application extending
# Standard_Suite or so). Import everything from our base module
@@ -715,7 +715,7 @@ class SuiteCompiler:
if arguments:
fp.write(" _argmap_%s = {\n"%funcname)
for a in arguments:
- fp.write(" %s : %s,\n"%(`identify(a[0])`, `a[1]`))
+ fp.write(" %r : %r,\n"%(identify(a[0]), a[1]))
fp.write(" }\n\n")
#
@@ -752,8 +752,8 @@ class SuiteCompiler:
#
# Fiddle the args so everything ends up in 'arguments' dictionary
#
- fp.write(" _code = %s\n"% `code`)
- fp.write(" _subcode = %s\n\n"% `subcode`)
+ fp.write(" _code = %r\n"% (code,))
+ fp.write(" _subcode = %r\n\n"% (subcode,))
#
# Do keyword name substitution
#
@@ -780,8 +780,8 @@ class SuiteCompiler:
kname = a[1]
ename = a[2][0]
if ename <> '****':
- fp.write(" aetools.enumsubst(_arguments, %s, _Enum_%s)\n" %
- (`kname`, identify(ename)))
+ fp.write(" aetools.enumsubst(_arguments, %r, _Enum_%s)\n" %
+ (kname, identify(ename)))
self.enumsneeded[ename] = 1
fp.write("\n")
#
@@ -971,7 +971,7 @@ class ObjectCompiler:
if self.fp:
self.fp.write('\nclass %s(aetools.ComponentItem):\n' % pname)
self.fp.write(' """%s - %s """\n' % (ascii(name), ascii(desc)))
- self.fp.write(' want = %s\n' % `code`)
+ self.fp.write(' want = %r\n' % (code,))
self.namemappers[0].addnamecode('class', pname, code)
is_application_class = (code == 'capp')
properties.sort()
@@ -998,8 +998,8 @@ class ObjectCompiler:
if self.fp:
self.fp.write("class _Prop_%s(aetools.NProperty):\n" % pname)
self.fp.write(' """%s - %s """\n' % (ascii(name), ascii(what[1])))
- self.fp.write(" which = %s\n" % `code`)
- self.fp.write(" want = %s\n" % `what[0]`)
+ self.fp.write(" which = %r\n" % (code,))
+ self.fp.write(" want = %r\n" % (what[0],))
self.namemappers[0].addnamecode('property', pname, code)
if is_application_class and self.fp:
self.fp.write("%s = _Prop_%s()\n" % (pname, pname))
@@ -1007,7 +1007,7 @@ class ObjectCompiler:
def compileelement(self, elem):
[code, keyform] = elem
if self.fp:
- self.fp.write("# element %s as %s\n" % (`code`, keyform))
+ self.fp.write("# element %r as %s\n" % (code, keyform))
def fillclasspropsandelems(self, cls):
[name, code, desc, properties, elements] = cls
@@ -1018,7 +1018,7 @@ class ObjectCompiler:
if self.fp and (elements or len(properties) > 1 or (len(properties) == 1 and
properties[0][1] != 'c@#!')):
if self.verbose:
- print >>self.verbose, '** Skip multiple %s of %s (code %s)' % (cname, self.namemappers[0].findcodename('class', code)[0], `code`)
+ print >>self.verbose, '** Skip multiple %s of %s (code %r)' % (cname, self.namemappers[0].findcodename('class', code)[0], code)
raise RuntimeError, "About to skip non-empty class"
return
plist = []
@@ -1044,7 +1044,7 @@ class ObjectCompiler:
superclassnames.append(superclassname)
if self.fp:
- self.fp.write("%s._superclassnames = %s\n"%(cname, `superclassnames`))
+ self.fp.write("%s._superclassnames = %r\n"%(cname, superclassnames))
for elem in elements:
[ecode, keyform] = elem
@@ -1053,7 +1053,7 @@ class ObjectCompiler:
name, ename, module = self.findcodename('class', ecode)
if not name:
if self.fp:
- self.fp.write("# XXXX %s element %s not found!!\n"%(cname, `ecode`))
+ self.fp.write("# XXXX %s element %r not found!!\n"%(cname, ecode))
else:
elist.append((name, ename))
@@ -1091,7 +1091,7 @@ class ObjectCompiler:
def compileenumerator(self, item):
[name, code, desc] = item
- self.fp.write(" %s : %s,\t# %s\n" % (`identify(name)`, `code`, ascii(desc)))
+ self.fp.write(" %r : %r,\t# %s\n" % (identify(name), code, ascii(desc)))
def checkforenum(self, enum):
"""This enum code is used by an event. Make sure it's available"""
@@ -1113,33 +1113,33 @@ class ObjectCompiler:
classlist = self.namemappers[0].getall('class')
classlist.sort()
for k, v in classlist:
- self.fp.write(" %s : %s,\n" % (`k`, v))
+ self.fp.write(" %r : %s,\n" % (k, v))
self.fp.write("}\n")
self.fp.write("\n_propdeclarations = {\n")
proplist = self.namemappers[0].getall('property')
proplist.sort()
for k, v in proplist:
- self.fp.write(" %s : _Prop_%s,\n" % (`k`, v))
+ self.fp.write(" %r : _Prop_%s,\n" % (k, v))
self.fp.write("}\n")
self.fp.write("\n_compdeclarations = {\n")
complist = self.namemappers[0].getall('comparison')
complist.sort()
for k, v in complist:
- self.fp.write(" %s : %s,\n" % (`k`, v))
+ self.fp.write(" %r : %s,\n" % (k, v))
self.fp.write("}\n")
self.fp.write("\n_enumdeclarations = {\n")
enumlist = self.namemappers[0].getall('enum')
enumlist.sort()
for k, v in enumlist:
- self.fp.write(" %s : %s,\n" % (`k`, v))
+ self.fp.write(" %r : %s,\n" % (k, v))
self.fp.write("}\n")
def compiledata(data):
[type, description, flags] = data
- return "%s -- %s %s" % (`type`, `description`, compiledataflags(flags))
+ return "%r -- %r %s" % (type, description, compiledataflags(flags))
def is_null(data):
return data[0] == 'null'
@@ -1158,7 +1158,7 @@ def getdatadoc(data):
return 'anything'
if type == 'obj ':
return 'an AE object reference'
- return "undocumented, typecode %s"%`type`
+ return "undocumented, typecode %r"%(type,)
dataflagdict = {15: "optional", 14: "list", 13: "enum", 12: "mutable"}
def compiledataflags(flags):
@@ -1168,7 +1168,7 @@ def compiledataflags(flags):
if i in dataflagdict.keys():
bits.append(dataflagdict[i])
else:
- bits.append(`i`)
+ bits.append(repr(i))
return '[%s]' % string.join(bits)
def ascii(str):
diff --git a/Lib/plat-mac/ic.py b/Lib/plat-mac/ic.py
index b90aa752b6..3236805fce 100644
--- a/Lib/plat-mac/ic.py
+++ b/Lib/plat-mac/ic.py
@@ -35,7 +35,7 @@ class ICOpaqueData:
self.data = data
def __repr__(self):
- return "ICOpaqueData(%s)"%`self.data`
+ return "ICOpaqueData(%r)"%(self.data,)
_ICOpaqueDataType=type(ICOpaqueData(''))
@@ -94,7 +94,7 @@ def _code_fontrecord(data, key):
chr(0) + _code_default(name)
def _code_boolean(data, key):
- print 'XXXX boolean:', `data`
+ print 'XXXX boolean:', repr(data)
return chr(data)
def _code_text(data, key):
diff --git a/Lib/plat-riscos/rourl2path.py b/Lib/plat-riscos/rourl2path.py
index 9c213866a9..494e394ffa 100644
--- a/Lib/plat-riscos/rourl2path.py
+++ b/Lib/plat-riscos/rourl2path.py
@@ -58,12 +58,12 @@ def test():
"/foo/bar/index.html",
"/foo/bar/",
"/"]:
- print `url`, '->', `url2pathname(url)`
+ print '%r -> %r' % (url, url2pathname(url))
print "*******************************************************"
for path in ["SCSI::SCSI4.$.Anwendung",
"PythonApp:Lib",
"PythonApp:Lib.rourl2path/py"]:
- print `path`, '->', `pathname2url(path)`
+ print '%r -> %r' % (path, pathname2url(path))
if __name__ == '__main__':
test()
diff --git a/Lib/popen2.py b/Lib/popen2.py
index ebb4ef6526..acba60258b 100644
--- a/Lib/popen2.py
+++ b/Lib/popen2.py
@@ -178,7 +178,7 @@ def _test():
w.close()
got = r.read()
if got.strip() != expected:
- raise ValueError("wrote %s read %s" % (`teststr`, `got`))
+ raise ValueError("wrote %r read %r" % (teststr, got))
print "testing popen3..."
try:
r, w, e = popen3([cmd])
@@ -188,10 +188,10 @@ def _test():
w.close()
got = r.read()
if got.strip() != expected:
- raise ValueError("wrote %s read %s" % (`teststr`, `got`))
+ raise ValueError("wrote %r read %r" % (teststr, got))
got = e.read()
if got:
- raise ValueError("unexected %s on stderr" % `got`)
+ raise ValueError("unexected %r on stderr" % (got,))
for inst in _active[:]:
inst.wait()
if _active:
diff --git a/Lib/poplib.py b/Lib/poplib.py
index c14b8b7d66..1475bdce87 100644
--- a/Lib/poplib.py
+++ b/Lib/poplib.py
@@ -100,14 +100,14 @@ class POP3:
def _putline(self, line):
- if self._debugging > 1: print '*put*', `line`
+ if self._debugging > 1: print '*put*', repr(line)
self.sock.sendall('%s%s' % (line, CRLF))
# Internal: send one command to the server (through _putline())
def _putcmd(self, line):
- if self._debugging: print '*cmd*', `line`
+ if self._debugging: print '*cmd*', repr(line)
self._putline(line)
@@ -117,7 +117,7 @@ class POP3:
def _getline(self):
line = self.file.readline()
- if self._debugging > 1: print '*get*', `line`
+ if self._debugging > 1: print '*get*', repr(line)
if not line: raise error_proto('-ERR EOF')
octets = len(line)
# server can send any combination of CR & LF
@@ -135,7 +135,7 @@ class POP3:
def _getresp(self):
resp, o = self._getline()
- if self._debugging > 1: print '*resp*', `resp`
+ if self._debugging > 1: print '*resp*', repr(resp)
c = resp[:1]
if c != '+':
raise error_proto(resp)
@@ -209,7 +209,7 @@ class POP3:
"""
retval = self._shortcmd('STAT')
rets = retval.split()
- if self._debugging: print '*stat*', `rets`
+ if self._debugging: print '*stat*', repr(rets)
numMessages = int(rets[1])
sizeMessages = int(rets[2])
return (numMessages, sizeMessages)
@@ -375,7 +375,7 @@ class POP3_SSL(POP3):
match = renewline.match(self.buffer)
line = match.group(0)
self.buffer = renewline.sub('' ,self.buffer, 1)
- if self._debugging > 1: print '*get*', `line`
+ if self._debugging > 1: print '*get*', repr(line)
octets = len(line)
if line[-2:] == CRLF:
@@ -385,7 +385,7 @@ class POP3_SSL(POP3):
return line[:-1], octets
def _putline(self, line):
- if self._debugging > 1: print '*put*', `line`
+ if self._debugging > 1: print '*put*', repr(line)
line += CRLF
bytes = len(line)
while bytes > 0:
@@ -416,7 +416,7 @@ if __name__ == "__main__":
(numMsgs, totalSize) = a.stat()
for i in range(1, numMsgs + 1):
(header, msg, octets) = a.retr(i)
- print "Message ", `i`, ':'
+ print "Message %d:" % i
for line in msg:
print ' ' + line
print '-----------------------'
diff --git a/Lib/posixfile.py b/Lib/posixfile.py
index e2eb024781..705fe77c99 100644
--- a/Lib/posixfile.py
+++ b/Lib/posixfile.py
@@ -83,7 +83,7 @@ class _posixfile_:
def fileopen(self, file):
import types
- if `type(file)` != "<type 'file'>":
+ if repr(type(file)) != "<type 'file'>":
raise TypeError, 'posixfile.fileopen() arg must be file object'
self._file_ = file
# Copy basic file methods
diff --git a/Lib/pprint.py b/Lib/pprint.py
index d938122518..716f35d646 100644
--- a/Lib/pprint.py
+++ b/Lib/pprint.py
@@ -212,7 +212,7 @@ def _safe_repr(object, context, maxlevels, level):
typ = _type(object)
if typ is str:
if 'locale' not in _sys.modules:
- return `object`, True, False
+ return repr(object), True, False
if "'" in object and '"' not in object:
closure = '"'
quotes = {'"': '\\"'}
@@ -226,7 +226,7 @@ def _safe_repr(object, context, maxlevels, level):
if char.isalpha():
write(char)
else:
- write(qget(char, `char`[1:-1]))
+ write(qget(char, repr(char)[1:-1]))
return ("%s%s%s" % (closure, sio.getvalue(), closure)), True, False
r = typ.__repr__
@@ -288,7 +288,7 @@ def _safe_repr(object, context, maxlevels, level):
del context[objid]
return format % _commajoin(components), readable, recursive
- rep = `object`
+ rep = repr(object)
return rep, (rep and not rep.startswith('<')), False
diff --git a/Lib/pre.py b/Lib/pre.py
index b6dd09b0e6..60db913018 100644
--- a/Lib/pre.py
+++ b/Lib/pre.py
@@ -544,7 +544,7 @@ class MatchObject:
try:
g = self.re.groupindex[g]
except (KeyError, TypeError):
- raise IndexError, 'group %s is undefined' % `g`
+ raise IndexError, 'group %r is undefined' % (g,)
return self.regs[g][0]
def end(self, g = 0):
@@ -560,7 +560,7 @@ class MatchObject:
try:
g = self.re.groupindex[g]
except (KeyError, TypeError):
- raise IndexError, 'group %s is undefined' % `g`
+ raise IndexError, 'group %r is undefined' % (g,)
return self.regs[g][1]
def span(self, g = 0):
@@ -576,7 +576,7 @@ class MatchObject:
try:
g = self.re.groupindex[g]
except (KeyError, TypeError):
- raise IndexError, 'group %s is undefined' % `g`
+ raise IndexError, 'group %r is undefined' % (g,)
return self.regs[g]
def groups(self, default=None):
@@ -629,9 +629,9 @@ class MatchObject:
try:
g = self.re.groupindex[g]
except (KeyError, TypeError):
- raise IndexError, 'group %s is undefined' % `g`
+ raise IndexError, 'group %r is undefined' % (g,)
if g >= len(self.regs):
- raise IndexError, 'group %s is undefined' % `g`
+ raise IndexError, 'group %r is undefined' % (g,)
a, b = self.regs[g]
if a == -1 or b == -1:
result.append(None)
diff --git a/Lib/profile.py b/Lib/profile.py
index 5993442cea..2dc6e8734c 100755
--- a/Lib/profile.py
+++ b/Lib/profile.py
@@ -411,7 +411,7 @@ class Profile:
# This method is more useful to profile a single function call.
def runcall(self, func, *args, **kw):
- self.set_cmd(`func`)
+ self.set_cmd(repr(func))
sys.setprofile(self.dispatcher)
try:
return func(*args, **kw)
@@ -550,4 +550,4 @@ if __name__ == '__main__':
# Insert script directory in front of module search path
sys.path.insert(0, os.path.dirname(filename))
- run('execfile(' + `filename` + ')')
+ run('execfile(%r)' % (filename,))
diff --git a/Lib/pstats.py b/Lib/pstats.py
index 9e202e91bf..5979a61bea 100644
--- a/Lib/pstats.py
+++ b/Lib/pstats.py
@@ -117,9 +117,8 @@ class Stats:
self.stats = arg.stats
arg.stats = {}
if not self.stats:
- raise TypeError, "Cannot create or construct a " \
- + `self.__class__` \
- + " object from '" + `arg` + "'"
+ raise TypeError, "Cannot create or construct a %r object from '%r''" % (
+ self.__class__, arg)
return
def get_top_level_stats(self):
@@ -300,9 +299,8 @@ class Stats:
count = sel
new_list = list[:count]
if len(list) != len(new_list):
- msg = msg + " List reduced from " + `len(list)` \
- + " to " + `len(new_list)` + \
- " due to restriction <" + `sel` + ">\n"
+ msg = msg + " List reduced from %r to %r due to restriction <%r>\n" % (
+ len(list), len(new_list), sel)
return new_list, msg
@@ -392,8 +390,7 @@ class Stats:
indent = ""
for func in clist:
name = func_std_string(func)
- print indent*name_size + name + '(' \
- + `call_dict[func]`+')', \
+ print indent*name_size + name + '(%r)' % (call_dict[func],), \
f8(self.stats[func][3])
indent = " "
diff --git a/Lib/regsub.py b/Lib/regsub.py
index 9b8fae5854..0fc10a5f68 100644
--- a/Lib/regsub.py
+++ b/Lib/regsub.py
@@ -191,8 +191,8 @@ def test():
fields = split(line, delpat)
if len(fields) != 3:
print 'Sorry, not three fields'
- print 'split:', `fields`
+ print 'split:', repr(fields)
continue
[pat, repl, str] = split(line, delpat)
- print 'sub :', `sub(pat, repl, str)`
- print 'gsub:', `gsub(pat, repl, str)`
+ print 'sub :', repr(sub(pat, repl, str))
+ print 'gsub:', repr(gsub(pat, repl, str))
diff --git a/Lib/repr.py b/Lib/repr.py
index 0431857bbe..2fa3bab7e5 100644
--- a/Lib/repr.py
+++ b/Lib/repr.py
@@ -2,6 +2,8 @@
__all__ = ["Repr","repr"]
+import __builtin__
+
class Repr:
def __init__(self):
self.maxlevel = 6
@@ -22,7 +24,7 @@ class Repr:
if hasattr(self, 'repr_' + typename):
return getattr(self, 'repr_' + typename)(x, level)
else:
- s = `x`
+ s = __builtin__.repr(x)
if len(s) > self.maxother:
i = max(0, (self.maxother-3)//2)
j = max(0, self.maxother-3-i)
@@ -81,15 +83,15 @@ class Repr:
if n > self.maxdict: s = s + ', ...'
return '{' + s + '}'
def repr_str(self, x, level):
- s = `x[:self.maxstring]`
+ s = __builtin__.repr(x[:self.maxstring])
if len(s) > self.maxstring:
i = max(0, (self.maxstring-3)//2)
j = max(0, self.maxstring-3-i)
- s = `x[:i] + x[len(x)-j:]`
+ s = __builtin__.repr(x[:i] + x[len(x)-j:])
s = s[:i] + '...' + s[len(s)-j:]
return s
def repr_long(self, x, level):
- s = `x` # XXX Hope this isn't too slow...
+ s = __builtin__.repr(x) # XXX Hope this isn't too slow...
if len(s) > self.maxlong:
i = max(0, (self.maxlong-3)//2)
j = max(0, self.maxlong-3-i)
@@ -97,7 +99,7 @@ class Repr:
return s
def repr_instance(self, x, level):
try:
- s = `x`
+ s = __builtin__.repr(x)
# Bugs in x.__repr__() can cause arbitrary
# exceptions -- then make up something
except:
diff --git a/Lib/rexec.py b/Lib/rexec.py
index 203a1e9e73..5911a3b991 100644
--- a/Lib/rexec.py
+++ b/Lib/rexec.py
@@ -552,7 +552,7 @@ def test():
try:
fp = open(args[0])
except IOError, msg:
- print "%s: can't open file %s" % (sys.argv[0], `args[0]`)
+ print "%s: can't open file %r" % (sys.argv[0], args[0])
return 1
if fp.isatty():
try:
diff --git a/Lib/sgmllib.py b/Lib/sgmllib.py
index 987ab9fc15..7db0a97ea6 100644
--- a/Lib/sgmllib.py
+++ b/Lib/sgmllib.py
@@ -423,18 +423,18 @@ class TestSGMLParser(SGMLParser):
def handle_data(self, data):
self.testdata = self.testdata + data
- if len(`self.testdata`) >= 70:
+ if len(repr(self.testdata)) >= 70:
self.flush()
def flush(self):
data = self.testdata
if data:
self.testdata = ""
- print 'data:', `data`
+ print 'data:', repr(data)
def handle_comment(self, data):
self.flush()
- r = `data`
+ r = repr(data)
if len(r) > 68:
r = r[:32] + '...' + r[-32:]
print 'comment:', r
diff --git a/Lib/shlex.py b/Lib/shlex.py
index ccf903898a..6632b87596 100644
--- a/Lib/shlex.py
+++ b/Lib/shlex.py
@@ -59,7 +59,7 @@ class shlex:
def push_token(self, tok):
"Push a token onto the stack popped by the get_token method"
if self.debug >= 1:
- print "shlex: pushing token " + `tok`
+ print "shlex: pushing token " + repr(tok)
self.pushback.appendleft(tok)
def push_source(self, newstream, newfile=None):
@@ -90,7 +90,7 @@ class shlex:
if self.pushback:
tok = self.pushback.popleft()
if self.debug >= 1:
- print "shlex: popping token " + `tok`
+ print "shlex: popping token " + repr(tok)
return tok
# No pushback. Get a token.
raw = self.read_token()
@@ -112,7 +112,7 @@ class shlex:
# Neither inclusion nor EOF
if self.debug >= 1:
if raw != self.eof:
- print "shlex: token=" + `raw`
+ print "shlex: token=" + repr(raw)
else:
print "shlex: token=EOF"
return raw
@@ -240,7 +240,7 @@ class shlex:
result = None
if self.debug > 1:
if result:
- print "shlex: raw token=" + `result`
+ print "shlex: raw token=" + repr(result)
else:
print "shlex: raw token=EOF"
return result
diff --git a/Lib/site.py b/Lib/site.py
index 7282190eee..c5f3d95501 100644
--- a/Lib/site.py
+++ b/Lib/site.py
@@ -368,7 +368,7 @@ if hasattr(sys, "setdefaultencoding"):
def _test():
print "sys.path = ["
for dir in sys.path:
- print " %s," % `dir`
+ print " %r," % (dir,)
print "]"
if __name__ == '__main__':
diff --git a/Lib/smtplib.py b/Lib/smtplib.py
index 1af127f067..daadee2c34 100755
--- a/Lib/smtplib.py
+++ b/Lib/smtplib.py
@@ -306,7 +306,7 @@ class SMTP:
def send(self, str):
"""Send `str' to the server."""
- if self.debuglevel > 0: print 'send:', `str`
+ if self.debuglevel > 0: print 'send:', repr(str)
if self.sock:
try:
self.sock.sendall(str)
@@ -345,7 +345,7 @@ class SMTP:
if line == '':
self.close()
raise SMTPServerDisconnected("Connection unexpectedly closed")
- if self.debuglevel > 0: print 'reply:', `line`
+ if self.debuglevel > 0: print 'reply:', repr(line)
resp.append(line[4:].strip())
code=line[:3]
# Check that the error code is syntactically correct.
@@ -666,7 +666,7 @@ class SMTP:
# Hmmm? what's this? -ddm
# self.esmtp_features['7bit']=""
if self.has_extn('size'):
- esmtp_opts.append("size=" + `len(msg)`)
+ esmtp_opts.append("size=%d" % len(msg))
for option in mail_options:
esmtp_opts.append(option)
@@ -727,7 +727,7 @@ if __name__ == '__main__':
if not line:
break
msg = msg + line
- print "Message length is " + `len(msg)`
+ print "Message length is %d" % len(msg)
server = SMTP('localhost')
server.set_debuglevel(1)
diff --git a/Lib/stringold.py b/Lib/stringold.py
index 2ee0ad950a..dd2d584f70 100644
--- a/Lib/stringold.py
+++ b/Lib/stringold.py
@@ -312,7 +312,7 @@ def zfill(x, width):
"""
if type(x) == type(''): s = x
- else: s = `x`
+ else: s = repr(x)
n = len(s)
if n >= width: return s
sign = ''
diff --git a/Lib/sunaudio.py b/Lib/sunaudio.py
index 86a5b4190e..3b0ee2793c 100644
--- a/Lib/sunaudio.py
+++ b/Lib/sunaudio.py
@@ -41,4 +41,4 @@ def printhdr(file):
print 'Encoding: ', encoding
print 'Sample rate:', sample_rate
print 'Channels: ', channels
- print 'Info: ', `info`
+ print 'Info: ', repr(info)
diff --git a/Lib/tabnanny.py b/Lib/tabnanny.py
index 251df27567..f38a79f8a5 100755
--- a/Lib/tabnanny.py
+++ b/Lib/tabnanny.py
@@ -83,7 +83,7 @@ def check(file):
if os.path.isdir(file) and not os.path.islink(file):
if verbose:
- print "%s: listing directory" % `file`
+ print "%r: listing directory" % (file,)
names = os.listdir(file)
for name in names:
fullname = os.path.join(file, name)
@@ -96,35 +96,34 @@ def check(file):
try:
f = open(file)
except IOError, msg:
- errprint("%s: I/O Error: %s" % (`file`, str(msg)))
+ errprint("%r: I/O Error: %s" % (file, msg))
return
if verbose > 1:
- print "checking", `file`, "..."
+ print "checking %r ..." % file
try:
process_tokens(tokenize.generate_tokens(f.readline))
except tokenize.TokenError, msg:
- errprint("%s: Token Error: %s" % (`file`, str(msg)))
+ errprint("%r: Token Error: %s" % (file, msg))
return
except NannyNag, nag:
badline = nag.get_lineno()
line = nag.get_line()
if verbose:
- print "%s: *** Line %d: trouble in tab city! ***" % (
- `file`, badline)
- print "offending line:", `line`
+ print "%r: *** Line %d: trouble in tab city! ***" % (file, badline)
+ print "offending line: %r" % (line,)
print nag.get_msg()
else:
if ' ' in file: file = '"' + file + '"'
if filename_only: print file
- else: print file, badline, `line`
+ else: print file, badline, repr(line)
return
if verbose:
- print "%s: Clean bill of health." % `file`
+ print "%r: Clean bill of health." % (file,)
class Whitespace:
# the characters used for space and tab
diff --git a/Lib/telnetlib.py b/Lib/telnetlib.py
index 85e4c461bf..f073050b81 100644
--- a/Lib/telnetlib.py
+++ b/Lib/telnetlib.py
@@ -288,7 +288,7 @@ class Telnet:
"""
if IAC in buffer:
buffer = buffer.replace(IAC, IAC+IAC)
- self.msg("send %s", `buffer`)
+ self.msg("send %r", buffer)
self.sock.sendall(buffer)
def read_until(self, match, timeout=None):
@@ -519,7 +519,7 @@ class Telnet:
# The buffer size should be fairly small so as to avoid quadratic
# behavior in process_rawq() above
buf = self.sock.recv(50)
- self.msg("recv %s", `buf`)
+ self.msg("recv %r", buf)
self.eof = (not buf)
self.rawq = self.rawq + buf
diff --git a/Lib/test/test_asynchat.py b/Lib/test/test_asynchat.py
index 60017e0ab5..e91c572162 100644
--- a/Lib/test/test_asynchat.py
+++ b/Lib/test/test_asynchat.py
@@ -42,7 +42,7 @@ class echo_client(asynchat.async_chat):
self.buffer = self.buffer + data
def found_terminator(self):
- print "Received:", `self.buffer`
+ print "Received:", repr(self.buffer)
self.buffer = ""
self.close()
diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py
index 46f3d68c5f..9aa24c2331 100644
--- a/Lib/test/test_builtin.py
+++ b/Lib/test/test_builtin.py
@@ -58,7 +58,7 @@ L = [
(' 314', 314),
('314 ', 314),
(' \t\t 314 \t\t ', 314),
- (`sys.maxint`, sys.maxint),
+ (repr(sys.maxint), sys.maxint),
(' 1x', ValueError),
(' 1 ', 1),
(' 1\02 ', ValueError),
@@ -480,7 +480,7 @@ class BuiltinTest(unittest.TestCase):
except v:
pass
- s = `-1-sys.maxint`
+ s = repr(-1-sys.maxint)
self.assertEqual(int(s)+1, -sys.maxint)
# should return long
int(s[1:])
diff --git a/Lib/test/test_contains.py b/Lib/test/test_contains.py
index 04eedf1757..e6f5cf7272 100644
--- a/Lib/test/test_contains.py
+++ b/Lib/test/test_contains.py
@@ -88,15 +88,15 @@ if have_unicode:
# A collection of tests on builtin sequence types
a = range(10)
for i in a:
- check(i in a, "%s not in %s" % (`i`, `a`))
-check(16 not in a, "16 not in %s" % `a`)
-check(a not in a, "%s not in %s" % (`a`, `a`))
+ check(i in a, "%r not in %r" % (i, a))
+check(16 not in a, "16 not in %r" % (a,))
+check(a not in a, "%s not in %r" % (a, a))
a = tuple(a)
for i in a:
- check(i in a, "%s not in %s" % (`i`, `a`))
-check(16 not in a, "16 not in %s" % `a`)
-check(a not in a, "%s not in %s" % (`a`, `a`))
+ check(i in a, "%r not in %r" % (i, a))
+check(16 not in a, "16 not in %r" % (a,))
+check(a not in a, "%r not in %r" % (a, a))
class Deviant1:
"""Behaves strangely when compared
diff --git a/Lib/test/test_copy.py b/Lib/test/test_copy.py
index 6e32ddd88f..bd5a3e10b9 100644
--- a/Lib/test/test_copy.py
+++ b/Lib/test/test_copy.py
@@ -86,7 +86,7 @@ class TestCopy(unittest.TestCase):
"hello", u"hello\u1234", f.func_code,
NewStyle, xrange(10), Classic, max]
for x in tests:
- self.assert_(copy.copy(x) is x, `x`)
+ self.assert_(copy.copy(x) is x, repr(x))
def test_copy_list(self):
x = [1, 2, 3]
@@ -259,7 +259,7 @@ class TestCopy(unittest.TestCase):
"hello", u"hello\u1234", f.func_code,
NewStyle, xrange(10), Classic, max]
for x in tests:
- self.assert_(copy.deepcopy(x) is x, `x`)
+ self.assert_(copy.deepcopy(x) is x, repr(x))
def test_deepcopy_list(self):
x = [[1, 2], 3]
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index d0500e6c16..ccb9fe613b 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -500,15 +500,15 @@ def complexes():
__str__ = __repr__
a = Number(3.14, prec=6)
- vereq(`a`, "3.14")
+ vereq(repr(a), "3.14")
vereq(a.prec, 6)
a = Number(a, prec=2)
- vereq(`a`, "3.1")
+ vereq(repr(a), "3.1")
vereq(a.prec, 2)
a = Number(234.5)
- vereq(`a`, "234.5")
+ vereq(repr(a), "234.5")
vereq(a.prec, 12)
def spamlists():
@@ -2801,8 +2801,8 @@ def pickles():
vereq(sorteditems(x.__dict__), sorteditems(a.__dict__))
vereq(y.__class__, b.__class__)
vereq(sorteditems(y.__dict__), sorteditems(b.__dict__))
- vereq(`x`, `a`)
- vereq(`y`, `b`)
+ vereq(repr(x), repr(a))
+ vereq(repr(y), repr(b))
if verbose:
print "a = x =", a
print "b = y =", b
@@ -2835,8 +2835,8 @@ def pickles():
vereq(sorteditems(x.__dict__), sorteditems(a.__dict__))
vereq(y.__class__, b.__class__)
vereq(sorteditems(y.__dict__), sorteditems(b.__dict__))
- vereq(`x`, `a`)
- vereq(`y`, `b`)
+ vereq(repr(x), repr(a))
+ vereq(repr(y), repr(b))
if verbose:
print "a = x =", a
print "b = y =", b
@@ -2968,13 +2968,13 @@ def binopoverride():
else:
return I(pow(int(other), int(self), int(mod)))
- vereq(`I(1) + I(2)`, "I(3)")
- vereq(`I(1) + 2`, "I(3)")
- vereq(`1 + I(2)`, "I(3)")
- vereq(`I(2) ** I(3)`, "I(8)")
- vereq(`2 ** I(3)`, "I(8)")
- vereq(`I(2) ** 3`, "I(8)")
- vereq(`pow(I(2), I(3), I(5))`, "I(3)")
+ vereq(repr(I(1) + I(2)), "I(3)")
+ vereq(repr(I(1) + 2), "I(3)")
+ vereq(repr(1 + I(2)), "I(3)")
+ vereq(repr(I(2) ** I(3)), "I(8)")
+ vereq(repr(2 ** I(3)), "I(8)")
+ vereq(repr(I(2) ** 3), "I(8)")
+ vereq(repr(pow(I(2), I(3), I(5))), "I(3)")
class S(str):
def __eq__(self, other):
return self.lower() == other.lower()
diff --git a/Lib/test/test_fcntl.py b/Lib/test/test_fcntl.py
index 530ca0c0df..1dabfa4af8 100755
--- a/Lib/test/test_fcntl.py
+++ b/Lib/test/test_fcntl.py
@@ -33,7 +33,7 @@ else:
lockdata = struct.pack('hh'+start_len+'hh', fcntl.F_WRLCK, 0, 0, 0, 0, 0)
if lockdata:
if verbose:
- print 'struct.pack: ', `lockdata`
+ print 'struct.pack: ', repr(lockdata)
# the example from the library docs
f = open(filename, 'w')
@@ -44,7 +44,7 @@ if verbose:
if sys.platform not in ['os2emx']:
rv = fcntl.fcntl(f.fileno(), fcntl.F_SETLKW, lockdata)
if verbose:
- print 'String from fcntl with F_SETLKW: ', `rv`
+ print 'String from fcntl with F_SETLKW: ', repr(rv)
f.close()
os.unlink(filename)
diff --git a/Lib/test/test_generators.py b/Lib/test/test_generators.py
index c72fae72a3..0a763675fd 100644
--- a/Lib/test/test_generators.py
+++ b/Lib/test/test_generators.py
@@ -236,7 +236,7 @@ Guido's binary tree example.
... self.right = right
...
... def __repr__(self, level=0, indent=" "):
- ... s = level*indent + `self.label`
+ ... s = level*indent + repr(self.label)
... if self.left:
... s = s + "\\n" + self.left.__repr__(level+1, indent)
... if self.right:
diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py
index 6666c13bc8..0eed4bbc7b 100644
--- a/Lib/test/test_grammar.py
+++ b/Lib/test/test_grammar.py
@@ -47,7 +47,7 @@ if maxint == 2147483647:
try:
x = eval(s)
except OverflowError:
- print "OverflowError on huge integer literal " + `s`
+ print "OverflowError on huge integer literal " + repr(s)
elif eval('maxint == 9223372036854775807'):
if eval('-9223372036854775807-1 != -01000000000000000000000'):
raise TestFailed, 'max negative int'
@@ -58,7 +58,7 @@ elif eval('maxint == 9223372036854775807'):
try:
x = eval(s)
except OverflowError:
- print "OverflowError on huge integer literal " + `s`
+ print "OverflowError on huge integer literal " + repr(s)
else:
print 'Weird maxint value', maxint
diff --git a/Lib/test/test_hash.py b/Lib/test/test_hash.py
index 90e80fc94d..3d6c9d1b67 100644
--- a/Lib/test/test_hash.py
+++ b/Lib/test/test_hash.py
@@ -14,7 +14,7 @@ class HashEqualityTestCase(unittest.TestCase):
hashed = map(hash, objlist)
for h in hashed[1:]:
if h != hashed[0]:
- self.fail("hashed values differ: %s" % `objlist`)
+ self.fail("hashed values differ: %r" % (objlist,))
def test_numeric_literals(self):
self.same_hash(1, 1L, 1.0, 1.0+0.0j)
diff --git a/Lib/test/test_math.py b/Lib/test/test_math.py
index 3a6b7fc88d..a092265b7f 100644
--- a/Lib/test/test_math.py
+++ b/Lib/test/test_math.py
@@ -91,8 +91,8 @@ testit('fmod(-10,1.5)', math.fmod(-10,1.5), -1)
print 'frexp'
def testfrexp(name, (mant, exp), (emant, eexp)):
if abs(mant-emant) > eps or exp != eexp:
- raise TestFailed, '%s returned %s, expected %s'%\
- (name, `mant, exp`, `emant,eexp`)
+ raise TestFailed, '%s returned %r, expected %r'%\
+ (name, (mant, exp), (emant,eexp))
testfrexp('frexp(-1)', math.frexp(-1), (-0.5, 1))
testfrexp('frexp(0)', math.frexp(0), (0, 0))
@@ -125,8 +125,8 @@ testit('log10(10)', math.log10(10), 1)
print 'modf'
def testmodf(name, (v1, v2), (e1, e2)):
if abs(v1-e1) > eps or abs(v2-e2):
- raise TestFailed, '%s returned %s, expected %s'%\
- (name, `v1,v2`, `e1,e2`)
+ raise TestFailed, '%s returned %r, expected %r'%\
+ (name, (v1,v2), (e1,e2))
testmodf('modf(1.5)', math.modf(1.5), (0.5, 1.0))
testmodf('modf(-1.5)', math.modf(-1.5), (-0.5, -1.0))
diff --git a/Lib/test/test_minidom.py b/Lib/test/test_minidom.py
index cb84987714..a54fbd3f32 100644
--- a/Lib/test/test_minidom.py
+++ b/Lib/test/test_minidom.py
@@ -1361,7 +1361,7 @@ for name in names:
print "Test Failed: ", name
sys.stdout.flush()
traceback.print_exception(*sys.exc_info())
- print `sys.exc_info()[1]`
+ print repr(sys.exc_info()[1])
Node.allnodes = {}
if failed:
diff --git a/Lib/test/test_mpz.py b/Lib/test/test_mpz.py
index dc583ae7f4..be1fd1fba7 100644
--- a/Lib/test/test_mpz.py
+++ b/Lib/test/test_mpz.py
@@ -6,7 +6,7 @@ def check_conversion(num):
mpz_num = mpz.mpz(num)
vereq(int(mpz_num), num)
vereq(long(mpz_num), num)
- vereq(str(mpz_num), 'mpz(%s)' % `int(num)`)
+ vereq(str(mpz_num), 'mpz(%d)' % int(num))
check_conversion(10)
check_conversion(10L)
diff --git a/Lib/test/test_poll.py b/Lib/test/test_poll.py
index ed1d736793..2ecae69919 100644
--- a/Lib/test/test_poll.py
+++ b/Lib/test/test_poll.py
@@ -157,7 +157,7 @@ def test_poll2():
elif flags & select.POLLIN:
line = p.readline()
if verbose:
- print `line`
+ print repr(line)
if not line:
if verbose:
print 'EOF'
diff --git a/Lib/test/test_popen2.py b/Lib/test/test_popen2.py
index cf3a09465a..2a15a206e6 100644
--- a/Lib/test/test_popen2.py
+++ b/Lib/test/test_popen2.py
@@ -49,7 +49,7 @@ def _test():
w.close()
got = r.read()
if got.strip() != expected:
- raise ValueError("wrote %s read %s" % (`teststr`, `got`))
+ raise ValueError("wrote %r read %r" % (teststr, got))
print "testing popen3..."
try:
w, r, e = os.popen3([cmd])
@@ -59,10 +59,10 @@ def _test():
w.close()
got = r.read()
if got.strip() != expected:
- raise ValueError("wrote %s read %s" % (`teststr`, `got`))
+ raise ValueError("wrote %r read %r" % (teststr, got))
got = e.read()
if got:
- raise ValueError("unexected %s on stderr" % `got`)
+ raise ValueError("unexected %r on stderr" % (got,))
for inst in popen2._active[:]:
inst.wait()
if popen2._active:
diff --git a/Lib/test/test_pprint.py b/Lib/test/test_pprint.py
index a61bb663e6..27d6b52084 100644
--- a/Lib/test/test_pprint.py
+++ b/Lib/test/test_pprint.py
@@ -40,14 +40,14 @@ class QueryTestCase(unittest.TestCase):
self.a, self.b):
# module-level convenience functions
verify(not pprint.isrecursive(safe),
- "expected not isrecursive for " + `safe`)
+ "expected not isrecursive for %r" % (safe,))
verify(pprint.isreadable(safe),
- "expected isreadable for " + `safe`)
+ "expected isreadable for %r" % (safe,))
# PrettyPrinter methods
verify(not pp.isrecursive(safe),
- "expected not isrecursive for " + `safe`)
+ "expected not isrecursive for %r" % (safe,))
verify(pp.isreadable(safe),
- "expected isreadable for " + `safe`)
+ "expected isreadable for %r" % (safe,))
def test_knotted(self):
# Verify .isrecursive() and .isreadable() w/ recursion
@@ -74,14 +74,14 @@ class QueryTestCase(unittest.TestCase):
for safe in self.a, self.b, self.d, (self.d, self.d):
# module-level convenience functions
verify(not pprint.isrecursive(safe),
- "expected not isrecursive for " + `safe`)
+ "expected not isrecursive for %r" % (safe,))
verify(pprint.isreadable(safe),
- "expected isreadable for " + `safe`)
+ "expected isreadable for %r" % (safe,))
# PrettyPrinter methods
verify(not pp.isrecursive(safe),
- "expected not isrecursive for " + `safe`)
+ "expected not isrecursive for %r" % (safe,))
verify(pp.isreadable(safe),
- "expected isreadable for " + `safe`)
+ "expected isreadable for %r" % (safe,))
def test_unreadable(self):
# Not recursive but not readable anyway
@@ -90,14 +90,14 @@ class QueryTestCase(unittest.TestCase):
for unreadable in type(3), pprint, pprint.isrecursive:
# module-level convenience functions
verify(not pprint.isrecursive(unreadable),
- "expected not isrecursive for " + `unreadable`)
+ "expected not isrecursive for %r" % (unreadable,))
verify(not pprint.isreadable(unreadable),
- "expected not isreadable for " + `unreadable`)
+ "expected not isreadable for %r" % (unreadable,))
# PrettyPrinter methods
verify(not pp.isrecursive(unreadable),
- "expected not isrecursive for " + `unreadable`)
+ "expected not isrecursive for %r" % (unreadable,))
verify(not pp.isreadable(unreadable),
- "expected not isreadable for " + `unreadable`)
+ "expected not isreadable for %r" % (unreadable,))
def test_same_as_repr(self):
# Simple objects, small containers and classes that overwrite __repr__
@@ -174,7 +174,7 @@ class DottedPrettyPrinter(pprint.PrettyPrinter):
def format(self, object, context, maxlevels, level):
if isinstance(object, str):
if ' ' in object:
- return `object`, 1, 0
+ return repr(object), 1, 0
else:
return object, 0, 0
else:
diff --git a/Lib/test/test_pty.py b/Lib/test/test_pty.py
index 7a1b7b1e3f..6bf907227c 100644
--- a/Lib/test/test_pty.py
+++ b/Lib/test/test_pty.py
@@ -19,7 +19,7 @@ def test_basic_pty():
debug("Calling master_open()")
master_fd, slave_name = pty.master_open()
debug("Got master_fd '%d', slave_name '%s'"%(master_fd, slave_name))
- debug("Calling slave_open(%s)"%`slave_name`)
+ debug("Calling slave_open(%r)"%(slave_name,))
slave_fd = pty.slave_open(slave_name)
debug("Got slave_fd '%d'"%slave_fd)
except OSError:
diff --git a/Lib/test/test_pyexpat.py b/Lib/test/test_pyexpat.py
index 09314c37ce..f281f8baad 100644
--- a/Lib/test/test_pyexpat.py
+++ b/Lib/test/test_pyexpat.py
@@ -216,7 +216,7 @@ for entry in L:
if tag is not entry:
print "expected L to contain many references to the same string",
print "(it didn't)"
- print "L =", `L`
+ print "L =", repr(L)
break
# Tests of the buffer_text attribute.
@@ -228,8 +228,8 @@ class TextCollector:
def check(self, expected, label):
require(self.stuff == expected,
- "%s\nstuff = %s\nexpected = %s"
- % (label, `self.stuff`, `map(unicode, expected)`))
+ "%s\nstuff = %r\nexpected = %r"
+ % (label, self.stuff, map(unicode, expected)))
def CharacterDataHandler(self, text):
self.stuff.append(text)
diff --git a/Lib/test/test_repr.py b/Lib/test/test_repr.py
index 29e1687a2d..48d969f573 100644
--- a/Lib/test/test_repr.py
+++ b/Lib/test/test_repr.py
@@ -25,12 +25,12 @@ class ReprTests(unittest.TestCase):
eq(r("abcdefghijklmnop"),"'abcdefghijklmnop'")
s = "a"*30+"b"*30
- expected = `s`[:13] + "..." + `s`[-14:]
+ expected = repr(s)[:13] + "..." + repr(s)[-14:]
eq(r(s), expected)
eq(r("\"'"), repr("\"'"))
s = "\""*30+"'"*100
- expected = `s`[:13] + "..." + `s`[-14:]
+ expected = repr(s)[:13] + "..." + repr(s)[-14:]
eq(r(s), expected)
def test_container(self):
@@ -75,7 +75,7 @@ class ReprTests(unittest.TestCase):
eq(r(1.0/3), repr(1.0/3))
n = 10L**100
- expected = `n`[:18] + "..." + `n`[-19:]
+ expected = repr(n)[:18] + "..." + repr(n)[-19:]
eq(r(n), expected)
def test_instance(self):
@@ -84,7 +84,7 @@ class ReprTests(unittest.TestCase):
eq(r(i1), repr(i1))
i2 = ClassWithRepr("x"*1000)
- expected = `i2`[:13] + "..." + `i2`[-14:]
+ expected = repr(i2)[:13] + "..." + repr(i2)[-14:]
eq(r(i2), expected)
i3 = ClassWithFailingRepr()
diff --git a/Lib/test/test_rotor.py b/Lib/test/test_rotor.py
index eeec55a7a4..16a7dcddf6 100644
--- a/Lib/test/test_rotor.py
+++ b/Lib/test/test_rotor.py
@@ -13,9 +13,9 @@ A = 'spam and eggs'
B = 'cheese shop'
a = r.encrypt(A)
-print `a`
+print repr(a)
b = r.encryptmore(B)
-print `b`
+print repr(b)
A1 = r.decrypt(a)
print A1
diff --git a/Lib/test/test_select.py b/Lib/test/test_select.py
index 6a00fe404e..eaec52be19 100644
--- a/Lib/test/test_select.py
+++ b/Lib/test/test_select.py
@@ -57,7 +57,7 @@ def test():
if (rfd, wfd, xfd) == ([p], [], []):
line = p.readline()
if verbose:
- print `line`
+ print repr(line)
if not line:
if verbose:
print 'EOF'
diff --git a/Lib/test/test_set.py b/Lib/test/test_set.py
index 3b108a1ebd..3a85c767a8 100644
--- a/Lib/test/test_set.py
+++ b/Lib/test/test_set.py
@@ -426,7 +426,7 @@ class TestBasicOps(unittest.TestCase):
def test_repr(self):
if self.repr is not None:
- self.assertEqual(`self.set`, self.repr)
+ self.assertEqual(repr(self.set), self.repr)
def test_length(self):
self.assertEqual(len(self.set), self.length)
@@ -1076,7 +1076,7 @@ class TestCopying(unittest.TestCase):
def test_deep_copy(self):
dup = copy.deepcopy(self.set)
- ##print type(dup), `dup`
+ ##print type(dup), repr(dup)
dup_list = list(dup); dup_list.sort()
set_list = list(self.set); set_list.sort()
self.assertEqual(len(dup_list), len(set_list))
diff --git a/Lib/test/test_sets.py b/Lib/test/test_sets.py
index 9cc586f832..4947e6bfa4 100644
--- a/Lib/test/test_sets.py
+++ b/Lib/test/test_sets.py
@@ -12,7 +12,7 @@ class TestBasicOps(unittest.TestCase):
def test_repr(self):
if self.repr is not None:
- self.assertEqual(`self.set`, self.repr)
+ self.assertEqual(repr(self.set), self.repr)
def test_length(self):
self.assertEqual(len(self.set), self.length)
@@ -670,7 +670,7 @@ class TestCopying(unittest.TestCase):
def test_deep_copy(self):
dup = copy.deepcopy(self.set)
- ##print type(dup), `dup`
+ ##print type(dup), repr(dup)
dup_list = list(dup); dup_list.sort()
set_list = list(self.set); set_list.sort()
self.assertEqual(len(dup_list), len(set_list))
diff --git a/Lib/test/test_socketserver.py b/Lib/test/test_socketserver.py
index 36396daa6f..cee5593b61 100644
--- a/Lib/test/test_socketserver.py
+++ b/Lib/test/test_socketserver.py
@@ -43,7 +43,7 @@ def receive(sock, n, timeout=20):
if sock in r:
return sock.recv(n)
else:
- raise RuntimeError, "timed out on %s" % `sock`
+ raise RuntimeError, "timed out on %r" % (sock,)
def testdgram(proto, addr):
s = socket.socket(proto, socket.SOCK_DGRAM)
diff --git a/Lib/test/test_struct.py b/Lib/test/test_struct.py
index 1e1092daad..0641d9ba45 100644
--- a/Lib/test/test_struct.py
+++ b/Lib/test/test_struct.py
@@ -48,8 +48,8 @@ fmt3 = '3c3b18x12h6i6l6f3d'
sz = struct.calcsize(fmt)
sz3 = struct.calcsize(fmt3)
if sz * 3 != sz3:
- raise TestFailed, 'inconsistent sizes (3*%s -> 3*%d = %d, %s -> %d)' % (
- `fmt`, sz, 3*sz, `fmt3`, sz3)
+ raise TestFailed, 'inconsistent sizes (3*%r -> 3*%d = %d, %r -> %d)' % (
+ fmt, sz, 3*sz, fmt3, sz3)
simple_err(struct.pack, 'iii', 3)
simple_err(struct.pack, 'i', 3, 3, 3)
@@ -120,21 +120,21 @@ tests = [
for fmt, arg, big, lil, asy in tests:
if verbose:
- print `fmt`, `arg`, `big`, `lil`
+ print "%r %r %r %r" % (fmt, arg, big, lil)
for (xfmt, exp) in [('>'+fmt, big), ('!'+fmt, big), ('<'+fmt, lil),
('='+fmt, ISBIGENDIAN and big or lil)]:
res = struct.pack(xfmt, arg)
if res != exp:
- raise TestFailed, "pack(%s, %s) -> %s # expected %s" % (
- `fmt`, `arg`, `res`, `exp`)
+ raise TestFailed, "pack(%r, %r) -> %r # expected %r" % (
+ fmt, arg, res, exp)
n = struct.calcsize(xfmt)
if n != len(res):
- raise TestFailed, "calcsize(%s) -> %d # expected %d" % (
- `xfmt`, n, len(res))
+ raise TestFailed, "calcsize(%r) -> %d # expected %d" % (
+ xfmt, n, len(res))
rev = struct.unpack(xfmt, res)[0]
if rev != arg and not asy:
- raise TestFailed, "unpack(%s, %s) -> (%s,) # expected (%s,)" % (
- `fmt`, `res`, `rev`, `arg`)
+ raise TestFailed, "unpack(%r, %r) -> (%r,) # expected (%r,)" % (
+ fmt, res, rev, arg)
###########################################################################
# Simple native q/Q tests.
diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py
index a40190ee86..4838608335 100644
--- a/Lib/test/test_syntax.py
+++ b/Lib/test/test_syntax.py
@@ -18,7 +18,7 @@ class SyntaxTestCase(unittest.TestCase):
except SyntaxError, err:
mo = re.search(errtext, str(err))
if mo is None:
- self.fail("SyntaxError did not contain '%s'" % `errtext`)
+ self.fail("SyntaxError did not contain '%r'" % (errtext,))
else:
self.fail("compile() did not raise SyntaxError")
diff --git a/Lib/test/test_types.py b/Lib/test/test_types.py
index 1dd51650d0..aa8f854db0 100644
--- a/Lib/test/test_types.py
+++ b/Lib/test/test_types.py
@@ -386,9 +386,9 @@ for copymode in -1, +1:
a = {}
b = {}
for i in range(size):
- a[`i`] = i
+ a[repr(i)] = i
if copymode < 0:
- b[`i`] = i
+ b[repr(i)] = i
if copymode > 0:
b = a.copy()
for i in range(size):
diff --git a/Lib/test/test_univnewlines.py b/Lib/test/test_univnewlines.py
index a6c079b170..e91bde72c6 100644
--- a/Lib/test/test_univnewlines.py
+++ b/Lib/test/test_univnewlines.py
@@ -51,13 +51,13 @@ class TestGenericUnivNewlines(unittest.TestCase):
fp = open(test_support.TESTFN, self.READMODE)
data = fp.read()
self.assertEqual(data, DATA_LF)
- self.assertEqual(`fp.newlines`, `self.NEWLINE`)
+ self.assertEqual(repr(fp.newlines), repr(self.NEWLINE))
def test_readlines(self):
fp = open(test_support.TESTFN, self.READMODE)
data = fp.readlines()
self.assertEqual(data, DATA_SPLIT)
- self.assertEqual(`fp.newlines`, `self.NEWLINE`)
+ self.assertEqual(repr(fp.newlines), repr(self.NEWLINE))
def test_readline(self):
fp = open(test_support.TESTFN, self.READMODE)
@@ -67,7 +67,7 @@ class TestGenericUnivNewlines(unittest.TestCase):
data.append(d)
d = fp.readline()
self.assertEqual(data, DATA_SPLIT)
- self.assertEqual(`fp.newlines`, `self.NEWLINE`)
+ self.assertEqual(repr(fp.newlines), repr(self.NEWLINE))
def test_seek(self):
fp = open(test_support.TESTFN, self.READMODE)
diff --git a/Lib/test/test_weakref.py b/Lib/test/test_weakref.py
index 00cd7ae04f..b2d266d9c3 100644
--- a/Lib/test/test_weakref.py
+++ b/Lib/test/test_weakref.py
@@ -176,7 +176,7 @@ class ReferencesTestCase(TestBase):
L2 = UserList.UserList(L)
p2 = weakref.proxy(L2)
self.assertEqual(p, p2)
- ## self.assertEqual(`L2`, `p2`)
+ ## self.assertEqual(repr(L2), repr(p2))
L3 = UserList.UserList(range(10))
p3 = weakref.proxy(L3)
self.assertEqual(L3[:], p3[:])
diff --git a/Lib/toaiff.py b/Lib/toaiff.py
index 51752f4233..3c8a02ba72 100644
--- a/Lib/toaiff.py
+++ b/Lib/toaiff.py
@@ -92,13 +92,12 @@ def _toaiff(filename, temps):
type(msg[0]) == type(0) and type(msg[1]) == type(''):
msg = msg[1]
if type(msg) != type(''):
- msg = `msg`
+ msg = repr(msg)
raise error, filename + ': ' + msg
if ftype == 'aiff':
return fname
if ftype is None or not ftype in table:
- raise error, \
- filename + ': unsupported audio file type ' + `ftype`
+ raise error, '%s: unsupported audio file type %r' % (filename, ftype)
(fd, temp) = tempfile.mkstemp()
os.close(fd)
temps.append(temp)
diff --git a/Lib/trace.py b/Lib/trace.py
index b694c15021..8a31d8ea21 100644
--- a/Lib/trace.py
+++ b/Lib/trace.py
@@ -674,7 +674,7 @@ def main(argv=None):
ignoremods=ignore_modules, ignoredirs=ignore_dirs,
infile=counts_file, outfile=counts_file)
try:
- t.run('execfile(' + `progname` + ')')
+ t.run('execfile(%r)' % (progname,))
except IOError, err:
_err_exit("Cannot run file %r because: %s" % (sys.argv[0], err))
except SystemExit:
diff --git a/Lib/unittest.py b/Lib/unittest.py
index 0ec059c801..29d90e3bfa 100644
--- a/Lib/unittest.py
+++ b/Lib/unittest.py
@@ -330,7 +330,7 @@ class TestCase:
"""
if not first == second:
raise self.failureException, \
- (msg or '%s != %s' % (`first`, `second`))
+ (msg or '%r != %r' % (first, second))
def failIfEqual(self, first, second, msg=None):
"""Fail if the two objects are equal as determined by the '=='
@@ -338,7 +338,7 @@ class TestCase:
"""
if first == second:
raise self.failureException, \
- (msg or '%s == %s' % (`first`, `second`))
+ (msg or '%r == %r' % (first, second))
def failUnlessAlmostEqual(self, first, second, places=7, msg=None):
"""Fail if the two objects are unequal as determined by their
@@ -350,7 +350,7 @@ class TestCase:
"""
if round(second-first, places) != 0:
raise self.failureException, \
- (msg or '%s != %s within %s places' % (`first`, `second`, `places` ))
+ (msg or '%r != %r within %r places' % (first, second, places))
def failIfAlmostEqual(self, first, second, places=7, msg=None):
"""Fail if the two objects are equal as determined by their
@@ -362,7 +362,7 @@ class TestCase:
"""
if round(second-first, places) == 0:
raise self.failureException, \
- (msg or '%s == %s within %s places' % (`first`, `second`, `places`))
+ (msg or '%r == %r within %r places' % (first, second, places))
# Synonyms for assertion methods
diff --git a/Lib/urllib.py b/Lib/urllib.py
index 5449104bf7..bf983e5898 100644
--- a/Lib/urllib.py
+++ b/Lib/urllib.py
@@ -794,8 +794,8 @@ class addbase:
self.next = self.fp.next
def __repr__(self):
- return '<%s at %s whose fp = %s>' % (self.__class__.__name__,
- `id(self)`, `self.fp`)
+ return '<%s at %r whose fp = %r>' % (self.__class__.__name__,
+ id(self), self.fp)
def close(self):
self.read = None
@@ -1407,9 +1407,9 @@ def test1():
t1 = time.time()
if uqs != s:
print 'Wrong!'
- print `s`
- print `qs`
- print `uqs`
+ print repr(s)
+ print repr(qs)
+ print repr(uqs)
print round(t1 - t0, 3), 'sec'
diff --git a/Lib/warnings.py b/Lib/warnings.py
index c2bc06ee70..c6e6006d87 100644
--- a/Lib/warnings.py
+++ b/Lib/warnings.py
@@ -110,8 +110,8 @@ def warn_explicit(message, category, filename, lineno,
else:
# Unrecognized actions are errors
raise RuntimeError(
- "Unrecognized action (%s) in warnings.filters:\n %s" %
- (`action`, str(item)))
+ "Unrecognized action (%r) in warnings.filters:\n %s" %
+ (action, item))
# Print message and context
showwarning(message, category, filename, lineno)
@@ -139,7 +139,7 @@ def filterwarnings(action, message="", category=Warning, module="", lineno=0,
Use assertions to check that all arguments have the right type."""
import re
assert action in ("error", "ignore", "always", "default", "module",
- "once"), "invalid action: %s" % `action`
+ "once"), "invalid action: %r" % (action,)
assert isinstance(message, basestring), "message must be a string"
assert isinstance(category, types.ClassType), "category must be a class"
assert issubclass(category, Warning), "category must be a Warning subclass"
@@ -159,7 +159,7 @@ def simplefilter(action, category=Warning, lineno=0, append=0):
A simple filter matches all modules and messages.
"""
assert action in ("error", "ignore", "always", "default", "module",
- "once"), "invalid action: %s" % `action`
+ "once"), "invalid action: %r" % (action,)
assert isinstance(lineno, int) and lineno >= 0, \
"lineno must be an int >= 0"
item = (action, None, category, None, lineno)
@@ -189,7 +189,7 @@ def _setoption(arg):
import re
parts = arg.split(':')
if len(parts) > 5:
- raise _OptionError("too many fields (max 5): %s" % `arg`)
+ raise _OptionError("too many fields (max 5): %r" % (arg,))
while len(parts) < 5:
parts.append('')
action, message, category, module, lineno = [s.strip()
@@ -206,7 +206,7 @@ def _setoption(arg):
if lineno < 0:
raise ValueError
except (ValueError, OverflowError):
- raise _OptionError("invalid lineno %s" % `lineno`)
+ raise _OptionError("invalid lineno %r" % (lineno,))
else:
lineno = 0
filterwarnings(action, message, category, module, lineno)
@@ -219,7 +219,7 @@ def _getaction(action):
for a in ['default', 'always', 'ignore', 'module', 'once', 'error']:
if a.startswith(action):
return a
- raise _OptionError("invalid action: %s" % `action`)
+ raise _OptionError("invalid action: %r" % (action,))
# Helper for _setoption()
def _getcategory(category):
@@ -230,7 +230,7 @@ def _getcategory(category):
try:
cat = eval(category)
except NameError:
- raise _OptionError("unknown warning category: %s" % `category`)
+ raise _OptionError("unknown warning category: %r" % (category,))
else:
i = category.rfind(".")
module = category[:i]
@@ -238,14 +238,14 @@ def _getcategory(category):
try:
m = __import__(module, None, None, [klass])
except ImportError:
- raise _OptionError("invalid module name: %s" % `module`)
+ raise _OptionError("invalid module name: %r" % (module,))
try:
cat = getattr(m, klass)
except AttributeError:
- raise _OptionError("unknown warning category: %s" % `category`)
+ raise _OptionError("unknown warning category: %r" % (category,))
if (not isinstance(cat, types.ClassType) or
not issubclass(cat, Warning)):
- raise _OptionError("invalid warning category: %s" % `category`)
+ raise _OptionError("invalid warning category: %r" % (category,))
return cat
# Module initialization
diff --git a/Lib/wave.py b/Lib/wave.py
index d41a9bd19d..29e15a0182 100644
--- a/Lib/wave.py
+++ b/Lib/wave.py
@@ -261,7 +261,7 @@ class Wave_read:
sampwidth = struct.unpack('<h', chunk.read(2))[0]
self._sampwidth = (sampwidth + 7) // 8
else:
- raise Error, 'unknown format: ' + `wFormatTag`
+ raise Error, 'unknown format: %r' % (wFormatTag,)
self._framesize = self._nchannels * self._sampwidth
self._comptype = 'NONE'
self._compname = 'not compressed'
diff --git a/Lib/xdrlib.py b/Lib/xdrlib.py
index dfb9742ff9..112309036d 100644
--- a/Lib/xdrlib.py
+++ b/Lib/xdrlib.py
@@ -211,7 +211,7 @@ class Unpacker:
x = self.unpack_uint()
if x == 0: break
if x != 1:
- raise ConversionError, '0 or 1 expected, got ' + `x`
+ raise ConversionError, '0 or 1 expected, got %r' % (x,)
item = unpack_item()
list.append(item)
return list
diff --git a/Lib/xml/dom/domreg.py b/Lib/xml/dom/domreg.py
index 117ca49820..684c436016 100644
--- a/Lib/xml/dom/domreg.py
+++ b/Lib/xml/dom/domreg.py
@@ -87,7 +87,7 @@ def _parse_feature_string(s):
while i < length:
feature = parts[i]
if feature[0] in "0123456789":
- raise ValueError, "bad feature name: " + `feature`
+ raise ValueError, "bad feature name: %r" % (feature,)
i = i + 1
version = None
if i < length:
diff --git a/Lib/xml/dom/minidom.py b/Lib/xml/dom/minidom.py
index a5ebe5f7e3..f17578baac 100644
--- a/Lib/xml/dom/minidom.py
+++ b/Lib/xml/dom/minidom.py
@@ -622,9 +622,9 @@ class TypeInfo(NewStyle):
def __repr__(self):
if self.namespace:
- return "<TypeInfo %s (from %s)>" % (`self.name`, `self.namespace`)
+ return "<TypeInfo %r (from %r)>" % (self.name, self.namespace)
else:
- return "<TypeInfo %s>" % `self.name`
+ return "<TypeInfo %r>" % self.name
def _get_name(self):
return self.name
diff --git a/Lib/xml/dom/xmlbuilder.py b/Lib/xml/dom/xmlbuilder.py
index fd43c37ed3..5c044128f6 100644
--- a/Lib/xml/dom/xmlbuilder.py
+++ b/Lib/xml/dom/xmlbuilder.py
@@ -81,7 +81,7 @@ class DOMBuilder:
settings = self._settings[(_name_xform(name), state)]
except KeyError:
raise xml.dom.NotSupportedErr(
- "unsupported feature: " + `name`)
+ "unsupported feature: %r" % (name,))
else:
for name, value in settings:
setattr(self._options, name, value)
diff --git a/Lib/xmllib.py b/Lib/xmllib.py
index cdc861eb68..f1cd2e45aa 100644
--- a/Lib/xmllib.py
+++ b/Lib/xmllib.py
@@ -817,30 +817,30 @@ class TestXMLParser(XMLParser):
def handle_doctype(self, tag, pubid, syslit, data):
self.flush()
- print 'DOCTYPE:',tag, `data`
+ print 'DOCTYPE:',tag, repr(data)
def handle_data(self, data):
self.testdata = self.testdata + data
- if len(`self.testdata`) >= 70:
+ if len(repr(self.testdata)) >= 70:
self.flush()
def flush(self):
data = self.testdata
if data:
self.testdata = ""
- print 'data:', `data`
+ print 'data:', repr(data)
def handle_cdata(self, data):
self.flush()
- print 'cdata:', `data`
+ print 'cdata:', repr(data)
def handle_proc(self, name, data):
self.flush()
- print 'processing:',name,`data`
+ print 'processing:',name,repr(data)
def handle_comment(self, data):
self.flush()
- r = `data`
+ r = repr(data)
if len(r) > 68:
r = r[:32] + '...' + r[-32:]
print 'comment:', r
diff --git a/Mac/Demo/PICTbrowse/ICONbrowse.py b/Mac/Demo/PICTbrowse/ICONbrowse.py
index 42ae96d75f..1194b7e1e1 100644
--- a/Mac/Demo/PICTbrowse/ICONbrowse.py
+++ b/Mac/Demo/PICTbrowse/ICONbrowse.py
@@ -52,7 +52,7 @@ class ICONbrowse(FrameWork.Application):
def showICON(self, resid):
w = ICONwindow(self)
w.open(resid)
- #EasyDialogs.Message('Show ICON '+`resid`)
+ #EasyDialogs.Message('Show ICON %r' % (resid,))
def findICONresources(self):
num = Res.CountResources('ICON')
@@ -70,7 +70,7 @@ class ICONbrowse(FrameWork.Application):
class ICONwindow(FrameWork.Window):
def open(self, (resid, resname)):
if not resname:
- resname = '#'+`resid`
+ resname = '#%r' % (resid,)
self.resid = resid
self.picture = Icn.GetIcon(self.resid)
l, t, r, b = 0, 0, 32, 32
@@ -127,7 +127,7 @@ class MyDialog(FrameWork.DialogWindow):
if self.contents:
self.list.LAddRow(len(self.contents), 0)
for i in range(len(self.contents)):
- v = `self.contents[i][0]`
+ v = repr(self.contents[i][0])
if self.contents[i][1]:
v = v + '"' + self.contents[i][1] + '"'
self.list.LSetCell(v, (0, i))
diff --git a/Mac/Demo/PICTbrowse/PICTbrowse.py b/Mac/Demo/PICTbrowse/PICTbrowse.py
index 41ffa5c1d8..eace8691d5 100644
--- a/Mac/Demo/PICTbrowse/PICTbrowse.py
+++ b/Mac/Demo/PICTbrowse/PICTbrowse.py
@@ -47,7 +47,7 @@ class PICTbrowse(FrameWork.Application):
def showPICT(self, resid):
w = PICTwindow(self)
w.open(resid)
- #EasyDialogs.Message('Show PICT '+`resid`)
+ #EasyDialogs.Message('Show PICT %r' % (resid,))
def findPICTresources(self):
num = Res.CountResources('PICT')
@@ -65,11 +65,11 @@ class PICTbrowse(FrameWork.Application):
class PICTwindow(FrameWork.Window):
def open(self, (resid, resname)):
if not resname:
- resname = '#'+`resid`
+ resname = '#%r' % (resid,)
self.resid = resid
picture = Qd.GetPicture(self.resid)
# Get rect for picture
- print `picture.data[:16]`
+ print repr(picture.data[:16])
sz, t, l, b, r = struct.unpack('hhhhh', picture.data[:10])
print 'pict:', t, l, b, r
width = r-l
@@ -105,7 +105,7 @@ class MyDialog(FrameWork.DialogWindow):
if self.contents:
self.list.LAddRow(len(self.contents), 0)
for i in range(len(self.contents)):
- v = `self.contents[i][0]`
+ v = repr(self.contents[i][0])
if self.contents[i][1]:
v = v + '"' + self.contents[i][1] + '"'
self.list.LSetCell(v, (0, i))
diff --git a/Mac/Demo/PICTbrowse/PICTbrowse2.py b/Mac/Demo/PICTbrowse/PICTbrowse2.py
index da389c0a28..875c99b07a 100644
--- a/Mac/Demo/PICTbrowse/PICTbrowse2.py
+++ b/Mac/Demo/PICTbrowse/PICTbrowse2.py
@@ -51,7 +51,7 @@ class PICTbrowse(FrameWork.Application):
def showPICT(self, resid):
w = PICTwindow(self)
w.open(resid)
- #EasyDialogs.Message('Show PICT '+`resid`)
+ #EasyDialogs.Message('Show PICT %r' % (resid,))
def findPICTresources(self):
num = Res.CountResources('PICT')
@@ -69,7 +69,7 @@ class PICTbrowse(FrameWork.Application):
class PICTwindow(FrameWork.Window):
def open(self, (resid, resname)):
if not resname:
- resname = '#'+`resid`
+ resname = '#%r' % (resid,)
self.resid = resid
self.picture = Qd.GetPicture(self.resid)
# Get rect for picture
@@ -127,7 +127,7 @@ class MyDialog(FrameWork.DialogWindow):
if self.contents:
self.list.LAddRow(len(self.contents), 0)
for i in range(len(self.contents)):
- v = `self.contents[i][0]`
+ v = repr(self.contents[i][0])
if self.contents[i][1]:
v = v + '"' + self.contents[i][1] + '"'
self.list.LSetCell(v, (0, i))
diff --git a/Mac/Demo/PICTbrowse/cicnbrowse.py b/Mac/Demo/PICTbrowse/cicnbrowse.py
index b90143e195..e3d79720ac 100644
--- a/Mac/Demo/PICTbrowse/cicnbrowse.py
+++ b/Mac/Demo/PICTbrowse/cicnbrowse.py
@@ -52,7 +52,7 @@ class CIconbrowse(FrameWork.Application):
def showCIcon(self, resid):
w = CIconwindow(self)
w.open(resid)
- #EasyDialogs.Message('Show cicn '+`resid`)
+ #EasyDialogs.Message('Show cicn %r' % (resid,))
def findcicnresources(self):
num = Res.CountResources('cicn')
@@ -70,7 +70,7 @@ class CIconbrowse(FrameWork.Application):
class CIconwindow(FrameWork.Window):
def open(self, (resid, resname)):
if not resname:
- resname = '#'+`resid`
+ resname = '#%r' % (resid,)
self.resid = resid
self.picture = Icn.GetCIcon(self.resid)
l, t, r, b = 0, 0, 32, 32
@@ -127,7 +127,7 @@ class MyDialog(FrameWork.DialogWindow):
if self.contents:
self.list.LAddRow(len(self.contents), 0)
for i in range(len(self.contents)):
- v = `self.contents[i][0]`
+ v = repr(self.contents[i][0])
if self.contents[i][1]:
v = v + '"' + self.contents[i][1] + '"'
self.list.LSetCell(v, (0, i))
diff --git a/Mac/Demo/PICTbrowse/oldPICTbrowse.py b/Mac/Demo/PICTbrowse/oldPICTbrowse.py
index dc1f5b4913..5f5893c359 100644
--- a/Mac/Demo/PICTbrowse/oldPICTbrowse.py
+++ b/Mac/Demo/PICTbrowse/oldPICTbrowse.py
@@ -46,7 +46,7 @@ class PICTbrowse(FrameWork.Application):
def showPICT(self, resid):
w = PICTwindow(self)
w.open(resid)
- #EasyDialogs.Message('Show PICT '+`resid`)
+ #EasyDialogs.Message('Show PICT %r' % (resid,))
def findPICTresources(self):
num = Res.CountResources('PICT')
@@ -64,11 +64,11 @@ class PICTbrowse(FrameWork.Application):
class PICTwindow(FrameWork.Window):
def open(self, (resid, resname)):
if not resname:
- resname = '#'+`resid`
+ resname = '#%r' % (resid,)
self.resid = resid
picture = Qd.GetPicture(self.resid)
# Get rect for picture
- print `picture.data[:16]`
+ print repr(picture.data[:16])
sz, t, l, b, r = struct.unpack('hhhhh', picture.data[:10])
print 'pict:', t, l, b, r
width = r-l
@@ -104,7 +104,7 @@ class MyDialog(FrameWork.DialogWindow):
if self.contents:
self.list.LAddRow(len(self.contents), 0)
for i in range(len(self.contents)):
- v = `self.contents[i][0]`
+ v = repr(self.contents[i][0])
if self.contents[i][1]:
v = v + '"' + self.contents[i][1] + '"'
self.list.LSetCell(v, (0, i))
diff --git a/Mac/Demo/calldll/testcalldll.py b/Mac/Demo/calldll/testcalldll.py
index cdb24c3d4f..d4a4853462 100644
--- a/Mac/Demo/calldll/testcalldll.py
+++ b/Mac/Demo/calldll/testcalldll.py
@@ -99,7 +99,7 @@ rv = cdll_N_pp('pascal string')
if rv == 'Was: pascal string':
print 'ok.'
else:
- print 'Failed, returned', `rv`
+ print 'Failed, returned', repr(rv)
print 'Test cdll_N_bb'
rv = cdll_N_bb(-100)
@@ -128,5 +128,5 @@ rv = cdll_N_sH('new data', h)
if rv == None and h.data == 'new data':
print 'ok.'
else:
- print 'Failed, rv is', rv, 'and handle data is', `rv.data`
+ print 'Failed, rv is', rv, 'and handle data is', repr(rv.data)
sys.exit(1)
diff --git a/Mac/Demo/imgbrowse/imgbrowse.py b/Mac/Demo/imgbrowse/imgbrowse.py
index d8164eaebe..262c650e4a 100644
--- a/Mac/Demo/imgbrowse/imgbrowse.py
+++ b/Mac/Demo/imgbrowse/imgbrowse.py
@@ -53,7 +53,7 @@ class imgbrowse(FrameWork.Application):
try:
rdr = img.reader(imgformat.macrgb16, pathname)
except img.error, arg:
- EasyDialogs.Message(`arg`)
+ EasyDialogs.Message(repr(arg))
return
w, h = rdr.width, rdr.height
bar.set(10)
diff --git a/Mac/Demo/mlte/mlted.py b/Mac/Demo/mlte/mlted.py
index 53f9f5dae0..381345aa2e 100644
--- a/Mac/Demo/mlte/mlted.py
+++ b/Mac/Demo/mlte/mlted.py
@@ -276,7 +276,7 @@ class Mlted(Application):
data = fp.read()
fp.close()
except IOError, arg:
- EasyDialogs.Message("IOERROR: "+`arg`)
+ EasyDialogs.Message("IOERROR: %r" % (arg,))
return
else:
path = None
diff --git a/Mac/Demo/resources/listres.py b/Mac/Demo/resources/listres.py
index 7575db803e..eacf2b7ede 100644
--- a/Mac/Demo/resources/listres.py
+++ b/Mac/Demo/resources/listres.py
@@ -7,7 +7,7 @@ def list1resources():
ntypes = Res.Count1Types()
for itype in range(1, 1+ntypes):
type = Res.Get1IndType(itype)
- print "Type:", `type`
+ print "Type:", repr(type)
nresources = Res.Count1Resources(type)
for i in range(1, 1 + nresources):
Res.SetResLoad(0)
@@ -19,7 +19,7 @@ def listresources():
ntypes = Res.CountTypes()
for itype in range(1, 1+ntypes):
type = Res.GetIndType(itype)
- print "Type:", `type`
+ print "Type:", repr(type)
nresources = Res.CountResources(type)
for i in range(1, 1 + nresources):
Res.SetResLoad(0)
diff --git a/Mac/Demo/textedit/ped.py b/Mac/Demo/textedit/ped.py
index 80cf7e5ce8..eee848bcb7 100644
--- a/Mac/Demo/textedit/ped.py
+++ b/Mac/Demo/textedit/ped.py
@@ -274,7 +274,7 @@ class Ped(Application):
data = fp.read()
fp.close()
except IOError, arg:
- EasyDialogs.Message("IOERROR: "+`arg`)
+ EasyDialogs.Message("IOERROR: %r" % (arg,))
return
else:
path = None
diff --git a/Mac/Demo/waste/htmled.py b/Mac/Demo/waste/htmled.py
index d415de13f2..871076633a 100644
--- a/Mac/Demo/waste/htmled.py
+++ b/Mac/Demo/waste/htmled.py
@@ -516,7 +516,7 @@ class Wed(Application):
self.sizemenu = Menu(self.menubar, "Size")
self.sizeitems = []
for n in SIZES:
- m = MenuItem(self.sizemenu, `n`, "", self.selsize)
+ m = MenuItem(self.sizemenu, repr(n), "", self.selsize)
self.sizeitems.append(m)
self.sizemenu.addseparator()
self.sizeitem_bigger = MenuItem(self.sizemenu, "Bigger", "+",
@@ -670,7 +670,7 @@ class Wed(Application):
data = fp.read()
fp.close()
except IOError, arg:
- EasyDialogs.Message("IOERROR: "+`arg`)
+ EasyDialogs.Message("IOERROR: %r" % (arg,))
return
else:
path = None
@@ -688,7 +688,7 @@ class Wed(Application):
try:
fp = open(path, 'rb') # NOTE binary, we need cr as end-of-line
except IOError, arg:
- EasyDialogs.Message("IOERROR: "+`arg`)
+ EasyDialogs.Message("IOERROR: %r" % (args,))
return
self.active.menu_insert(fp)
else:
@@ -702,7 +702,7 @@ class Wed(Application):
try:
fp = open(path, 'r')
except IOError, arg:
- EasyDialogs.Message("IOERROR: "+`arg`)
+ EasyDialogs.Message("IOERROR: %r" % (arg,))
return
self.active.menu_insert_html(fp)
else:
diff --git a/Mac/Demo/waste/swed.py b/Mac/Demo/waste/swed.py
index c85cb21c22..ca772933e7 100644
--- a/Mac/Demo/waste/swed.py
+++ b/Mac/Demo/waste/swed.py
@@ -375,7 +375,7 @@ class Wed(Application):
self.sizemenu = Menu(self.menubar, "Size")
self.sizeitems = []
for n in SIZES:
- m = MenuItem(self.sizemenu, `n`, "", self.selsize)
+ m = MenuItem(self.sizemenu, repr(n), "", self.selsize)
self.sizeitems.append(m)
self.sizemenu.addseparator()
self.sizeitem_bigger = MenuItem(self.sizemenu, "Bigger", "+",
@@ -529,7 +529,7 @@ class Wed(Application):
data = fp.read()
fp.close()
except IOError, arg:
- EasyDialogs.Message("IOERROR: "+`arg`)
+ EasyDialogs.Message("IOERROR: %r" % (arg,))
return
else:
path = None
diff --git a/Mac/Demo/waste/wed.py b/Mac/Demo/waste/wed.py
index 7161ae5bbb..5d84b402b2 100644
--- a/Mac/Demo/waste/wed.py
+++ b/Mac/Demo/waste/wed.py
@@ -338,7 +338,7 @@ class Wed(Application):
data = fp.read()
fp.close()
except IOError, arg:
- EasyDialogs.Message("IOERROR: "+`arg`)
+ EasyDialogs.Message("IOERROR: %r" % (arg,))
return
else:
path = None
diff --git a/Mac/IDE scripts/Widget demos/KeyTester.py b/Mac/IDE scripts/Widget demos/KeyTester.py
index ec66966efc..a9f3140d6f 100644
--- a/Mac/IDE scripts/Widget demos/KeyTester.py
+++ b/Mac/IDE scripts/Widget demos/KeyTester.py
@@ -4,7 +4,7 @@ import W
# key callback function
def tester(char, event):
- text = `char` + "\r" + `ord(char)` + "\r" + hex(ord(char)) + "\r" + oct(ord(char))
+ text = "%r\r%d\r%s\r%s" % (char, ord(char), hex(ord(chart)), oct(ord(char)))
window.keys.set(text)
# close callback
diff --git a/Mac/IDE scripts/Widget demos/WidgetTest.py b/Mac/IDE scripts/Widget demos/WidgetTest.py
index f88b059963..424e70d263 100644
--- a/Mac/IDE scripts/Widget demos/WidgetTest.py
+++ b/Mac/IDE scripts/Widget demos/WidgetTest.py
@@ -79,7 +79,7 @@ window.open()
if 0:
import time
for i in range(20):
- window.et2.set(`i`)
+ window.et2.set(repr(i))
#window.et2.SetPort()
#window.et2.draw()
time.sleep(0.1)
diff --git a/Mac/Tools/IDE/FontSettings.py b/Mac/Tools/IDE/FontSettings.py
index a41fcbd550..af2bd80320 100644
--- a/Mac/Tools/IDE/FontSettings.py
+++ b/Mac/Tools/IDE/FontSettings.py
@@ -51,7 +51,7 @@ class _FontDialog:
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 @@ class _FontDialog:
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 @@ class _FontDialog:
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 @@ class _FontDialog:
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 @@ class _FontDialog:
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 18a089ed73..51ba753b46 100644
--- a/Mac/Tools/IDE/PyDebugger.py
+++ b/Mac/Tools/IDE/PyDebugger.py
@@ -511,7 +511,7 @@ class Debugger(bdb.Bdb):
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 f9d2cb5a46..1abd4cd28e 100644
--- a/Mac/Tools/IDE/PyDocSearch.py
+++ b/Mac/Tools/IDE/PyDocSearch.py
@@ -75,7 +75,7 @@ class Status:
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 0ad7a8a58c..6826c65866 100644
--- a/Mac/Tools/IDE/PyEdit.py
+++ b/Mac/Tools/IDE/PyEdit.py
@@ -43,7 +43,7 @@ class Editor(W.Window):
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 @@ class Editor(W.Window):
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 @@ class _EditorDefaultSettings:
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 @@ class _EditorDefaultSettings:
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 5680aa871a..eb37ad3428 100644
--- a/Mac/Tools/IDE/PyFontify.py
+++ b/Mac/Tools/IDE/PyFontify.py
@@ -152,4 +152,4 @@ def test(path):
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 29e9befa88..111a0b069a 100644
--- a/Mac/Tools/IDE/PythonIDEMain.py
+++ b/Mac/Tools/IDE/PythonIDEMain.py
@@ -394,7 +394,7 @@ class PythonIDE(Wapplication.Application):
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 @@ class PythonIDE(Wapplication.Application):
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 @@ class PythonIDE(Wapplication.Application):
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 ada441986b..a63be2a590 100644
--- a/Mac/Tools/IDE/Wapplication.py
+++ b/Mac/Tools/IDE/Wapplication.py
@@ -118,7 +118,7 @@ class Application(FrameWork.Application):
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 @@ class Application(FrameWork.Application):
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 4c78b88215..a5d556b8ec 100644
--- a/Mac/Tools/IDE/Wbase.py
+++ b/Mac/Tools/IDE/Wbase.py
@@ -229,7 +229,7 @@ class Widget:
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 @@ class HorizontalPanes(Widget):
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 @@ def CallbackCall(callback, mustfit, *args):
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 e0077b2fe7..913797ce4d 100644
--- a/Mac/Tools/IDE/Wsocket.py
+++ b/Mac/Tools/IDE/Wsocket.py
@@ -129,14 +129,14 @@ class Connection(asyncore.dispatcher):
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 @@ class Connection(asyncore.dispatcher):
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 @@ class PyConnection(Connection):
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 @@ class HTTPProxy(Proxy):
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 51b54f36a0..90a25fe99d 100644
--- a/Mac/Tools/IDE/Wtraceback.py
+++ b/Mac/Tools/IDE/Wtraceback.py
@@ -147,9 +147,7 @@ class TraceBack:
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])
diff --git a/Mac/Tools/macfreeze/macfreezegui.py b/Mac/Tools/macfreeze/macfreezegui.py
index 7921a29f7f..5dd3435b6d 100644
--- a/Mac/Tools/macfreeze/macfreezegui.py
+++ b/Mac/Tools/macfreeze/macfreezegui.py
@@ -113,7 +113,7 @@ def dialog(script=None):
try:
debug = string.atoi(string.strip(debug))
except ValueError:
- EasyDialogs.Message("Illegal debug value %s, set to zero."%`debug`)
+ EasyDialogs.Message("Illegal debug value %r, set to zero."%(debug,))
debug = 0
if gentype == ITEM_GENSOURCE:
return 'source', script, dirname, debug
diff --git a/Mac/Tools/macfreeze/macgen_info.py b/Mac/Tools/macfreeze/macgen_info.py
index 9ec6aa03d4..2d984c1ddd 100644
--- a/Mac/Tools/macfreeze/macgen_info.py
+++ b/Mac/Tools/macfreeze/macgen_info.py
@@ -4,5 +4,5 @@ def generate(output, module_dict):
for name in module_dict.keys():
print 'Include %-20s\t'%name,
module = module_dict[name]
- print module.gettype(), '\t', `module`
+ print module.gettype(), '\t', repr(module)
return 0
diff --git a/Mac/Tools/macfreeze/macgenerate.py b/Mac/Tools/macfreeze/macgenerate.py
index 6c60605bdc..dfa2047d40 100644
--- a/Mac/Tools/macfreeze/macgenerate.py
+++ b/Mac/Tools/macfreeze/macgenerate.py
@@ -4,5 +4,5 @@ def generate(program, module_dict):
for name in module_dict.keys():
print 'Include %-20s\t'%name,
module = module_dict[name]
- print module.gettype(), '\t', `module`
+ print module.gettype(), '\t', repr(module)
return 0
diff --git a/Modules/cgen.py b/Modules/cgen.py
index af336cef5e..f47e41f426 100644
--- a/Modules/cgen.py
+++ b/Modules/cgen.py
@@ -232,7 +232,7 @@ def generate(type, func, database):
brac = '('
ket = ')'
print brac + '*',
- print 'arg' + `i+1` + ket,
+ print 'arg' + repr(i+1) + ket,
if a_sub and isnum(a_sub):
print '[', a_sub, ']',
if a_factor:
@@ -249,7 +249,7 @@ def generate(type, func, database):
if 1 <= n <= len(database):
b_type, b_mode, b_factor, b_sub = database[n-1]
if b_mode == 's':
- database[n-1] = b_type, 'i', a_factor, `i`
+ database[n-1] = b_type, 'i', a_factor, repr(i)
n_in_args = n_in_args - 1
#
# Assign argument positions in the Python argument list
@@ -281,20 +281,20 @@ def generate(type, func, database):
j = eval(a_sub)
print '\tif',
print '(!geti' + xtype + 'arraysize(args,',
- print `n_in_args` + ',',
- print `in_pos[j]` + ',',
+ print repr(n_in_args) + ',',
+ print repr(in_pos[j]) + ',',
if xtype <> a_type:
print '('+xtype+' *)',
- print '&arg' + `i+1` + '))'
+ print '&arg' + repr(i+1) + '))'
print '\t\treturn NULL;'
if a_factor:
- print '\targ' + `i+1`,
- print '= arg' + `i+1`,
+ print '\targ' + repr(i+1),
+ print '= arg' + repr(i+1),
print '/', a_factor + ';'
elif a_mode == 's':
if a_sub and not isnum(a_sub):
# Allocate memory for varsize array
- print '\tif ((arg' + `i+1`, '=',
+ print '\tif ((arg' + repr(i+1), '=',
if a_factor:
print '('+a_type+'(*)['+a_factor+'])',
print 'PyMem_NEW(' + a_type, ',',
@@ -305,22 +305,22 @@ def generate(type, func, database):
print '\tif',
if a_factor or a_sub: # Get a fixed-size array array
print '(!geti' + xtype + 'array(args,',
- print `n_in_args` + ',',
- print `in_pos[i]` + ',',
+ print repr(n_in_args) + ',',
+ print repr(in_pos[i]) + ',',
if a_factor: print a_factor,
if a_factor and a_sub: print '*',
if a_sub: print a_sub,
print ',',
if (a_sub and a_factor) or xtype <> a_type:
print '('+xtype+' *)',
- print 'arg' + `i+1` + '))'
+ print 'arg' + repr(i+1) + '))'
else: # Get a simple variable
print '(!geti' + xtype + 'arg(args,',
- print `n_in_args` + ',',
- print `in_pos[i]` + ',',
+ print repr(n_in_args) + ',',
+ print repr(in_pos[i]) + ',',
if xtype <> a_type:
print '('+xtype+' *)',
- print '&arg' + `i+1` + '))'
+ print '&arg' + repr(i+1) + '))'
print '\t\treturn NULL;'
#
# Begin of function call
@@ -337,7 +337,7 @@ def generate(type, func, database):
a_type, a_mode, a_factor, a_sub = database[i]
if a_mode == 'r' and not a_factor:
print '&',
- print 'arg' + `i+1`,
+ print 'arg' + repr(i+1),
#
# End of function call
#
@@ -348,7 +348,7 @@ def generate(type, func, database):
for i in range(len(database)):
a_type, a_mode, a_factor, a_sub = database[i]
if a_mode == 's' and a_sub and not isnum(a_sub):
- print '\tPyMem_DEL(arg' + `i+1` + ');'
+ print '\tPyMem_DEL(arg' + repr(i+1) + ');'
#
# Return
#
@@ -366,7 +366,7 @@ def generate(type, func, database):
else:
raise arg_error, 'expected r arg not found'
print '\treturn',
- print mkobject(a_type, 'arg' + `i+1`) + ';'
+ print mkobject(a_type, 'arg' + repr(i+1)) + ';'
else:
print '\t{ PyObject *v = PyTuple_New(',
print n_out_args, ');'
@@ -374,15 +374,15 @@ def generate(type, func, database):
i_out = 0
if type <> 'void':
print '\t PyTuple_SetItem(v,',
- print `i_out` + ',',
+ print repr(i_out) + ',',
print mkobject(type, 'retval') + ');'
i_out = i_out + 1
for i in range(len(database)):
a_type, a_mode, a_factor, a_sub = database[i]
if a_mode == 'r':
print '\t PyTuple_SetItem(v,',
- print `i_out` + ',',
- s = mkobject(a_type, 'arg' + `i+1`)
+ print repr(i_out) + ',',
+ s = mkobject(a_type, 'arg' + repr(i+1))
print s + ');'
i_out = i_out + 1
print '\t return v;'
diff --git a/Tools/bgen/bgen/scantools.py b/Tools/bgen/bgen/scantools.py
index b9b68543ec..4afd7c8927 100644
--- a/Tools/bgen/bgen/scantools.py
+++ b/Tools/bgen/bgen/scantools.py
@@ -151,7 +151,7 @@ if missing: raise "Missing Types"
"""
f = self.openrepairfile()
if not f: return []
- print "Reading repair file", `f.name`, "..."
+ print "Reading repair file", repr(f.name), "..."
list = []
lineno = 0
while 1:
@@ -169,14 +169,14 @@ if missing: raise "Missing Types"
if len(words) <> 3:
print "Line", startlineno,
print ": bad line (not 3 colon-separated fields)"
- print `line`
+ print repr(line)
continue
[fpat, pat, rep] = words
if not fpat: fpat = "*"
if not pat:
print "Line", startlineno,
print "Empty pattern"
- print `line`
+ print repr(line)
continue
patparts = [s.strip() for s in pat.split(',')]
repparts = [s.strip() for s in rep.split(',')]
@@ -185,13 +185,13 @@ if missing: raise "Missing Types"
if not p:
print "Line", startlineno,
print "Empty pattern part"
- print `line`
+ print repr(line)
continue
pattern = p.split()
if len(pattern) > 3:
print "Line", startlineno,
print "Pattern part has > 3 words"
- print `line`
+ print repr(line)
pattern = pattern[:3]
else:
while len(pattern) < 3:
@@ -202,13 +202,13 @@ if missing: raise "Missing Types"
if not p:
print "Line", startlineno,
print "Empty replacement part"
- print `line`
+ print repr(line)
continue
replacement = p.split()
if len(replacement) > 3:
print "Line", startlineno,
print "Pattern part has > 3 words"
- print `line`
+ print repr(line)
replacement = replacement[:3]
else:
while len(replacement) < 3:
@@ -224,7 +224,7 @@ if missing: raise "Missing Types"
try:
return open(filename, "rU")
except IOError, msg:
- print `filename`, ":", msg
+ print repr(filename), ":", msg
print "Cannot open repair file -- assume no repair needed"
return None
@@ -360,7 +360,7 @@ if missing: raise "Missing Types"
if not os.path.isabs(filename):
for dir in self.includepath:
fullname = os.path.join(dir, filename)
- #self.report("trying full name %s", `fullname`)
+ #self.report("trying full name %r", fullname)
try:
return open(fullname, 'rU')
except IOError:
@@ -387,17 +387,17 @@ if missing: raise "Missing Types"
self.error("No input file has been specified")
return
inputname = self.scanfile.name
- self.report("scanfile = %s", `inputname`)
+ self.report("scanfile = %r", inputname)
if not self.specfile:
self.report("(No interface specifications will be written)")
else:
- self.report("specfile = %s", `self.specfile.name`)
- self.specfile.write("# Generated from %s\n\n" % `inputname`)
+ self.report("specfile = %r", self.specfile.name)
+ self.specfile.write("# Generated from %r\n\n" % (inputname,))
if not self.defsfile:
self.report("(No symbol definitions will be written)")
else:
- self.report("defsfile = %s", `self.defsfile.name`)
- self.defsfile.write("# Generated from %s\n\n" % `os.path.split(inputname)[1]`)
+ self.report("defsfile = %r", (self.defsfile.name,))
+ self.defsfile.write("# Generated from %r\n\n" % (os.path.split(inputname)[1],))
self.writeinitialdefs()
self.alreadydone = []
try:
@@ -405,17 +405,17 @@ if missing: raise "Missing Types"
try: line = self.getline()
except EOFError: break
if self.debug:
- self.report("LINE: %s" % `line`)
+ self.report("LINE: %r" % (line,))
match = self.comment1.match(line)
if match:
line = match.group('rest')
if self.debug:
- self.report("\tafter comment1: %s" % `line`)
+ self.report("\tafter comment1: %r" % (line,))
match = self.comment2.match(line)
while match:
line = match.group('rest1')+match.group('rest2')
if self.debug:
- self.report("\tafter comment2: %s" % `line`)
+ self.report("\tafter comment2: %r" % (line,))
match = self.comment2.match(line)
if self.defsfile:
match = self.sym.match(line)
@@ -438,7 +438,7 @@ if missing: raise "Missing Types"
name, defn = match.group('name', 'defn')
defn = escape8bit(defn)
if self.debug:
- self.report("\tsym: name=%s, defn=%s" % (`name`, `defn`))
+ self.report("\tsym: name=%r, defn=%r" % (name, defn))
if not name in self.blacklistnames:
self.defsfile.write("%s = %s\n" % (name, defn))
else:
@@ -450,27 +450,27 @@ if missing: raise "Missing Types"
while not self.tail.search(raw):
line = self.getline()
if self.debug:
- self.report("* CONTINUATION LINE: %s" % `line`)
+ self.report("* CONTINUATION LINE: %r" % (line,))
match = self.comment1.match(line)
if match:
line = match.group('rest')
if self.debug:
- self.report("\tafter comment1: %s" % `line`)
+ self.report("\tafter comment1: %r" % (line,))
match = self.comment2.match(line)
while match:
line = match.group('rest1')+match.group('rest2')
if self.debug:
- self.report("\tafter comment1: %s" % `line`)
+ self.report("\tafter comment1: %r" % (line,))
match = self.comment2.match(line)
raw = raw + line
if self.debug:
- self.report("* WHOLE LINE: %s" % `raw`)
+ self.report("* WHOLE LINE: %r" % (raw,))
self.processrawspec(raw)
def processrawspec(self, raw):
match = self.whole.search(raw)
if not match:
- self.report("Bad raw spec: %s", `raw`)
+ self.report("Bad raw spec: %r", raw)
if self.debug:
if not self.type.search(raw):
self.report("(Type already doesn't match)")
@@ -481,7 +481,7 @@ if missing: raise "Missing Types"
type = re.sub("\*", " ptr", type)
type = re.sub("[ \t]+", "_", type)
if name in self.alreadydone:
- self.report("Name has already been defined: %s", `name`)
+ self.report("Name has already been defined: %r", name)
return
self.report("==> %s %s <==", type, name)
if self.blacklisted(type, name):
@@ -494,7 +494,7 @@ if missing: raise "Missing Types"
arglist = self.repairarglist(name, arglist)
if self.unmanageable(type, name, arglist):
##for arg in arglist:
- ## self.report(" %s", `arg`)
+ ## self.report(" %r", arg)
self.report("*** %s %s unmanageable", type, name)
return
self.alreadydone.append(name)
@@ -516,7 +516,7 @@ if missing: raise "Missing Types"
part = part.strip()
match = self.asplit.match(part)
if not match:
- self.error("Indecipherable argument: %s", `part`)
+ self.error("Indecipherable argument: %r", part)
return ("unknown", part, mode)
type, name, array = match.group('type', 'name', 'array')
if array:
@@ -583,21 +583,21 @@ if missing: raise "Missing Types"
index = int(item[i][1:]) - 1
newitem[i] = old[index][i]
new.append(tuple(newitem))
- ##self.report("old: %s", `old`)
- ##self.report("new: %s", `new`)
+ ##self.report("old: %r", old)
+ ##self.report("new: %r", new)
return new
def generate(self, type, name, arglist):
self.typeused(type, 'return')
classname, listname = self.destination(type, name, arglist)
if not self.specfile: return
- self.specfile.write("f = %s(%s, %s,\n" % (classname, type, `name`))
+ self.specfile.write("f = %s(%s, %r,\n" % (classname, type, name))
for atype, aname, amode in arglist:
self.typeused(atype, amode)
- self.specfile.write(" (%s, %s, %s),\n" %
- (atype, `aname`, amode))
+ self.specfile.write(" (%s, %r, %s),\n" %
+ (atype, aname, amode))
if self.greydictnames.has_key(name):
- self.specfile.write(" condition=%s,\n"%`self.greydictnames[name]`)
+ self.specfile.write(" condition=%r,\n"%(self.greydictnames[name],))
self.specfile.write(")\n")
self.specfile.write("%s.append(f)\n\n" % listname)
diff --git a/Tools/compiler/compile.py b/Tools/compiler/compile.py
index c90d8510f4..c1483c5905 100644
--- a/Tools/compiler/compile.py
+++ b/Tools/compiler/compile.py
@@ -35,8 +35,7 @@ def main():
print filename
try:
if PROFILE:
- profile.run('compileFile(%s, %s)' % (`filename`,
- `DISPLAY`),
+ profile.run('compileFile(%r, %r)' % (filename, DISPLAY),
filename + ".prof")
else:
compileFile(filename, DISPLAY)
diff --git a/Tools/faqwiz/faqwiz.py b/Tools/faqwiz/faqwiz.py
index e91d4dce87..a44da12e86 100644
--- a/Tools/faqwiz/faqwiz.py
+++ b/Tools/faqwiz/faqwiz.py
@@ -383,7 +383,7 @@ class FaqWizard:
try:
meth = getattr(self, mname)
except AttributeError:
- self.error("Bad request type %s." % `req`)
+ self.error("Bad request type %r." % (req,))
else:
try:
meth()
@@ -664,7 +664,7 @@ class FaqWizard:
rev = self.ui.rev
mami = revparse(rev)
if not mami:
- self.error("Invalid revision number: %s." % `rev`)
+ self.error("Invalid revision number: %r." % (rev,))
self.prologue(T_REVISION, entry)
self.shell(interpolate(SH_REVISION, entry, rev=rev))
@@ -674,10 +674,10 @@ class FaqWizard:
rev = self.ui.rev
mami = revparse(rev)
if not mami:
- self.error("Invalid revision number: %s." % `rev`)
+ self.error("Invalid revision number: %r." % (rev,))
if prev:
if not revparse(prev):
- self.error("Invalid previous revision number: %s." % `prev`)
+ self.error("Invalid previous revision number: %r." % (prev,))
else:
prev = '%d.%d' % (mami[0], mami[1])
self.prologue(T_DIFF, entry)
diff --git a/Tools/freeze/makefreeze.py b/Tools/freeze/makefreeze.py
index 29a6ad6d8d..9ff348c59a 100644
--- a/Tools/freeze/makefreeze.py
+++ b/Tools/freeze/makefreeze.py
@@ -87,4 +87,4 @@ def writecode(outfp, mod, str):
## def writecode(outfp, mod, str):
## outfp.write('unsigned char M_%s[%d] = "%s";\n' % (mod, len(str),
-## '\\"'.join(map(lambda s: `s`[1:-1], str.split('"')))))
+## '\\"'.join(map(lambda s: repr(s)[1:-1], str.split('"')))))
diff --git a/Tools/freeze/winmakemakefile.py b/Tools/freeze/winmakemakefile.py
index 763e8205c5..8570f3d5cc 100644
--- a/Tools/freeze/winmakemakefile.py
+++ b/Tools/freeze/winmakemakefile.py
@@ -51,7 +51,7 @@ def makemakefile(outfp, vars, files, target):
sys.stdout = save
def realwork(vars, moddefns, target):
- version_suffix = `sys.version_info[0]`+`sys.version_info[1]`
+ version_suffix = "%r%r" % sys.version_info[:2]
print "# Makefile for Microsoft Visual C++ generated by freeze.py script"
print
print 'target = %s' % target
diff --git a/Tools/modulator/modulator.py b/Tools/modulator/modulator.py
index df6d9efc3d..48287431b0 100755
--- a/Tools/modulator/modulator.py
+++ b/Tools/modulator/modulator.py
@@ -216,15 +216,15 @@ class UI_module:
o.synchronize()
onames = []
for i in range(len(objects)):
- oname = 'o'+`i+1`
+ oname = 'o%d' % (i+1)
rv = rv + objects[i].gencode(oname)
onames.append(oname)
- rv = rv + (name+' = genmodule.module()\n')
- rv = rv + (name+'.name = '+`self.name_entry.get()`+'\n')
- rv = rv + (name+'.abbrev = '+`self.abbrev_entry.get()`+'\n')
- rv = rv + (name+'.methodlist = '+`getlistlist(self.method_list)`+'\n')
- rv = rv + (name+'.objects = ['+','.join(onames)+']\n')
- rv = rv + ('\n')
+ rv = rv + '%s = genmodule.module()\n' % (name,)
+ rv = rv + '%s.name = %r\n' % (name, self.name_entry.get())
+ rv = rv + '%s.abbrev = %r\n' % (name, self.abbrev_entry.get())
+ rv = rv + '%s.methodlist = %r\n' % (name, getlistlist(self.method_list))
+ rv = rv + '%s.objects = [%s]\n' % (name, ','.join(onames))
+ rv = rv + '\n'
return rv
object_number = 0
@@ -235,7 +235,7 @@ class UI_object:
object_number = object_number + 1
self.num = object_number
- self.vpref = 'o'+`self.num`+'_'
+ self.vpref = 'o%r_' % self.num
self.frame = Toplevel(parent.objframe)
# self.frame.pack()
self.frame.title('Modulator: object view')
@@ -340,16 +340,16 @@ class UI_object:
def gencode(self, name):
rv = ''
- rv = rv + (name+' = genmodule.object()\n')
- rv = rv + (name+'.name = '+`self.name_entry.get()`+'\n')
- rv = rv + (name+'.abbrev = '+`self.abbrev_entry.get()`+'\n')
- rv = rv + (name+'.methodlist = '+`getlistlist(self.method_list)`+'\n')
+ rv = rv + '%s = genmodule.object()\n' % (name,)
+ rv = rv + '%s.name = %r\n' % (name, self.name_entry.get())
+ rv = rv + '%s.abbrev = %r\n' % (name, self.abbrev_entry.get())
+ rv = rv + '%s.methodlist = %r\n' % (name, getlistlist(self.method_list))
fl = []
for fn in genmodule.FUNCLIST:
vname = self.vpref + fn
if self.f5.getvar(vname) == '1':
fl.append(fn)
- rv = rv + (name+'.funclist = '+`fl`+'\n')
+ rv = rv + '%s.funclist = %r\n' % (name, fl)
fl = []
for fn in genmodule.TYPELIST:
@@ -357,9 +357,9 @@ class UI_object:
if self.f5.getvar(vname) == '1':
fl.append(fn)
- rv = rv + (name+'.typelist = '+`fl`+'\n')
+ rv = rv + '%s.typelist = %r\n' % (name, fl)
- rv = rv + ('\n')
+ rv = rv + '\n'
return rv
diff --git a/Tools/scripts/byteyears.py b/Tools/scripts/byteyears.py
index 9c2a974643..b2a114fc93 100755
--- a/Tools/scripts/byteyears.py
+++ b/Tools/scripts/byteyears.py
@@ -42,7 +42,7 @@ for filename in sys.argv[1:]:
try:
st = statfunc(filename)
except os.error, msg:
- sys.stderr.write('can\'t stat ' + `filename` + ': ' + `msg` + '\n')
+ sys.stderr.write("can't stat %r: %r\n" % (filename, msg))
status = 1
st = ()
if st:
diff --git a/Tools/scripts/checkappend.py b/Tools/scripts/checkappend.py
index b3141dfd10..a8714d9368 100755
--- a/Tools/scripts/checkappend.py
+++ b/Tools/scripts/checkappend.py
@@ -65,7 +65,7 @@ def main():
def check(file):
if os.path.isdir(file) and not os.path.islink(file):
if verbose:
- print "%s: listing directory" % `file`
+ print "%r: listing directory" % (file,)
names = os.listdir(file)
for name in names:
fullname = os.path.join(file, name)
@@ -78,15 +78,15 @@ def check(file):
try:
f = open(file)
except IOError, msg:
- errprint("%s: I/O Error: %s" % (`file`, str(msg)))
+ errprint("%r: I/O Error: %s" % (file, msg))
return
if verbose > 1:
- print "checking", `file`, "..."
+ print "checking %r ..." % (file,)
ok = AppendChecker(file, f).run()
if verbose and ok:
- print "%s: Clean bill of health." % `file`
+ print "%r: Clean bill of health." % (file,)
[FIND_DOT,
FIND_APPEND,
@@ -105,7 +105,7 @@ class AppendChecker:
try:
tokenize.tokenize(self.file.readline, self.tokeneater)
except tokenize.TokenError, msg:
- errprint("%s: Token Error: %s" % (`self.fname`, str(msg)))
+ errprint("%r: Token Error: %s" % (self.fname, msg))
self.nerrors = self.nerrors + 1
return self.nerrors == 0
@@ -159,7 +159,7 @@ class AppendChecker:
state = FIND_DOT
else:
- raise SystemError("unknown internal state '%s'" % `state`)
+ raise SystemError("unknown internal state '%r'" % (state,))
self.state = state
diff --git a/Tools/scripts/checkpyc.py b/Tools/scripts/checkpyc.py
index b38b456a89..d5f3c7a9cf 100755
--- a/Tools/scripts/checkpyc.py
+++ b/Tools/scripts/checkpyc.py
@@ -17,15 +17,15 @@ def main():
silent = 1
MAGIC = imp.get_magic()
if not silent:
- print 'Using MAGIC word', `MAGIC`
+ print 'Using MAGIC word', repr(MAGIC)
for dirname in sys.path:
try:
names = os.listdir(dirname)
except os.error:
- print 'Cannot list directory', `dirname`
+ print 'Cannot list directory', repr(dirname)
continue
if not silent:
- print 'Checking', `dirname`, '...'
+ print 'Checking ', repr(dirname), '...'
names.sort()
for name in names:
if name[-3:] == '.py':
@@ -33,29 +33,29 @@ def main():
try:
st = os.stat(name)
except os.error:
- print 'Cannot stat', `name`
+ print 'Cannot stat', repr(name)
continue
if verbose:
- print 'Check', `name`, '...'
+ print 'Check', repr(name), '...'
name_c = name + 'c'
try:
f = open(name_c, 'r')
except IOError:
- print 'Cannot open', `name_c`
+ print 'Cannot open', repr(name_c)
continue
magic_str = f.read(4)
mtime_str = f.read(4)
f.close()
if magic_str <> MAGIC:
print 'Bad MAGIC word in ".pyc" file',
- print `name_c`
+ print repr(name_c)
continue
mtime = get_long(mtime_str)
if mtime == 0 or mtime == -1:
- print 'Bad ".pyc" file', `name_c`
+ print 'Bad ".pyc" file', repr(name_c)
elif mtime <> st[ST_MTIME]:
print 'Out-of-date ".pyc" file',
- print `name_c`
+ print repr(name_c)
def get_long(s):
if len(s) <> 4:
diff --git a/Tools/scripts/classfix.py b/Tools/scripts/classfix.py
index 7b86aa3953..520b352965 100755
--- a/Tools/scripts/classfix.py
+++ b/Tools/scripts/classfix.py
@@ -58,12 +58,12 @@ def ispython(name):
return ispythonprog.match(name) >= 0
def recursedown(dirname):
- dbg('recursedown(' + `dirname` + ')\n')
+ dbg('recursedown(%r)\n' % (dirname,))
bad = 0
try:
names = os.listdir(dirname)
except os.error, msg:
- err(dirname + ': cannot list directory: ' + `msg` + '\n')
+ err('%s: cannot list directory: %r\n' % (dirname, msg))
return 1
names.sort()
subdirs = []
@@ -80,11 +80,11 @@ def recursedown(dirname):
return bad
def fix(filename):
-## dbg('fix(' + `filename` + ')\n')
+## dbg('fix(%r)\n' % (filename,))
try:
f = open(filename, 'r')
except IOError, msg:
- err(filename + ': cannot open: ' + `msg` + '\n')
+ err('%s: cannot open: %r\n' % (filename, msg))
return 1
head, tail = os.path.split(filename)
tempname = os.path.join(head, '@' + tail)
@@ -108,14 +108,13 @@ def fix(filename):
g = open(tempname, 'w')
except IOError, msg:
f.close()
- err(tempname+': cannot create: '+\
- `msg`+'\n')
+ err('%s: cannot create: %r\n' % (tempname, msg))
return 1
f.seek(0)
lineno = 0
rep(filename + ':\n')
continue # restart from the beginning
- rep(`lineno` + '\n')
+ rep(repr(lineno) + '\n')
rep('< ' + line)
rep('> ' + newline)
if g is not None:
@@ -132,17 +131,17 @@ def fix(filename):
statbuf = os.stat(filename)
os.chmod(tempname, statbuf[ST_MODE] & 07777)
except os.error, msg:
- err(tempname + ': warning: chmod failed (' + `msg` + ')\n')
+ err('%s: warning: chmod failed (%r)\n' % (tempname, msg))
# Then make a backup of the original file as filename~
try:
os.rename(filename, filename + '~')
except os.error, msg:
- err(filename + ': warning: backup failed (' + `msg` + ')\n')
+ err('%s: warning: backup failed (%r)\n' % (filename, msg))
# Now move the temp file to the original file
try:
os.rename(tempname, filename)
except os.error, msg:
- err(filename + ': rename failed (' + `msg` + ')\n')
+ err('%s: rename failed (%r)\n' % (filename, msg))
return 1
# Return succes
return 0
diff --git a/Tools/scripts/dutree.py b/Tools/scripts/dutree.py
index 857a5cc4fc..a49d80a396 100755
--- a/Tools/scripts/dutree.py
+++ b/Tools/scripts/dutree.py
@@ -46,7 +46,7 @@ def show(total, d, prefix):
## list.append((total - sum, os.curdir))
list.sort()
list.reverse()
- width = len(`list[0][0]`)
+ width = len(repr(list[0][0]))
for tsub, key in list:
if tsub is None:
psub = prefix
diff --git a/Tools/scripts/fixcid.py b/Tools/scripts/fixcid.py
index 8bc1de0dcb..76841febd0 100755
--- a/Tools/scripts/fixcid.py
+++ b/Tools/scripts/fixcid.py
@@ -93,7 +93,7 @@ def wanted(name):
return regex.match(Wanted, name) >= 0
def recursedown(dirname):
- dbg('recursedown(' + `dirname` + ')\n')
+ dbg('recursedown(%r)\n' % (dirname,))
bad = 0
try:
names = os.listdir(dirname)
@@ -115,7 +115,7 @@ def recursedown(dirname):
return bad
def fix(filename):
-## dbg('fix(' + `filename` + ')\n')
+## dbg('fix(%r)\n' % (filename,))
if filename == '-':
# Filter mode
f = sys.stdin
@@ -158,7 +158,7 @@ def fix(filename):
initfixline()
rep(filename + ':\n')
continue # restart from the beginning
- rep(`lineno` + '\n')
+ rep(repr(lineno) + '\n')
rep('< ' + line)
rep('> ' + newline)
if g is not None:
@@ -225,7 +225,7 @@ def initfixline():
def fixline(line):
global Program
-## print '-->', `line`
+## print '-->', repr(line)
i = 0
while i < len(line):
i = Program.search(line, i)
@@ -293,8 +293,7 @@ def addsubst(substfile):
if len(words) == 3 and words[0] == 'struct':
words[:2] = [words[0] + ' ' + words[1]]
elif len(words) <> 2:
- err(substfile + ':' + `lineno` +
- ': warning: bad line: ' + line)
+ err(substfile + '%s:%r: warning: bad line: %r' % (substfile, lineno, line))
continue
if Reverse:
[value, key] = words
@@ -306,11 +305,8 @@ def addsubst(substfile):
key = key[1:]
NotInComment[key] = value
if Dict.has_key(key):
- err(substfile + ':' + `lineno` +
- ': warning: overriding: ' +
- key + ' ' + value + '\n')
- err(substfile + ':' + `lineno` +
- ': warning: previous: ' + Dict[key] + '\n')
+ err('%s:%r: warning: overriding: %r %r\n' % (substfile, lineno, key, value))
+ err('%s:%r: warning: previous: %r\n' % (substfile, lineno, Dict[key]))
Dict[key] = value
fp.close()
diff --git a/Tools/scripts/fixps.py b/Tools/scripts/fixps.py
index e406571e72..12e9f4362b 100755
--- a/Tools/scripts/fixps.py
+++ b/Tools/scripts/fixps.py
@@ -23,7 +23,7 @@ def main():
f.close()
line = re.sub('/usr/local/bin/python',
'/usr/bin/env python', line)
- print filename, ':', `line`
+ print filename, ':', repr(line)
f = open(filename, "w")
f.write(line)
f.write(rest)
diff --git a/Tools/scripts/ftpmirror.py b/Tools/scripts/ftpmirror.py
index 41607b0b7e..0f918b8845 100755
--- a/Tools/scripts/ftpmirror.py
+++ b/Tools/scripts/ftpmirror.py
@@ -87,17 +87,17 @@ def main():
f.connect(host,port)
if not nologin:
if verbose:
- print 'Logging in as %s...' % `login or 'anonymous'`
+ print 'Logging in as %r...' % (login or 'anonymous')
f.login(login, passwd, account)
if verbose: print 'OK.'
pwd = f.pwd()
- if verbose > 1: print 'PWD =', `pwd`
+ if verbose > 1: print 'PWD =', repr(pwd)
if remotedir:
- if verbose > 1: print 'cwd(%s)' % `remotedir`
+ if verbose > 1: print 'cwd(%s)' % repr(remotedir)
f.cwd(remotedir)
if verbose > 1: print 'OK.'
pwd = f.pwd()
- if verbose > 1: print 'PWD =', `pwd`
+ if verbose > 1: print 'PWD =', repr(pwd)
#
mirrorsubdir(f, localdir)
@@ -105,11 +105,11 @@ def main():
def mirrorsubdir(f, localdir):
pwd = f.pwd()
if localdir and not os.path.isdir(localdir):
- if verbose: print 'Creating local directory', `localdir`
+ if verbose: print 'Creating local directory', repr(localdir)
try:
makedir(localdir)
except os.error, msg:
- print "Failed to establish local directory", `localdir`
+ print "Failed to establish local directory", repr(localdir)
return
infofilename = os.path.join(localdir, '.mirrorinfo')
try:
@@ -119,15 +119,15 @@ def mirrorsubdir(f, localdir):
try:
info = eval(text)
except (SyntaxError, NameError):
- print 'Bad mirror info in %s' % `infofilename`
+ print 'Bad mirror info in', repr(infofilename)
info = {}
subdirs = []
listing = []
- if verbose: print 'Listing remote directory %s...' % `pwd`
+ if verbose: print 'Listing remote directory %r...' % (pwd,)
f.retrlines('LIST', listing.append)
filesfound = []
for line in listing:
- if verbose > 1: print '-->', `line`
+ if verbose > 1: print '-->', repr(line)
if mac:
# Mac listing has just filenames;
# trailing / means subdirectory
@@ -148,7 +148,7 @@ def mirrorsubdir(f, localdir):
if i >= 0:
# words[0] had better start with 'l'...
if verbose > 1:
- print 'Found symbolic link %s' % `filename`
+ print 'Found symbolic link %r' % (filename,)
linkto = filename[i+4:]
filename = filename[:i]
infostuff = words[-5:-1]
@@ -157,21 +157,21 @@ def mirrorsubdir(f, localdir):
for pat in skippats:
if fnmatch(filename, pat):
if verbose > 1:
- print 'Skip pattern', `pat`,
- print 'matches', `filename`
+ print 'Skip pattern', repr(pat),
+ print 'matches', repr(filename)
skip = 1
break
if skip:
continue
if mode[0] == 'd':
if verbose > 1:
- print 'Remembering subdirectory', `filename`
+ print 'Remembering subdirectory', repr(filename)
subdirs.append(filename)
continue
filesfound.append(filename)
if info.has_key(filename) and info[filename] == infostuff:
if verbose > 1:
- print 'Already have this version of',`filename`
+ print 'Already have this version of',repr(filename)
continue
fullname = os.path.join(localdir, filename)
tempname = os.path.join(localdir, '@'+filename)
@@ -187,24 +187,20 @@ def mirrorsubdir(f, localdir):
pass
if mode[0] == 'l':
if verbose:
- print "Creating symlink %s -> %s" % (
- `filename`, `linkto`)
+ print "Creating symlink %r -> %r" % (filename, linkto)
try:
os.symlink(linkto, tempname)
except IOError, msg:
- print "Can't create %s: %s" % (
- `tempname`, str(msg))
+ print "Can't create %r: %s" % (tempname, msg)
continue
else:
try:
fp = open(tempname, 'wb')
except IOError, msg:
- print "Can't create %s: %s" % (
- `tempname`, str(msg))
+ print "Can't create %r: %s" % (tempname, msg)
continue
if verbose:
- print 'Retrieving %s from %s as %s...' % \
- (`filename`, `pwd`, `fullname`)
+ print 'Retrieving %r from %r as %r...' % (filename, pwd, fullname)
if verbose:
fp1 = LoggingFile(fp, 1024, sys.stdout)
else:
@@ -227,9 +223,7 @@ def mirrorsubdir(f, localdir):
try:
os.rename(tempname, fullname)
except os.error, msg:
- print "Can't rename %s to %s: %s" % (`tempname`,
- `fullname`,
- str(msg))
+ print "Can't rename %r to %r: %s" % (tempname, fullname, msg)
continue
info[filename] = infostuff
writedict(info, infofilename)
@@ -251,7 +245,7 @@ def mirrorsubdir(f, localdir):
if filename not in filesfound:
if verbose:
print "Removing obsolete info entry for",
- print `filename`, "in", `localdir or "."`
+ print repr(filename), "in", repr(localdir or ".")
del info[filename]
deletions = deletions + 1
if deletions:
@@ -270,8 +264,8 @@ def mirrorsubdir(f, localdir):
for pat in skippats:
if fnmatch(name, pat):
if verbose > 1:
- print 'Skip pattern', `pat`,
- print 'matches', `name`
+ print 'Skip pattern', repr(pat),
+ print 'matches', repr(name)
skip = 1
break
if skip:
@@ -279,10 +273,10 @@ def mirrorsubdir(f, localdir):
fullname = os.path.join(localdir, name)
if not rmok:
if verbose:
- print 'Local file', `fullname`,
+ print 'Local file', repr(fullname),
print 'is no longer pertinent'
continue
- if verbose: print 'Removing local file/dir', `fullname`
+ if verbose: print 'Removing local file/dir', repr(fullname)
remove(fullname)
#
# Recursively mirror subdirectories
@@ -290,18 +284,18 @@ def mirrorsubdir(f, localdir):
if interactive:
doit = askabout('subdirectory', subdir, pwd)
if not doit: continue
- if verbose: print 'Processing subdirectory', `subdir`
+ if verbose: print 'Processing subdirectory', repr(subdir)
localsubdir = os.path.join(localdir, subdir)
pwd = f.pwd()
if verbose > 1:
- print 'Remote directory now:', `pwd`
- print 'Remote cwd', `subdir`
+ print 'Remote directory now:', repr(pwd)
+ print 'Remote cwd', repr(subdir)
try:
f.cwd(subdir)
except ftplib.error_perm, msg:
- print "Can't chdir to", `subdir`, ":", `msg`
+ print "Can't chdir to", repr(subdir), ":", repr(msg)
else:
- if verbose: print 'Mirroring as', `localsubdir`
+ if verbose: print 'Mirroring as', repr(localsubdir)
mirrorsubdir(f, localsubdir)
if verbose > 1: print 'Remote cwd ..'
f.cwd('..')
@@ -329,15 +323,13 @@ def remove(fullname):
try:
os.rmdir(fullname)
except os.error, msg:
- print "Can't remove local directory %s: %s" % \
- (`fullname`, str(msg))
+ print "Can't remove local directory %r: %s" % (fullname, msg)
return 0
else:
try:
os.unlink(fullname)
except os.error, msg:
- print "Can't remove local file %s: %s" % \
- (`fullname`, str(msg))
+ print "Can't remove local file %r: %s" % (fullname, msg)
return 0
return 1
@@ -394,7 +386,7 @@ def writedict(dict, filename):
fp = open(tempname, 'w')
fp.write('{\n')
for key, value in dict.items():
- fp.write('%s: %s,\n' % (`key`, `value`))
+ fp.write('%r: %r,\n' % (key, value))
fp.write('}\n')
fp.close()
try:
diff --git a/Tools/scripts/methfix.py b/Tools/scripts/methfix.py
index 9e69961be3..9200d265a0 100755
--- a/Tools/scripts/methfix.py
+++ b/Tools/scripts/methfix.py
@@ -55,12 +55,12 @@ def ispython(name):
return ispythonprog.match(name) >= 0
def recursedown(dirname):
- dbg('recursedown(' + `dirname` + ')\n')
+ dbg('recursedown(%r)\n' % (dirname,))
bad = 0
try:
names = os.listdir(dirname)
except os.error, msg:
- err(dirname + ': cannot list directory: ' + `msg` + '\n')
+ err('%s: cannot list directory: %r\n' % (dirname, msg))
return 1
names.sort()
subdirs = []
@@ -77,11 +77,11 @@ def recursedown(dirname):
return bad
def fix(filename):
-## dbg('fix(' + `filename` + ')\n')
+## dbg('fix(%r)\n' % (filename,))
try:
f = open(filename, 'r')
except IOError, msg:
- err(filename + ': cannot open: ' + `msg` + '\n')
+ err('%s: cannot open: %r\n' % (filename, msg))
return 1
head, tail = os.path.split(filename)
tempname = os.path.join(head, '@' + tail)
@@ -119,14 +119,13 @@ def fix(filename):
g = open(tempname, 'w')
except IOError, msg:
f.close()
- err(tempname+': cannot create: '+\
- `msg`+'\n')
+ err('%s: cannot create: %r\n' % (tempname, msg))
return 1
f.seek(0)
lineno = 0
rep(filename + ':\n')
continue # restart from the beginning
- rep(`lineno` + '\n')
+ rep(repr(lineno) + '\n')
rep('< ' + line)
rep('> ' + newline)
if g is not None:
@@ -143,17 +142,17 @@ def fix(filename):
statbuf = os.stat(filename)
os.chmod(tempname, statbuf[ST_MODE] & 07777)
except os.error, msg:
- err(tempname + ': warning: chmod failed (' + `msg` + ')\n')
+ err('%s: warning: chmod failed (%r)\n' % (tempname, msg))
# Then make a backup of the original file as filename~
try:
os.rename(filename, filename + '~')
except os.error, msg:
- err(filename + ': warning: backup failed (' + `msg` + ')\n')
+ err('%s: warning: backup failed (%r)\n' % (filename, msg))
# Now move the temp file to the original file
try:
os.rename(tempname, filename)
except os.error, msg:
- err(filename + ': rename failed (' + `msg` + ')\n')
+ err('%s: rename failed (%r)\n' % (filename, msg))
return 1
# Return succes
return 0
diff --git a/Tools/scripts/pathfix.py b/Tools/scripts/pathfix.py
index 81c5a6ecbf..47ae4649b5 100755
--- a/Tools/scripts/pathfix.py
+++ b/Tools/scripts/pathfix.py
@@ -64,12 +64,12 @@ def ispython(name):
return ispythonprog.match(name) >= 0
def recursedown(dirname):
- dbg('recursedown(' + `dirname` + ')\n')
+ dbg('recursedown(%r)\n' % (dirname,))
bad = 0
try:
names = os.listdir(dirname)
except os.error, msg:
- err(dirname + ': cannot list directory: ' + `msg` + '\n')
+ err('%s: cannot list directory: %r\n' % (dirname, msg))
return 1
names.sort()
subdirs = []
@@ -86,11 +86,11 @@ def recursedown(dirname):
return bad
def fix(filename):
-## dbg('fix(' + `filename` + ')\n')
+## dbg('fix(%r)\n' % (filename,))
try:
f = open(filename, 'r')
except IOError, msg:
- err(filename + ': cannot open: ' + `msg` + '\n')
+ err('%s: cannot open: %r\n' % (filename, msg))
return 1
line = f.readline()
fixed = fixline(line)
@@ -104,7 +104,7 @@ def fix(filename):
g = open(tempname, 'w')
except IOError, msg:
f.close()
- err(tempname+': cannot create: '+`msg`+'\n')
+ err('%s: cannot create: %r\n' % (tempname, msg))
return 1
rep(filename + ': updating\n')
g.write(fixed)
@@ -123,17 +123,17 @@ def fix(filename):
statbuf = os.stat(filename)
os.chmod(tempname, statbuf[ST_MODE] & 07777)
except os.error, msg:
- err(tempname + ': warning: chmod failed (' + `msg` + ')\n')
+ err('%s: warning: chmod failed (%r)\n' % (tempname, msg))
# Then make a backup of the original file as filename~
try:
os.rename(filename, filename + '~')
except os.error, msg:
- err(filename + ': warning: backup failed (' + `msg` + ')\n')
+ err('%s: warning: backup failed (%r)\n' % (filename, msg))
# Now move the temp file to the original file
try:
os.rename(tempname, filename)
except os.error, msg:
- err(filename + ': rename failed (' + `msg` + ')\n')
+ err('%s: rename failed (%r)\n' % (filename, msg))
return 1
# Return succes
return 0
diff --git a/Tools/scripts/redemo.py b/Tools/scripts/redemo.py
index 1eed8f845c..de7f3c4a21 100644
--- a/Tools/scripts/redemo.py
+++ b/Tools/scripts/redemo.py
@@ -146,7 +146,7 @@ class ReDemo:
groups = list(m.groups())
groups.insert(0, m.group())
for i in range(len(groups)):
- g = "%2d: %s" % (i, `groups[i]`)
+ g = "%2d: %r" % (i, groups[i])
self.grouplist.insert(END, g)
nmatches = nmatches + 1
if self.showvar.get() == "first":
diff --git a/Tools/scripts/suff.py b/Tools/scripts/suff.py
index ee7499f5e4..dfb3da0b2f 100755
--- a/Tools/scripts/suff.py
+++ b/Tools/scripts/suff.py
@@ -17,7 +17,7 @@ def main():
keys = suffixes.keys()
keys.sort()
for suff in keys:
- print `suff`, len(suffixes[suff])
+ print repr(suff), len(suffixes[suff])
def getsuffix(filename):
suff = ''
diff --git a/Tools/scripts/texi2html.py b/Tools/scripts/texi2html.py
index b91a53d967..1d9a21ab4e 100755
--- a/Tools/scripts/texi2html.py
+++ b/Tools/scripts/texi2html.py
@@ -257,7 +257,7 @@ class TexinfoParser:
line = fp.readline()
lineno = lineno + 1
if line[:len(MAGIC)] <> MAGIC:
- raise SyntaxError, 'file does not begin with '+`MAGIC`
+ raise SyntaxError, 'file does not begin with %r' % (MAGIC,)
self.parserest(fp, lineno)
# Parse the contents of a file, not expecting a MAGIC header
@@ -475,7 +475,7 @@ class TexinfoParser:
continue
if c <> '@':
# Cannot happen unless spprog is changed
- raise RuntimeError, 'unexpected funny '+`c`
+ raise RuntimeError, 'unexpected funny %r' % c
start = i
while i < n and text[i] in string.ascii_letters: i = i+1
if i == start:
@@ -555,9 +555,9 @@ class TexinfoParser:
try:
fp = open(file, 'r')
except IOError, msg:
- print '*** Can\'t open include file', `file`
+ print '*** Can\'t open include file', repr(file)
return
- print '!'*self.debugging, '--> file', `file`
+ print '!'*self.debugging, '--> file', repr(file)
save_done = self.done
save_skip = self.skip
save_stack = self.stack
@@ -568,7 +568,7 @@ class TexinfoParser:
self.done = save_done
self.skip = save_skip
self.stack = save_stack
- print '!'*self.debugging, '<-- file', `file`
+ print '!'*self.debugging, '<-- file', repr(file)
# --- Special Insertions ---
@@ -806,7 +806,7 @@ class TexinfoParser:
# if self.savetext <> None:
# print '*** Recursive footnote -- expect weirdness'
id = len(self.footnotes) + 1
- self.write(self.FN_SOURCE_PATTERN % {'id': `id`})
+ self.write(self.FN_SOURCE_PATTERN % {'id': repr(id))
self.startsaving()
def close_footnote(self):
@@ -817,7 +817,7 @@ class TexinfoParser:
self.write(self.FN_HEADER)
for id, text in self.footnotes:
self.write(self.FN_TARGET_PATTERN
- % {'id': `id`, 'text': text})
+ % {'id': repr(id), 'text': text})
self.footnotes = []
def open_file(self): self.write('<CODE>')
@@ -1162,7 +1162,7 @@ class TexinfoParser:
self.numbering[level] = self.numbering[level] + 1
x = ''
for i in self.numbering:
- x = x + `i` + '.'
+ x = x + repr(i) + '.'
args = x + ' ' + args
self.contents.append((level, args, self.nodename))
self.write('<', type, '>')
@@ -1549,7 +1549,7 @@ class TexinfoParser:
if self.whichindex.has_key(name):
self.index(name, args)
else:
- print '*** No index named', `name`
+ print '*** No index named', repr(name)
def do_cindex(self, args): self.index('cp', args)
def do_findex(self, args): self.index('fn', args)
@@ -1585,7 +1585,7 @@ class TexinfoParser:
if self.whichindex.has_key(name):
self.prindex(name)
else:
- print '*** No index named', `name`
+ print '*** No index named', repr(name)
def prindex(self, name):
iscodeindex = (name not in self.noncodeindices)
diff --git a/Tools/scripts/untabify.py b/Tools/scripts/untabify.py
index 17e9166690..9bdf235b67 100755
--- a/Tools/scripts/untabify.py
+++ b/Tools/scripts/untabify.py
@@ -29,7 +29,7 @@ def process(filename, tabsize):
text = f.read()
f.close()
except IOError, msg:
- print "%s: I/O error: %s" % (`filename`, str(msg))
+ print "%r: I/O error: %s" % (filename, msg)
return
newtext = text.expandtabs(tabsize)
if newtext == text:
diff --git a/Tools/scripts/which.py b/Tools/scripts/which.py
index 218254677b..7b3d2e00ee 100755
--- a/Tools/scripts/which.py
+++ b/Tools/scripts/which.py
@@ -48,7 +48,7 @@ for prog in sys.argv[1:]:
msg(filename + ': not executable')
if longlist:
sts = os.system('ls ' + longlist + ' ' + filename)
- if sts: msg('"ls -l" exit status: ' + `sts`)
+ if sts: msg('"ls -l" exit status: ' + repr(sts))
if not ident:
msg(prog + ': not found')
sts = 1