[gnome-keysign: 55/65] gnome-keysign-sign-key: Add binary mode for Python 3 compatibility
- From: Gitlab System User <gitlab src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-keysign: 55/65] gnome-keysign-sign-key: Add binary mode for Python 3 compatibility
- Date: Tue, 3 Oct 2017 11:41:31 +0000 (UTC)
commit 47f3be3e1bab15264c807566c295fce0549ede3d
Author: RyuzakiKK <aasonykk gmail com>
Date: Sun Oct 1 18:40:00 2017 +0200
gnome-keysign-sign-key: Add binary mode for Python 3 compatibility
Opening the file in binary mode is necessary for Python 3
compatibility, otherwise it will fail with:
"TypeError: arg 2: expected gpg.Data, file, bytes (not string!), or an
object implementing the buffer protocol. Got: str"
I also removed the unused sleep import.
keysign/gnome-keysign-sign-key.py | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/keysign/gnome-keysign-sign-key.py b/keysign/gnome-keysign-sign-key.py
index 22342b9..ba07824 100755
--- a/keysign/gnome-keysign-sign-key.py
+++ b/keysign/gnome-keysign-sign-key.py
@@ -18,20 +18,20 @@
import logging
import sys
-from time import sleep
from .util import sign_keydata_and_send
if sys.version_info.major < 3:
input = raw_input
+
def main(args):
log = logging.getLogger(__name__)
log.debug('Running main with args: %s', args)
if not args:
raise ValueError("You need to give filesnames as args: %s" % args)
for fname in args:
- data = open(fname, 'r').read()
+ data = open(fname, 'rb').read()
log.info("Calling %r to sign %s", sign_keydata_and_send, fname)
tmpfiles = list(sign_keydata_and_send(keydata=data))
log.info("Finished signing. " +
@@ -40,6 +40,7 @@ def main(args):
"Press any key to quit the application.")
input()
+
if __name__ == '__main__':
logging.basicConfig(stream=sys.stderr, level=logging.DEBUG,
format='%(name)s (%(levelname)s): %(message)s')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]