Replace backticks with repr() or "%r"
From SF patch #852334.
diff --git a/Lib/bsddb/dbrecio.py b/Lib/bsddb/dbrecio.py
index 470fb41..22e382a 100644
--- a/Lib/bsddb/dbrecio.py
+++ b/Lib/bsddb/dbrecio.py
@@ -164,10 +164,10 @@
f.seek(len(lines[0]))
f.write(lines[1])
f.seek(0)
- print 'First line =', `f.readline()`
+ print 'First line =', repr(f.readline())
here = f.tell()
line = f.readline()
- print 'Second line =', `line`
+ print 'Second line =', repr(line)
f.seek(-len(line), 1)
line2 = f.read(len(line))
if line != line2:
diff --git a/Lib/bsddb/dbtables.py b/Lib/bsddb/dbtables.py
index 6edfd29..e1d2c43 100644
--- a/Lib/bsddb/dbtables.py
+++ b/Lib/bsddb/dbtables.py
@@ -206,7 +206,7 @@
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 @@
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 @@
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 @@
columns = self.tablecolumns[table]
for column in (columns + conditions.keys()):
if not self.__tablecolumns[table].count(column):
- raise TableDBError, "unknown column: "+`column`
+ raise TableDBError, "unknown column: %r" % (column,)
# keyed on rows that match so far, containings dicts keyed on
# column names containing the data for that row and column.
diff --git a/Lib/bsddb/test/test_associate.py b/Lib/bsddb/test/test_associate.py
index f810eb0..fc92c22 100644
--- a/Lib/bsddb/test/test_associate.py
+++ b/Lib/bsddb/test/test_associate.py
@@ -200,7 +200,7 @@
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 @@
def getGenre(self, priKey, priData):
assert type(priData) == type(())
if verbose:
- print 'getGenre key:', `priKey`, 'data:', `priData`
+ print 'getGenre key: %r data: %r' % (priKey, priData)
genre = priData[2]
if genre == 'Blues':
return db.DB_DONOTINDEX
diff --git a/Lib/bsddb/test/test_basics.py b/Lib/bsddb/test/test_basics.py
index d757b34..da7e18f 100644
--- a/Lib/bsddb/test/test_basics.py
+++ b/Lib/bsddb/test/test_basics.py
@@ -361,7 +361,7 @@
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 @@
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 @@
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 @@
num = d.truncate(txn)
assert num >= 1, "truncate returned <= 0 on non-empty database"
num = d.truncate(txn)
- assert num == 0, "truncate on empty DB returned nonzero (%s)" % `num`
+ assert num == 0, "truncate on empty DB returned nonzero (%r)" % (num,)
txn.commit()
#----------------------------------------
diff --git a/Lib/bsddb/test/test_dbtables.py b/Lib/bsddb/test/test_dbtables.py
index eb5758f..1128a5a 100644
--- a/Lib/bsddb/test/test_dbtables.py
+++ b/Lib/bsddb/test/test_dbtables.py
@@ -109,7 +109,7 @@
assert values[1]['Species'] == 'Penguin'
else :
if verbose:
- print "values=", `values`
+ print "values= %r" % (values,)
raise "Wrong values returned!"
def test03(self):