diff --git a/src/dbi.py b/src/dbi.py index b353d7ecc..fbeeeea30 100644 --- a/src/dbi.py +++ b/src/dbi.py @@ -161,7 +161,8 @@ class FlatfileMapping(MappingInterface): self.currentId = 0 self._incrementCurrentId() finally: - fd.close() + if 'fd' in locals(): + fd.close() def _canonicalId(self, id): if id is not None: