os_open(): don't attempt to close fd if open failed.
authorNikolaus Rath <Nikolaus@rath.org>
Sun, 6 Aug 2017 11:24:20 +0000 (13:24 +0200)
committerNikolaus Rath <Nikolaus@rath.org>
Sun, 6 Aug 2017 11:24:20 +0000 (13:24 +0200)
test/test_examples.py

index f9badad629c0942dbc7df1e7972df19ba966cb8b..e20b47c815161a62d9e22ace9c28398c57c450fb 100755 (executable)
@@ -290,8 +290,8 @@ def test_cuse(capfd):
 
 @contextmanager
 def os_open(name, flags):
+    fd = os.open(name, flags)
     try:
-        fd = os.open(name, flags)
         yield fd
     finally:
         os.close(fd)