summaryrefslogtreecommitdiffstats
path: root/Lib/bsddb
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-01-10 16:19:56 (GMT)
committerGuido van Rossum <guido@python.org>2007-01-10 16:19:56 (GMT)
commitb940e113bf90ff71b0ef57414ea2beea9d2a4bc0 (patch)
tree0b9ea19eba1e665dac95126c3140ac2bc36326ad /Lib/bsddb
parent893523e80a2003d4a630aafb84ba016e0070cbbd (diff)
downloadcpython-b940e113bf90ff71b0ef57414ea2beea9d2a4bc0.zip
cpython-b940e113bf90ff71b0ef57414ea2beea9d2a4bc0.tar.gz
cpython-b940e113bf90ff71b0ef57414ea2beea9d2a4bc0.tar.bz2
SF patch 1631942 by Collin Winter:
(a) "except E, V" -> "except E as V" (b) V is now limited to a simple name (local variable) (c) V is now deleted at the end of the except block
Diffstat (limited to 'Lib/bsddb')
-rw-r--r--Lib/bsddb/dbtables.py20
-rw-r--r--Lib/bsddb/test/test_basics.py22
-rw-r--r--Lib/bsddb/test/test_compare.py2
-rw-r--r--Lib/bsddb/test/test_pickle.py4
-rw-r--r--Lib/bsddb/test/test_recno.py12
-rw-r--r--Lib/bsddb/test/test_thread.py10
6 files changed, 35 insertions, 35 deletions
diff --git a/Lib/bsddb/dbtables.py b/Lib/bsddb/dbtables.py
index 7f862d7..704c4d2 100644
--- a/Lib/bsddb/dbtables.py
+++ b/Lib/bsddb/dbtables.py
@@ -260,7 +260,7 @@ class bsdTableDB :
txn.commit()
txn = None
- except DBError, dberror:
+ except DBError as dberror:
if txn:
txn.abort()
raise TableDBError, dberror[1]
@@ -338,7 +338,7 @@ class bsdTableDB :
txn = None
self.__load_column_info(table)
- except DBError, dberror:
+ except DBError as dberror:
if txn:
txn.abort()
raise TableDBError, dberror[1]
@@ -407,7 +407,7 @@ class bsdTableDB :
txn.commit()
txn = None
- except DBError, dberror:
+ except DBError as dberror:
# WIBNI we could just abort the txn and re-raise the exception?
# But no, because TableDBError is not related to DBError via
# inheritance, so it would be backwards incompatible. Do the next
@@ -466,7 +466,7 @@ class bsdTableDB :
txn.abort()
raise
- except DBError, dberror:
+ except DBError as dberror:
raise TableDBError, dberror[1]
def Delete(self, table, conditions={}):
@@ -502,11 +502,11 @@ class bsdTableDB :
pass
txn.commit()
txn = None
- except DBError, dberror:
+ except DBError as dberror:
if txn:
txn.abort()
raise
- except DBError, dberror:
+ except DBError as dberror:
raise TableDBError, dberror[1]
@@ -526,7 +526,7 @@ class bsdTableDB :
if columns is None:
columns = self.__tablecolumns[table]
matching_rowids = self.__Select(table, columns, conditions)
- except DBError, dberror:
+ except DBError as dberror:
raise TableDBError, dberror[1]
# return the matches as a list of dictionaries
return matching_rowids.values()
@@ -616,7 +616,7 @@ class bsdTableDB :
key, data = cur.next()
- except DBError, dberror:
+ except DBError as dberror:
if dberror[0] != DB_NOTFOUND:
raise
continue
@@ -636,7 +636,7 @@ class bsdTableDB :
try:
rowdata[column] = self.db.get(
_data_key(table, column, rowid))
- except DBError, dberror:
+ except DBError as dberror:
if dberror[0] != DB_NOTFOUND:
raise
rowdata[column] = None
@@ -700,7 +700,7 @@ class bsdTableDB :
if table in self.__tablecolumns:
del self.__tablecolumns[table]
- except DBError, dberror:
+ except DBError as dberror:
if txn:
txn.abort()
raise TableDBError, dberror[1]
diff --git a/Lib/bsddb/test/test_basics.py b/Lib/bsddb/test/test_basics.py
index 48ecdb9..281e942 100644
--- a/Lib/bsddb/test/test_basics.py
+++ b/Lib/bsddb/test/test_basics.py
@@ -58,7 +58,7 @@ class BasicTestCase(unittest.TestCase):
self.homeDir = homeDir
try:
shutil.rmtree(homeDir)
- except OSError, e:
+ except OSError as e:
# unix returns ENOENT, windows returns ESRCH
if e.errno not in (errno.ENOENT, errno.ESRCH): raise
os.mkdir(homeDir)
@@ -162,7 +162,7 @@ class BasicTestCase(unittest.TestCase):
# set_get_returns_none() to change it.
try:
d.delete('abcd')
- except db.DBNotFoundError, val:
+ except db.DBNotFoundError as val:
assert val[0] == db.DB_NOTFOUND
if verbose: print val
else:
@@ -181,7 +181,7 @@ class BasicTestCase(unittest.TestCase):
try:
d.put('abcd', 'this should fail', flags=db.DB_NOOVERWRITE)
- except db.DBKeyExistError, val:
+ except db.DBKeyExistError as val:
assert val[0] == db.DB_KEYEXIST
if verbose: print val
else:
@@ -313,7 +313,7 @@ class BasicTestCase(unittest.TestCase):
print rec
try:
rec = c.next()
- except db.DBNotFoundError, val:
+ except db.DBNotFoundError as val:
if get_raises_error:
assert val[0] == db.DB_NOTFOUND
if verbose: print val
@@ -333,7 +333,7 @@ class BasicTestCase(unittest.TestCase):
print rec
try:
rec = c.prev()
- except db.DBNotFoundError, val:
+ except db.DBNotFoundError as val:
if get_raises_error:
assert val[0] == db.DB_NOTFOUND
if verbose: print val
@@ -357,7 +357,7 @@ class BasicTestCase(unittest.TestCase):
try:
n = c.set('bad key')
- except db.DBNotFoundError, val:
+ except db.DBNotFoundError as val:
assert val[0] == db.DB_NOTFOUND
if verbose: print val
else:
@@ -371,7 +371,7 @@ class BasicTestCase(unittest.TestCase):
try:
n = c.get_both('0404', 'bad data')
- except db.DBNotFoundError, val:
+ except db.DBNotFoundError as val:
assert val[0] == db.DB_NOTFOUND
if verbose: print val
else:
@@ -399,7 +399,7 @@ class BasicTestCase(unittest.TestCase):
c.delete()
try:
rec = c.current()
- except db.DBKeyEmptyError, val:
+ except db.DBKeyEmptyError as val:
if get_raises_error:
assert val[0] == db.DB_KEYEMPTY
if verbose: print val
@@ -445,7 +445,7 @@ class BasicTestCase(unittest.TestCase):
method
# a bug may cause a NULL pointer dereference...
getattr(c, method)(*args)
- except db.DBError, val:
+ except db.DBError as val:
assert val[0] == 0
if verbose: print val
else:
@@ -730,7 +730,7 @@ class BasicTransactionTestCase(BasicTestCase):
txn.abort()
try:
txn.abort()
- except db.DBError, e:
+ except db.DBError as e:
pass
else:
raise RuntimeError, "DBTxn.abort() called after DB_TXN no longer valid w/o an exception"
@@ -739,7 +739,7 @@ class BasicTransactionTestCase(BasicTestCase):
txn.commit()
try:
txn.commit()
- except db.DBError, e:
+ except db.DBError as e:
pass
else:
raise RuntimeError, "DBTxn.commit() called after DB_TXN no longer valid w/o an exception"
diff --git a/Lib/bsddb/test/test_compare.py b/Lib/bsddb/test/test_compare.py
index ccf8b83..b3eaf3a 100644
--- a/Lib/bsddb/test/test_compare.py
+++ b/Lib/bsddb/test/test_compare.py
@@ -234,7 +234,7 @@ class BtreeExceptionsTestCase (AbstractBtreeKeyCompareTestCase):
self.db.set_bt_compare (my_compare)
assert False, "this set should fail"
- except RuntimeError, msg:
+ except RuntimeError as msg:
pass
def test_suite ():
diff --git a/Lib/bsddb/test/test_pickle.py b/Lib/bsddb/test/test_pickle.py
index 3916e5c..4683ec6 100644
--- a/Lib/bsddb/test/test_pickle.py
+++ b/Lib/bsddb/test/test_pickle.py
@@ -11,7 +11,7 @@ import glob
try:
# For Pythons w/distutils pybsddb
from bsddb3 import db
-except ImportError, e:
+except ImportError as e:
# For Python 2.3
from bsddb import db
@@ -47,7 +47,7 @@ class pickleTestCase(unittest.TestCase):
assert self.db['spam'] == 'eggs'
try:
self.db.put('spam', 'ham', flags=db.DB_NOOVERWRITE)
- except db.DBError, egg:
+ except db.DBError as egg:
pickledEgg = pickle.dumps(egg)
#print repr(pickledEgg)
rottenEgg = pickle.loads(pickledEgg)
diff --git a/Lib/bsddb/test/test_recno.py b/Lib/bsddb/test/test_recno.py
index 35399b5..7bf3695 100644
--- a/Lib/bsddb/test/test_recno.py
+++ b/Lib/bsddb/test/test_recno.py
@@ -29,7 +29,7 @@ class SimpleRecnoTestCase(unittest.TestCase):
def tearDown(self):
try:
os.remove(self.filename)
- except OSError, e:
+ except OSError as e:
if e.errno != errno.EEXIST: raise
def test01_basic(self):
@@ -63,7 +63,7 @@ class SimpleRecnoTestCase(unittest.TestCase):
try:
data = d[0] # This should raise a KeyError!?!?!
- except db.DBInvalidArgError, val:
+ except db.DBInvalidArgError as val:
assert val[0] == db.EINVAL
if verbose: print val
else:
@@ -72,7 +72,7 @@ class SimpleRecnoTestCase(unittest.TestCase):
# test that has_key raises DB exceptions (fixed in pybsddb 4.3.2)
try:
d.has_key(0)
- except db.DBError, val:
+ except db.DBError as val:
pass
else:
self.fail("has_key did not raise a proper exception")
@@ -86,7 +86,7 @@ class SimpleRecnoTestCase(unittest.TestCase):
try:
data = d.get(100)
- except db.DBNotFoundError, val:
+ except db.DBNotFoundError as val:
if get_returns_none:
self.fail("unexpected exception")
else:
@@ -177,7 +177,7 @@ class SimpleRecnoTestCase(unittest.TestCase):
try:
d.get(99)
- except db.DBKeyEmptyError, val:
+ except db.DBKeyEmptyError as val:
if get_returns_none:
self.fail("unexpected DBKeyEmptyError exception")
else:
@@ -267,7 +267,7 @@ class SimpleRecnoTestCase(unittest.TestCase):
try: # this one will fail
d.append('bad' * 20)
- except db.DBInvalidArgError, val:
+ except db.DBInvalidArgError as val:
assert val[0] == db.EINVAL
if verbose: print val
else:
diff --git a/Lib/bsddb/test/test_thread.py b/Lib/bsddb/test/test_thread.py
index bf19d21..b3d7ef9 100644
--- a/Lib/bsddb/test/test_thread.py
+++ b/Lib/bsddb/test/test_thread.py
@@ -57,7 +57,7 @@ class BaseThreadedTestCase(unittest.TestCase):
self.homeDir = homeDir
try:
os.mkdir(homeDir)
- except OSError, e:
+ except OSError as e:
if e.errno != errno.EEXIST: raise
self.env = db.DBEnv()
self.setEnvOpts()
@@ -247,7 +247,7 @@ class SimpleThreadedBase(BaseThreadedTestCase):
# flush them
try:
dbutils.DeadlockWrap(d.sync, max_retries=12)
- except db.DBIncompleteError, val:
+ except db.DBIncompleteError as val:
if verbose:
print "could not complete sync()..."
@@ -360,7 +360,7 @@ class ThreadedTransactionsBase(BaseThreadedTestCase):
print "%s: records %d - %d finished" % (name, start, x)
txn.commit()
finished = True
- except (db.DBLockDeadlockError, db.DBLockNotGrantedError), val:
+ except (db.DBLockDeadlockError, db.DBLockNotGrantedError) as val:
if verbose:
print "%s: Aborting transaction (%s)" % (name, val[1])
txn.abort()
@@ -398,7 +398,7 @@ class ThreadedTransactionsBase(BaseThreadedTestCase):
finished = True
if verbose:
print "%s: deleted records %s" % (name, recs)
- except (db.DBLockDeadlockError, db.DBLockNotGrantedError), val:
+ except (db.DBLockDeadlockError, db.DBLockNotGrantedError) as val:
if verbose:
print "%s: Aborting transaction (%s)" % (name, val[1])
txn.abort()
@@ -428,7 +428,7 @@ class ThreadedTransactionsBase(BaseThreadedTestCase):
c.close()
txn.commit()
finished = True
- except (db.DBLockDeadlockError, db.DBLockNotGrantedError), val:
+ except (db.DBLockDeadlockError, db.DBLockNotGrantedError) as val:
if verbose:
print "%s: Aborting transaction (%s)" % (name, val[1])
c.close()