-
Notifications
You must be signed in to change notification settings - Fork 34
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
Re-raise exceptions from on_data handler #242
Comments
The |
Thanks for your answer, I didn't realize that it was used for other cases too. Indeed adding something along those lines in the doc would be helpful:
And change one of the examples like this for instance: class Collector:
def __init__(self, fn):
self.out = open(fn, 'wb')
self.exception = None
def __call__(self, chunk):
try:
self.out.write(chunk)
except Exception as e:
self.exception = e
finally:
if not chunk:
self.out.close()
return False # Tell python-gnupg not to buffer the chunk I can do a quick PR if you'd like, but maybe you prefer writing this a bit differently? Thanks |
I've already started on something to address this, I'll push it shortly - just quite busy this weekend. My approach is a little different (allowing |
I have now pushed the changes, and updated the documentation which you can see at https://gnupg.readthedocs.io/en/latest/ - search for "New in version 0.5.4" to see the update. |
Thanks! |
Thank you for this very useful package.
Is your feature request related to a problem? Please describe.
I am using the
on_data
handler to process decrypted data. When an exception is raised within it,decrypt_file
call prints it to the console but does not raise.In the result returned by
decrypt_file
I see no clue that this exception was raised.Describe the solution you'd like
I would prefer that
decrypt_file
re-raise the exception instead of printing it. Or alternatively thatreturncode
were changed to non-zero. Or another possibility would be simply to warn about this behavior in the doc as I suppose most users would expectdecrypt_file
to re-raise in the first place (the example shown in the doc says that it does not handle errors but could be further specified).Describe alternatives you've considered
I could circumvent this issue by handling all exceptions within the callable object passed to
on_data
, setting a flag when an exception is raised and read this flag afterwards to raise outsidedecrypt_file
call but it does not look very intuitive.Thanks!
The text was updated successfully, but these errors were encountered: