diff --git a/gnupg/_meta.py b/gnupg/_meta.py index d90da47..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') - elif self.use_agent==False: cmd.append('--no-use-agent') # obsolete for GPG 2.0 + 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 2427c4d..12b46ce 100644 --- a/gnupg/gnupg.py +++ b/gnupg/gnupg.py @@ -161,8 +161,11 @@ class GPG(GPGBase): # fatal error (at least it does with GnuPG>=2.0.0): self.create_trustdb() - # --no-use-agent is obsolete - if not self.use_agent: self.use_agent = None + # 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):