[Pkg-gnupg-commit] [gpgme] 81/132: python: Fix using strings as commands in the assuan protocol.

Daniel Kahn Gillmor dkg at fifthhorseman.net
Wed Apr 26 01:01:28 UTC 2017


This is an automated email from the git hooks/post-receive script.

dkg pushed a commit to branch experimental
in repository gpgme.

commit 9350168a1eed3f055040d7cc8a9bf4cdf745b23a
Author: Justus Winter <justus at g10code.com>
Date:   Fri Feb 17 12:10:34 2017 +0100

    python: Fix using strings as commands in the assuan protocol.
    
    * lang/python/gpg/core.py (Context.assuan_transact): Fix testing
    whether the command is a string on Python2.
    * lang/python/tests/t-protocol-assuan.py: Improve the test to detect
    this problem.
    
    Signed-off-by: Justus Winter <justus at g10code.com>
---
 lang/python/gpg/core.py                | 2 +-
 lang/python/tests/t-protocol-assuan.py | 9 ++++++---
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/lang/python/gpg/core.py b/lang/python/gpg/core.py
index beaebda..28d4629 100644
--- a/lang/python/gpg/core.py
+++ b/lang/python/gpg/core.py
@@ -699,7 +699,7 @@ class Context(GpgmeWrapper):
 
         """
 
-        if isinstance(command, (str, bytes)):
+        if util.is_a_string(command) or isinstance(command, bytes):
             cmd = command
         else:
             cmd = " ".join(util.percent_escape(f) for f in command)
diff --git a/lang/python/tests/t-protocol-assuan.py b/lang/python/tests/t-protocol-assuan.py
index 0084a6b..27b28c7 100755
--- a/lang/python/tests/t-protocol-assuan.py
+++ b/lang/python/tests/t-protocol-assuan.py
@@ -24,9 +24,12 @@ import gpg
 
 with gpg.Context(protocol=gpg.constants.protocol.ASSUAN) as c:
     # Do nothing.
-    c.assuan_transact('nop')
-    c.assuan_transact('NOP')
-    c.assuan_transact(['NOP'])
+    err = c.assuan_transact('nop')
+    assert err == None
+    err = c.assuan_transact(b'NOP')
+    assert err == None
+    err = c.assuan_transact(['NOP'])
+    assert err == None
 
     err = c.assuan_transact('idontexist')
     assert err.getsource() == gpg.errors.SOURCE_GPGAGENT

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gpgme.git



More information about the Pkg-gnupg-commit mailing list