Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new_archive_write should probably call write_fail when an exception is raised #51

Closed
Changaco opened this issue Dec 21, 2016 · 0 comments

Comments

@Changaco
Copy link
Owner

From #50 (comment)

Something like that:

diff --git a/libarchive/write.py b/libarchive/write.py
index 35eb8f5..062c384 100644
--- a/libarchive/write.py
+++ b/libarchive/write.py
@@ -116,9 +116,12 @@ def new_archive_write(format_name, filter_name=None):
         getattr(ffi, 'write_add_filter_'+filter_name)(archive_p)
     try:
         yield archive_p
-    finally:
         ffi.write_close(archive_p)
         ffi.write_free(archive_p)
+    except:
+        ffi.write_fail(archive_p)
+        ffi.write_free(archive_p)
+        raise
 
 
 @contextmanager

Need a test to confirm that it's the right thing to do. I don't have time to take of it right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant