Skip to content

Commit f9ff042

Browse files
committed
define encoding when communicating with the gpg-agent process
This fixes: $ vault_from_gpg_agent.py --clear Traceback (most recent call last): File "/usr/local/bin/vault_from_gpg_agent.py", line 91, in <module> main() File "/usr/local/bin/vault_from_gpg_agent.py", line 85, in main clear_passphrase(gpg_agent, cache_id) File "/usr/local/bin/vault_from_gpg_agent.py", line 61, in clear_passphrase stdout = gpg_agent.communicate("CLEAR_PASSPHRASE %s\n" % (cache_id,))[0] File "/usr/lib/python3.7/subprocess.py", line 939, in communicate stdout, stderr = self._communicate(input, endtime, timeout) File "/usr/lib/python3.7/subprocess.py", line 1666, in _communicate input_view = memoryview(self._input) TypeError: memoryview: a bytes-like object is required, not 'str' I set the encoding='utf8' when doing the `Popen`. As long as only ascii characters get passed back and forth we should be safe.
1 parent d58d2bc commit f9ff042

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

vault_from_gpg_agent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def main():
6767
parser.add_argument("--clear", default=False, action="store_true",
6868
help="Clear password from GPG agent")
6969
gpg_agent = subprocess.Popen(["gpg-connect-agent"], stdin=subprocess.PIPE,
70-
stdout=subprocess.PIPE)
70+
stdout=subprocess.PIPE, encoding='utf8')
7171
args = parser.parse_args()
7272
my_path = os.path.realpath(sys.argv[0])
7373
# Per the source, cache-id is limited to 50 bytes, so we hash our

0 commit comments

Comments
 (0)