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@g10code.com>
This commit is contained in:
parent
7641b7b5f2
commit
9350168a1e
@ -699,7 +699,7 @@ class Context(GpgmeWrapper):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if isinstance(command, (str, bytes)):
|
if util.is_a_string(command) or isinstance(command, bytes):
|
||||||
cmd = command
|
cmd = command
|
||||||
else:
|
else:
|
||||||
cmd = " ".join(util.percent_escape(f) for f in command)
|
cmd = " ".join(util.percent_escape(f) for f in command)
|
||||||
|
@ -24,9 +24,12 @@ import gpg
|
|||||||
|
|
||||||
with gpg.Context(protocol=gpg.constants.protocol.ASSUAN) as c:
|
with gpg.Context(protocol=gpg.constants.protocol.ASSUAN) as c:
|
||||||
# Do nothing.
|
# Do nothing.
|
||||||
c.assuan_transact('nop')
|
err = c.assuan_transact('nop')
|
||||||
c.assuan_transact('NOP')
|
assert err == None
|
||||||
c.assuan_transact(['NOP'])
|
err = c.assuan_transact(b'NOP')
|
||||||
|
assert err == None
|
||||||
|
err = c.assuan_transact(['NOP'])
|
||||||
|
assert err == None
|
||||||
|
|
||||||
err = c.assuan_transact('idontexist')
|
err = c.assuan_transact('idontexist')
|
||||||
assert err.getsource() == gpg.errors.SOURCE_GPGAGENT
|
assert err.getsource() == gpg.errors.SOURCE_GPGAGENT
|
||||||
|
Loading…
Reference in New Issue
Block a user