Closed instantname closed 6 years ago
Hi @instantname! Thanks for the patches!
This didn't appear to change anything for me on python-3.4. Do either of you, @instantname or @DustinHolden, have maybe an example script of what you were doing that failed?
@isislovecruft How about these unittests? test_decrypt_message__unarmored()
fails before the patch, and passes after.
#!/usr/bin/env python3
import gnupg
import logging
import unittest
TEST_MESSAGE = 'test_message_ABCDEFabcdef0123456789'
TEST_PASSWORD = 'password'
class TestDecryptBug(unittest.TestCase):
def setUp(self):
self.message = TEST_MESSAGE
self.password = TEST_PASSWORD
self.gpg = gnupg.GPG()
self.encrypted_message__armored = self.gpg.encrypt(
self.message,
None,
symmetric=True,
encrypt=False,
passphrase=self.password,
armor=True,
).data
self.encrypted_message__unarmored = self.gpg.encrypt(
self.message,
None,
symmetric=True,
encrypt=False,
passphrase=self.password,
armor=False,
).data
def test_decrypt_message__unarmored(self):
decrypted_message = str(self.gpg.decrypt(
self.encrypted_message__unarmored,
passphrase=self.password))
self.assertEqual(decrypted_message, self.message)
def test_decrypt_message__armored(self):
decrypted_message = str(self.gpg.decrypt(
self.encrypted_message__armored,
passphrase=self.password))
self.assertEqual(decrypted_message, self.message)
Hello,
Am running into the same issue where the decrypt_file works in 2.7 but not in python 3.6.8. We do have latest version of python-gnupg which is 0.4.6
We tried in 2 ways and below are the code snippets and both did not work. 1.) with open(_inputfile, "rb") as f: status = gpg.decrypt_file(f.read().decode('utf-8'), output= out_filename) 2.) with open(_inputfile, "rb") as f: out_filename = os.path.splitext(filename)[0] status = gpg.decrypt_file(f, output= out_filename)
ERROR:
None gpg: no valid OpenPGP data found. [GNUPG:] NODATA 1 [GNUPG:] NODATA 2 gpg: decrypt_message failed: Unknown system error
If anyone knows the answer please help.
@Alekhya404 From the version number you gave, it looks like you are not using the python-gnupg hosted at https://github.com/isislovecruft/python-gnupg/ and that is now named pretty-bad-protocol, but another package from which this project is a fork. Do you get the same error when using pretty-bad-protocol?
Thanks for your update. I installed pretty-bad-protocol and that worked for me in python3
Due to popular demand in #102, here is a hackish fix for that bug. I think it requires some testing and understanding before being merged.