objectstore: fix Object._open exception handling

Move the call to os.open outside of the try block so that if an
exception occurs it will be properly propagated to the callers.
This commit is contained in:
Christian Kellner 2020-02-18 16:19:00 +01:00 committed by Tom Gundersen
parent 007488488e
commit c73a28613b

View file

@ -129,8 +129,8 @@ class Object:
@contextlib.contextmanager
def _open(self):
"""Open the directory and return the file descriptor"""
fd = os.open(self._path, os.O_DIRECTORY)
try:
fd = os.open(self._path, os.O_DIRECTORY)
yield fd
finally:
os.close(fd)