mirror of
https://github.com/python/cpython.git
synced 2025-11-03 03:22:27 +00:00
parent
ecfeb7f095
commit
70a6b49821
246 changed files with 926 additions and 962 deletions
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,))
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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__':
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
||||
#----------------------------------------
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
19
Lib/cgi.py
19
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
|
||||
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
16
Lib/dis.py
16
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] + ')',
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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__':
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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():
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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."""
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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())
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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"))
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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:]
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
21
Lib/mhlib.py
21
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()')
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
16
Lib/pdb.py
16
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,))
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
10
Lib/pipes.py
10
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
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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():
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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():
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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 '-----------------------'
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
|||
10
Lib/pre.py
10
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)
|
||||
|
|
|
|||
|
|
@ -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,))
|
||||
|
|
|
|||
|
|
@ -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 = " "
|
||||
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
|
|
|||
12
Lib/repr.py
12
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:
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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__':
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue