Commit ec6c4a89 authored by Guido van Rossum's avatar Guido van Rossum

Fix a problem I saw when some tests here failed: there's a pattern in

the code

    try:
        root = self._getRoot()
        ...
    except:
        self._closeDB(root)
	self._delDB()
	raise

which fails with an UnboundLocalError if the first line in the try
clause fails.  Fixed this by setting 'root = None' before each such
try clause, and adding a None check to _closeDB().  Also removed a
useless 'root = None' from the body of _closeDB().

Barry: I saw this in the saz 1.0c1 release.  Is it worth backporting?
Probably not given that we're not going to do a merge pre-1.0.
parent a858080a
...@@ -37,8 +37,8 @@ class Base: ...@@ -37,8 +37,8 @@ class Base:
return root return root
def _closeDB(self, root): def _closeDB(self, root):
root._p_jar._db.close() if root is not None:
root = None root._p_jar._db.close()
def _delDB(self): def _delDB(self):
for file in glob('fs_tmp__*'): for file in glob('fs_tmp__*'):
...@@ -48,6 +48,7 @@ class Base: ...@@ -48,6 +48,7 @@ class Base:
for i in 0, 10, 1000: for i in 0, 10, 1000:
t = self.t.__class__() t = self.t.__class__()
self._populate(t, i) self._populate(t, i)
root = None
try: try:
root = self._getRoot() root = self._getRoot()
root[i] = t root[i] = t
...@@ -59,6 +60,7 @@ class Base: ...@@ -59,6 +60,7 @@ class Base:
self._closeDB(root) self._closeDB(root)
root = None
try: try:
root = self._getRoot() root = self._getRoot()
#XXX BTree stuff doesn't implement comparison #XXX BTree stuff doesn't implement comparison
...@@ -74,6 +76,7 @@ class Base: ...@@ -74,6 +76,7 @@ class Base:
for i in 0, 10, 1000: for i in 0, 10, 1000:
t = self.t.__class__() t = self.t.__class__()
self._populate(t, i) self._populate(t, i)
root = None
try: try:
root = self._getRoot() root = self._getRoot()
root[i] = t root[i] = t
...@@ -85,6 +88,7 @@ class Base: ...@@ -85,6 +88,7 @@ class Base:
self._closeDB(root) self._closeDB(root)
root = None
try: try:
root = self._getRoot() root = self._getRoot()
root[i]._p_changed = None root[i]._p_changed = None
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment