except handling in spelling
@@ -32,7 +32,7 @@ class OsDictionary:
self.pageSize = 1024 * 8 # Arbitrary.
# Add one to pick up any partial page at the end.
self.filePages = self.fileLength / self.pageSize + 1
- except:
+ except IOError:
self.file = None
self.cache = {}
self.knownOffsets = []
@@ -47,6 +47,7 @@ class OsDictionary:
high = self.filePages
low = 0
leash = 20 # Way more than should be necessary.
+ try:
while True:
if not leash:
# There's likely a bug in this function if we hit this.
@@ -61,11 +62,7 @@ class OsDictionary:
self.cache[word] = False
return False
chunk = self.file.read(size)
- try:
- chunk = chunk[chunk.index('\n'):chunk.rfind('\n')]
- except:
- self.cache[word] = False
- return False
+ chunk = chunk[chunk.find('\n'):chunk.rfind('\n')]
if not chunk:
self.cache[word] = False
return False
@@ -83,6 +80,8 @@ class OsDictionary:
return True
self.cache[word] = False
return False
+ except IOError:
+ return False
osDictionary = OsDictionary()
