From 078381c2ddf05f0a5701f00bffa99e178ab658c9 Mon Sep 17 00:00:00 2001 From: Igor Rzegocki Date: Wed, 17 Apr 2013 20:23:48 +0200 Subject: [PATCH] Removed stdin.write and stdout.read from GnuPG and replaced it with subprocess.communicate, to avoid deadlocks when larger messages are passed in --- GnuPG/__init__.py | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/GnuPG/__init__.py b/GnuPG/__init__.py index 674c7b3..cde18a2 100644 --- a/GnuPG/__init__.py +++ b/GnuPG/__init__.py @@ -26,16 +26,7 @@ class GPGEncryptor: def encrypt(self): p = subprocess.Popen( self._command(), stdin=subprocess.PIPE, stdout=subprocess.PIPE,stderr=subprocess.PIPE ) - (stdin, stdout, stderr) = (p.stdin, p.stdout, p.stderr) - - # Write the data - stdin.write(self._message) - stdin.close() - - # Read the encrypted data - p.wait() - encdata = stdout.read() - + encdata = p.communicate(input=self._message)[0] return encdata def _command(self):