From: Helmut Grohne Date: Mon, 26 May 2014 05:47:07 +0000 (+0200) Subject: fix gpg_get_key_addresses X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;ds=sidebyside;h=f2c4736fc1b4de2ea09b7e09518abd79ed682c64;hp=5bf93e8c52febd744c56d72dbbb4edc0ccca0177;p=dak.git fix gpg_get_key_addresses Do not use codecs.decode(s, "unicode_escape"). It has two issues: * When being passed a bytes literal, the returned value becomes a str and the decoding operation is locale specific on Python3. * When passing a unicode literal, it implicitly encodes to sys.getdefaultencoding() (locale specific) on Python2. Thus "unicode_escape" is a bad choice in all cases. For Python2 string_escape works with str, but it hinders a potential Python3 port of dak. Use it now, because Python3 is totally broken. --- diff --git a/daklib/utils.py b/daklib/utils.py index 30683097..3ae8d289 100644 --- a/daklib/utils.py +++ b/daklib/utils.py @@ -1381,7 +1381,8 @@ def gpg_get_key_addresses(fingerprint): except IndexError: continue try: - uid = codecs.decode(uid.decode("utf-8"), "unicode_escape") + # Do not use unicode_escape, because it is locale-specific + uid = codecs.decode(uid, "string_escape").decode("utf-8") except UnicodeDecodeError: uid = uid.decode("latin1") # does not fail m = re_parse_maintainer.match(uid)