[Zodb-checkins] CVS: ZODB3/ZODB - FileStorage.py:1.133
Christian Reis
kiko at async.com.br
Thu May 22 15:33:33 EDT 2003
Update of /cvs-repository/ZODB3/ZODB
In directory cvs.zope.org:/tmp/cvs-serv9580
Modified Files:
FileStorage.py
Log Message:
Implement check for invalid oids when the FileStorage's _index member
is accessed. This improves some odd unsliceable object TypeErrors which
popped up from inside fsIndex.
=== ZODB3/ZODB/FileStorage.py 1.132 => 1.133 ===
--- ZODB3/ZODB/FileStorage.py:1.132 Fri May 16 16:19:15 2003
+++ ZODB3/ZODB/FileStorage.py Thu May 22 14:33:32 2003
@@ -595,6 +595,8 @@
pos=_index[oid]
except KeyError:
raise POSKeyError(oid)
+ except TypeError:
+ raise TypeError, 'invalid oid %r' % (oid,)
file.seek(pos)
read=file.read
h=read(DATA_HDR_LEN)
@@ -616,6 +618,8 @@
pos = _index[oid]
except KeyError:
raise POSKeyError(oid)
+ except TypeError:
+ raise TypeError, 'invalid oid %r' % (oid,)
file.seek(pos)
read = file.read
h = read(DATA_HDR_LEN)
@@ -655,6 +659,8 @@
pos = self._index[oid]
except KeyError:
raise POSKeyError(oid)
+ except TypeError:
+ raise TypeError, 'invalid oid %r' % (oid,)
while 1:
seek(pos)
h=read(DATA_HDR_LEN)
@@ -686,6 +692,8 @@
pos = self._index[oid]
except KeyError:
raise POSKeyError(oid)
+ except TypeError:
+ raise TypeError, 'invalid oid %r' % (oid,)
file=self._file
file.seek(pos)
doid,serial,prev,tloc,vlen = unpack(">8s8s8s8sH", file.read(34))
@@ -1082,7 +1090,12 @@
def getSerial(self, oid):
self._lock_acquire()
try:
- return self._getSerial(oid, self._index[oid])
+ try:
+ return self._getSerial(oid, self._index[oid])
+ except KeyError:
+ raise POSKeyError(oid)
+ except TypeError:
+ raise TypeError, 'invalid oid %r' % (oid,)
finally:
self._lock_release()
@@ -1370,7 +1383,12 @@
file=self._file
seek=file.seek
read=file.read
- pos=self._index[oid]
+ try:
+ pos=self._index[oid]
+ except KeyError:
+ raise POSKeyError(oid)
+ except TypeError:
+ raise TypeError, 'invalid oid %r' % (oid,)
wantver=version
while 1:
@@ -1503,6 +1521,8 @@
pos = self._index[oid]
except KeyError:
return None
+ except TypeError:
+ raise TypeError, 'invalid oid %r' % (oid,)
self._file.seek(pos)
# first 8 bytes are oid, second 8 bytes are serialno
h = self._file.read(16)
More information about the Zodb-checkins
mailing list