archrelease: copy trunk to extra-x86_64
[arch-packages.git] / crda / trunk / crda-4.14-python-3.patch
blob8dc7aecbae414baa4cddea1d9e164c5b3db683cb
1 diff --git a/utils/key2pub.py b/utils/key2pub.py
2 index 9bb04cd..632e6a6 100755
3 --- a/utils/key2pub.py
4 +++ b/utils/key2pub.py
5 @@ -3,20 +3,20 @@
6 import sys
7 try:
8 from M2Crypto import RSA
9 -except ImportError, e:
10 +except ImportError as e:
11 sys.stderr.write('ERROR: Failed to import the "M2Crypto" module: %s\n' % e.message)
12 sys.stderr.write('Please install the "M2Crypto" Python module.\n')
13 sys.stderr.write('On Debian GNU/Linux the package is called "python-m2crypto".\n')
14 sys.exit(1)
16 def print_ssl_64(output, name, val):
17 - while val[0] == '\0':
18 + while val[0:1] == b'\0':
19 val = val[1:]
20 while len(val) % 8:
21 - val = '\0' + val
22 + val = b'\0' + val
23 vnew = []
24 while len(val):
25 - vnew.append((val[0], val[1], val[2], val[3], val[4], val[5], val[6], val[7]))
26 + vnew.append((val[0:1], val[1:2], val[2:3], val[3:4], val[4:5], val[5:6], val[6:7], val[7:8]))
27 val = val[8:]
28 vnew.reverse()
29 output.write('static BN_ULONG %s[%d] = {\n' % (name, len(vnew)))
30 @@ -34,13 +34,13 @@ def print_ssl_64(output, name, val):
31 output.write('};\n\n')
33 def print_ssl_32(output, name, val):
34 - while val[0] == '\0':
35 + while val[0:1] == b'\0':
36 val = val[1:]
37 while len(val) % 4:
38 - val = '\0' + val
39 + val = b'\0' + val
40 vnew = []
41 while len(val):
42 - vnew.append((val[0], val[1], val[2], val[3], ))
43 + vnew.append((val[0:1], val[1:2], val[2:3], val[3:4]))
44 val = val[4:]
45 vnew.reverse()
46 output.write('static BN_ULONG %s[%d] = {\n' % (name, len(vnew)))
47 @@ -80,21 +80,21 @@ struct pubkey {
49 static struct pubkey keys[] = {
50 ''')
51 - for n in xrange(n + 1):
52 + for n in range(n + 1):
53 output.write(' KEYS(e_%d, n_%d),\n' % (n, n))
54 output.write('};\n')
55 pass
57 def print_gcrypt(output, name, val):
58 output.write('#include <stdint.h>\n')
59 - while val[0] == '\0':
60 + while val[0:1] == b'\0':
61 val = val[1:]
62 output.write('static const uint8_t %s[%d] = {\n' % (name, len(val)))
63 idx = 0
64 for v in val:
65 if not idx:
66 output.write('\t')
67 - output.write('0x%.2x, ' % ord(v))
68 + output.write('0x%.2x, ' % (v if sys.version_info[0] >=3 else ord(v)))
69 idx += 1
70 if idx == 8:
71 idx = 0
72 @@ -117,7 +117,7 @@ struct key_params {
74 static const struct key_params __attribute__ ((unused)) keys[] = {
75 ''')
76 - for n in xrange(n + 1):
77 + for n in range(n + 1):
78 output.write(' KEYS(e_%d, n_%d),\n' % (n, n))
79 output.write('};\n')
81 @@ -135,7 +135,7 @@ except IndexError:
82 mode = None
84 if not mode in modes:
85 - print 'Usage: %s [%s] input-file... output-file' % (sys.argv[0], '|'.join(modes.keys()))
86 + print('Usage: %s [%s] input-file... output-file' % (sys.argv[0], '|'.join(modes.keys())))
87 sys.exit(2)
89 output = open(outfile, 'w')
90 @@ -153,3 +153,5 @@ for f in files:
91 idx += 1
93 modes[mode][1](output, idx - 1)
95 +output.close()