From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 4C5FC13881E for ; Tue, 29 Sep 2015 00:39:00 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 89060E07E6; Tue, 29 Sep 2015 00:38:57 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 12DCEE07E6 for ; Tue, 29 Sep 2015 00:38:57 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 02082340854 for ; Tue, 29 Sep 2015 00:38:55 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 15349215 for ; Tue, 29 Sep 2015 00:38:53 +0000 (UTC) From: "Mike Frysinger" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Mike Frysinger" Message-ID: <1443487118.751d0f79973aa5c2918b386e814aa3eda17df27b.vapier@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: app-misc/ca-certificates/files/ X-VCS-Repository: repo/gentoo X-VCS-Files: app-misc/ca-certificates/files/ca-certificates-20150426-nss-certdata2pem-py3.patch X-VCS-Directories: app-misc/ca-certificates/files/ X-VCS-Committer: vapier X-VCS-Committer-Name: Mike Frysinger X-VCS-Revision: 751d0f79973aa5c2918b386e814aa3eda17df27b X-VCS-Branch: master Date: Tue, 29 Sep 2015 00:38:53 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 5a663c6e-e271-438b-a71b-0918c5b5878d X-Archives-Hash: fba4eebbfc1054294f30254b76ce03e3 commit: 751d0f79973aa5c2918b386e814aa3eda17df27b Author: Mike Frysinger gentoo org> AuthorDate: Tue Sep 29 00:37:37 2015 +0000 Commit: Mike Frysinger gentoo org> CommitDate: Tue Sep 29 00:38:38 2015 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=751d0f79 app-misc/ca-certificates: rework py3 patch a bit more #561586 Rework some of the codec logic to make sure we can read files when in a non-UTF8 locale (like LANG=C), and it works w/py2.7 and py3.4. ...certificates-20150426-nss-certdata2pem-py3.patch | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/app-misc/ca-certificates/files/ca-certificates-20150426-nss-certdata2pem-py3.patch b/app-misc/ca-certificates/files/ca-certificates-20150426-nss-certdata2pem-py3.patch index 300ce47..d639aef 100644 --- a/app-misc/ca-certificates/files/ca-certificates-20150426-nss-certdata2pem-py3.patch +++ b/app-misc/ca-certificates/files/ca-certificates-20150426-nss-certdata2pem-py3.patch @@ -3,6 +3,19 @@ https://bugs.gentoo.org/548374 --- a/ca-certificates/mozilla/certdata2pem.py +++ b/ca-certificates/mozilla/certdata2pem.py +@@ -31,7 +31,11 @@ objects = [] + # Dirty file parser. + in_data, in_multiline, in_obj = False, False, False + field, type, value, obj = None, None, None, dict() +-for line in open('certdata.txt', 'r'): ++try: ++ f = open('certdata.txt', 'r', encoding='utf-8') ++except TypeError: ++ f = open('certdata.txt', 'r') ++for line in f: + # Ignore the file header. + if not in_data: + if line.startswith('BEGINDATA'): @@ -53,7 +53,7 @@ for line in open('certdata.txt', 'r'): if type == 'MULTILINE_OCTAL': line = line.strip() @@ -62,17 +75,19 @@ https://bugs.gentoo.org/548374 .replace(')', '=')\ .replace(',', '_') - bname = bname.decode('string_escape') +- fname = bname + '.crt' + + # this is the only way to decode the way NSS stores multi-byte UTF-8 + if bytes != str: + bname = bname.encode('utf-8') + bname = bname.decode('unicode_escape').encode('latin-1').decode('utf-8') - fname = bname + '.crt' ++ fname = (bname + '.crt').encode('utf-8') + if os.path.exists(fname): - print "Found duplicate certificate name %s, renaming." % bname -+ print("Found duplicate certificate name %s, renaming." % bname) - fname = bname + '_2.crt' +- fname = bname + '_2.crt' ++ print("Found duplicate certificate name %s, renaming." % fname) ++ fname = (bname + '_2.crt').encode('utf-8') f = open(fname, 'w') f.write("-----BEGIN CERTIFICATE-----\n") - f.write("\n".join(textwrap.wrap(base64.b64encode(obj['CKA_VALUE']), 64)))