Replace backticks with repr() or "%r"

From SF patch #852334.
This commit is contained in:
Walter Dörwald 2004-02-12 17:35:32 +00:00
parent ecfeb7f095
commit 70a6b49821
246 changed files with 926 additions and 962 deletions

View file

@ -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

View file

@ -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

View file

@ -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()

View file

@ -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)