GnuPG and standard output

Robert J. Hansen rjh at
Tue Aug 1 20:17:37 CEST 2017

GnuPG seems to insist on writing to a console, even where it's
unnecessary and counterproductive.  Consider the following Python code:


#!/usr/bin/env python3

args = ["/usr/local/bin/gpg",
result =, stdout=subprocess.PIPE)
print("Got {} bytes output".format(len(result.stdout)))


(If you're wondering why I'd do this, GPGME does not yet have a way to
query key prefs, and I need them for a project.)

There's no security reason to dump this to the console.  It's just
publicly-available information about the certificate.  And yet, it
consistently puts zero bytes in result.stdout, while displaying data to
the console.

What's the best way to get past this behavior?

More information about the Gnupg-users mailing list