diff --git a/gnupg/_meta.py b/gnupg/_meta.py index 934eba8..f93bae4 100644 --- a/gnupg/_meta.py +++ b/gnupg/_meta.py @@ -537,8 +537,8 @@ class GPGBase(object): if passphrase: cmd.append('--batch --passphrase-fd 0') - if self.use_agent: cmd.append('--use-agent') - else: cmd.append('--no-use-agent') + if self.use_agent is True: cmd.append('--use-agent') + elif self.use_agent is False: cmd.append('--no-use-agent') # The arguments for debugging and verbosity should be placed into the # cmd list before the options/args in order to resolve Issue #76: diff --git a/gnupg/gnupg.py b/gnupg/gnupg.py index 6a2fb46..12b46ce 100644 --- a/gnupg/gnupg.py +++ b/gnupg/gnupg.py @@ -161,6 +161,12 @@ class GPG(GPGBase): # fatal error (at least it does with GnuPG>=2.0.0): self.create_trustdb() + # The --no-use-agent and --use-agent options were deprecated in GnuPG + # 2.x, so we should set use_agent to None here to avoid having + # GPGBase._make_args() add either one. + if self.is_gpg2(): + self.use_agent = None + @functools.wraps(_trust._create_trustdb) def create_trustdb(self): if self.is_gpg2():