[elbe-devel] [PATCH 2/2] Python 3: decode the downloaded base64 OpenPGP key

Torben Hohn torben.hohn at linutronix.de
Wed Dec 11 12:21:57 CET 2019


please correct the subject to Python3: without the space.



On Tue, Dec 10, 2019 at 11:31:17PM +0100, bage at linutronix.de wrote:
> From: Bastian Germann <bage at linutronix.de>
> 
> urlopen() returns binary data, so it has to be converted for Python 3.
> As the data is base64 in this case, we can assume ASCII data.
> 
> Signed-off-by: Bastian Germann <bage at linutronix.de>
> ---
>  elbepack/xmlpreprocess.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/elbepack/xmlpreprocess.py b/elbepack/xmlpreprocess.py
> index e310048e3..26db99b6b 100644
> --- a/elbepack/xmlpreprocess.py
> +++ b/elbepack/xmlpreprocess.py
> @@ -43,7 +43,7 @@ def preprocess_pgp_key(xml):
>          print("[WARN] <key>%s</key> is deprecated.  You should use raw-key instead." % key.text)
>          try:
>              keyurl = key.text.strip().replace('LOCALMACHINE', 'localhost')
> -            myKey = urlopen(keyurl).read()
> +            myKey = urlopen(keyurl).read().decode('ascii')

not so happy about forcing it to ascii.
not so happy about doing 3 things in a single line.

and the decoding Exception is not caught, so there is no proper
Error message.

Acked-by: Torben Hohn <torben.hohn at linutronix.de>




>              key.tag = "raw-key"
>              key.text = "\n%s\n" % myKey
>          except HTTPError as E:
> -- 
> 2.20.1
> 
> 
> _______________________________________________
> elbe-devel mailing list
> elbe-devel at linutronix.de
> https://lists.linutronix.de/mailman/listinfo/elbe-devel

-- 
Torben Hohn
Linutronix GmbH | Bahnhofstrasse 3 | D-88690 Uhldingen-Mühlhofen
Phone: +49 7556 25 999 18; Fax.: +49 7556 25 999 99

Hinweise zum Datenschutz finden Sie hier (Informations on data privacy 
can be found here): https://linutronix.de/kontakt/Datenschutz.php

Linutronix GmbH | Firmensitz (Registered Office): Uhldingen-Mühlhofen | 
Registergericht (Registration Court): Amtsgericht Freiburg i.Br., HRB700 
806 | Geschäftsführer (Managing Directors): Heinz Egger, Thomas Gleixner



More information about the elbe-devel mailing list