fix python2 stuff
Hanno Böck

Hanno Böck commited on 2020-09-24 13:26:09
Zeige 7 geänderte Dateien mit 301 Einfügungen und 0 Löschungen.

... ...
@@ -1,2 +1,3 @@
1
+AUX cffi-0.14.0-g-line.patch 9258 BLAKE2B a57cb8836dfcfb1124b1b72c38fb4c02d231fc7116c2de4b970e6423d037d1aa382173a4bebb9dafab0d690df485a64d824aafcdb16e31d01b391c25f4c239eb SHA512 335758de740050256af711e688072bbe4ac835551437bc2fbfd4dfaf5492efd5c722bca3bd8e5747bb0a88d3e7e6f82b78f85f5f42a4f11efb7b2f6c3ae4a492
1 2
 DIST cffi-1.14.0.tar.gz 463065 BLAKE2B 4d1e8a92241db801848ef8bd05ea15a31c7f61ea426ce4da184aff00df786348d2c76de9dc48898c814478aed9750b665868df24ad39435062cd7e1c84163e52 SHA512 4c5451eeede1d48a8f4b40e25b845ad1863b8bf3bd39624e6c693c2800d89a13efedc4c43b37e317a035613bffc2e3fd5f7e583c46cb283cb5cb930356f86253
2 3
 EBUILD cffi-1.14.0-r2.ebuild 1349 BLAKE2B 51d75557181e50a0cf4b23d7358e23f8b56bd05d76efe18a9d5685328c5197060eb45e9ffe894fbc5f05baa2e35275eef205d148b080ff6e774ce09da8cb6743 SHA512 510887308c5068c4d7b9f44c9e297cd854202b1651ba2661b2339dcf91fc438b476e1f1f6c30cbc95267e675dd00a98979a24482d5cc9aed99db6c89d9c555c9
... ...
@@ -0,0 +1,250 @@
1
+From 19ff1036043ae40ff3d8a2e1a6a793219e1ec378 Mon Sep 17 00:00:00 2001
2
+From: Armin Rigo <arigo@tunes.org>
3
+Date: Tue, 26 May 2020 15:51:56 +0200
4
+Subject: [PATCH] Issue #454
5
+
6
+Try harder to avoid #line directives confuse the rest of pre-parsing
7
+---
8
+ cffi/cparser.py               | 37 ++++++++++++++++++++++++---
9
+ testing/cffi0/test_parsing.py | 48 ++++++++++++++++++++++++++++++++++-
10
+ 2 files changed, 81 insertions(+), 4 deletions(-)
11
+
12
+diff --git a/cffi/cparser.py b/cffi/cparser.py
13
+index d7069a73..d9784655 100644
14
+--- a/cffi/cparser.py
15
++++ b/cffi/cparser.py
16
+@@ -29,6 +29,7 @@ _r_comment = re.compile(r"/\*.*?\*/|//([^\n\\]|\\.)*?$",
17
+ _r_define  = re.compile(r"^\s*#\s*define\s+([A-Za-z_][A-Za-z_0-9]*)"
18
+                         r"\b((?:[^\n\\]|\\.)*?)$",
19
+                         re.DOTALL | re.MULTILINE)
20
++_r_line_directive = re.compile(r"^[ \t]*#[ \t]*line\b.*$", re.MULTILINE)
21
+ _r_partial_enum = re.compile(r"=\s*\.\.\.\s*[,}]|\.\.\.\s*\}")
22
+ _r_enum_dotdotdot = re.compile(r"__dotdotdot\d+__$")
23
+ _r_partial_array = re.compile(r"\[\s*\.\.\.\s*\]")
24
+@@ -163,10 +164,37 @@ def _warn_for_non_extern_non_static_global_variable(decl):
25
+                       "with C it should have a storage class specifier "
26
+                       "(usually 'extern')" % (decl.name,))
27
+ 
28
++def _remove_line_directives(csource):
29
++    # _r_line_directive matches whole lines, without the final \n, if they
30
++    # start with '#line' with some spacing allowed.  This function stores
31
++    # them away and replaces them with exactly the string '#line@N', where
32
++    # N is the index in the list 'line_directives'.
33
++    line_directives = []
34
++    def replace(m):
35
++        i = len(line_directives)
36
++        line_directives.append(m.group())
37
++        return '#line@%d' % i
38
++    csource = _r_line_directive.sub(replace, csource)
39
++    return csource, line_directives
40
++
41
++def _put_back_line_directives(csource, line_directives):
42
++    def replace(m):
43
++        s = m.group()
44
++        if not s.startswith('#line@'):
45
++            raise AssertionError("unexpected #line directive "
46
++                                 "(should have been processed and removed")
47
++        return line_directives[int(s[6:])]
48
++    return _r_line_directive.sub(replace, csource)
49
++
50
+ def _preprocess(csource):
51
++    # First, remove the lines of the form '#line N "filename"' because
52
++    # the "filename" part could confuse the rest
53
++    csource, line_directives = _remove_line_directives(csource)
54
+     # Remove comments.  NOTE: this only work because the cdef() section
55
+-    # should not contain any string literal!
56
+-    csource = _r_comment.sub(' ', csource)
57
++    # should not contain any string literals (except in line directives)!
58
++    def replace_keeping_newlines(m):
59
++        return ' ' + m.group().count('\n') * '\n'
60
++    csource = _r_comment.sub(replace_keeping_newlines, csource)
61
+     # Remove the "#define FOO x" lines
62
+     macros = {}
63
+     for match in _r_define.finditer(csource):
64
+@@ -219,7 +247,10 @@ def _preprocess(csource):
65
+     csource = _r_float_dotdotdot.sub(' __dotdotdotfloat__ ', csource)
66
+     # Replace all remaining "..." with the same name, "__dotdotdot__",
67
+     # which is declared with a typedef for the purpose of C parsing.
68
+-    return csource.replace('...', ' __dotdotdot__ '), macros
69
++    csource = csource.replace('...', ' __dotdotdot__ ')
70
++    # Finally, put back the line directives
71
++    csource = _put_back_line_directives(csource, line_directives)
72
++    return csource, macros
73
+ 
74
+ def _common_type_names(csource):
75
+     # Look in the source for what looks like usages of types from the
76
+diff --git a/testing/cffi0/test_parsing.py b/testing/cffi0/test_parsing.py
77
+index 3fc3783a..5f2d7ec4 100644
78
+--- a/testing/cffi0/test_parsing.py
79
++++ b/testing/cffi0/test_parsing.py
80
+@@ -174,7 +174,7 @@ def test_remove_line_continuation_comments():
81
+         double // blah \\
82
+                   more comments
83
+         x(void);
84
+-        double // blah\\\\
85
++        double // blah // blah\\\\
86
+         y(void);
87
+         double // blah\\ \
88
+                   etc
89
+@@ -185,6 +185,52 @@ def test_remove_line_continuation_comments():
90
+     m.y
91
+     m.z
92
+ 
93
++def test_dont_remove_comment_in_line_directives():
94
++    ffi = FFI(backend=FakeBackend())
95
++    e = py.test.raises(CDefError, ffi.cdef, """
96
++        \t # \t line \t 8 \t "baz.c" \t
97
++
98
++        some syntax error here
99
++    """)
100
++    assert str(e.value) == "parse error\nbaz.c:9:14: before: syntax"
101
++    #
102
++    e = py.test.raises(CDefError, ffi.cdef, """
103
++        #line 7 "foo//bar.c"
104
++
105
++        some syntax error here
106
++    """)
107
++    assert str(e.value) == "parse error\nfoo//bar.c:8:14: before: syntax"
108
++
109
++def test_multiple_line_directives():
110
++    ffi = FFI(backend=FakeBackend())
111
++    e = py.test.raises(CDefError, ffi.cdef,
112
++    """ #line 5 "foo.c"
113
++        extern int xx;
114
++        #line 6 "bar.c"
115
++        extern int yy;
116
++        #line 7 "baz.c"
117
++        some syntax error here
118
++        #line 8 "yadda.c"
119
++        extern int zz;
120
++    """)
121
++    assert str(e.value) == "parse error\nbaz.c:7:14: before: syntax"
122
++
123
++def test_commented_line_directive():
124
++    ffi = FFI(backend=FakeBackend())
125
++    e = py.test.raises(CDefError, ffi.cdef, """
126
++        /*
127
++        #line 5 "foo.c"
128
++        */
129
++        void xx(void);
130
++
131
++        #line 6 "bar.c"
132
++        /*
133
++        #line 35 "foo.c"
134
++        */
135
++        some syntax error
136
++    """)
137
++    assert str(e.value) == "parse error\nbar.c:9:14: before: syntax"
138
++
139
+ def test_line_continuation_in_defines():
140
+     ffi = FFI(backend=FakeBackend())
141
+     ffi.cdef("""
142
+-- 
143
+2.26.2
144
+
145
+From 31249d786c833d4960bbbf4e0d7f7bcaecf92d1f Mon Sep 17 00:00:00 2001
146
+From: Armin Rigo <arigo@tunes.org>
147
+Date: Fri, 29 May 2020 10:27:40 +0200
148
+Subject: [PATCH] #454
149
+
150
+Second try with '# NUMBER' instead of '#line NUMBER', as gcc seems to output
151
+---
152
+ cffi/cparser.py               |  8 +++----
153
+ testing/cffi0/test_parsing.py | 41 +++++++++++++++++++++++++++++++++++
154
+ 2 files changed, 45 insertions(+), 4 deletions(-)
155
+
156
+diff --git a/cffi/cparser.py b/cffi/cparser.py
157
+index d9784655..74830e91 100644
158
+--- a/cffi/cparser.py
159
++++ b/cffi/cparser.py
160
+@@ -29,7 +29,7 @@ _r_comment = re.compile(r"/\*.*?\*/|//([^\n\\]|\\.)*?$",
161
+ _r_define  = re.compile(r"^\s*#\s*define\s+([A-Za-z_][A-Za-z_0-9]*)"
162
+                         r"\b((?:[^\n\\]|\\.)*?)$",
163
+                         re.DOTALL | re.MULTILINE)
164
+-_r_line_directive = re.compile(r"^[ \t]*#[ \t]*line\b.*$", re.MULTILINE)
165
++_r_line_directive = re.compile(r"^[ \t]*#[ \t]*(?:line|\d+)\b.*$", re.MULTILINE)
166
+ _r_partial_enum = re.compile(r"=\s*\.\.\.\s*[,}]|\.\.\.\s*\}")
167
+ _r_enum_dotdotdot = re.compile(r"__dotdotdot\d+__$")
168
+ _r_partial_array = re.compile(r"\[\s*\.\.\.\s*\]")
169
+@@ -166,9 +166,9 @@ def _warn_for_non_extern_non_static_global_variable(decl):
170
+ 
171
+ def _remove_line_directives(csource):
172
+     # _r_line_directive matches whole lines, without the final \n, if they
173
+-    # start with '#line' with some spacing allowed.  This function stores
174
+-    # them away and replaces them with exactly the string '#line@N', where
175
+-    # N is the index in the list 'line_directives'.
176
++    # start with '#line' with some spacing allowed, or '#NUMBER'.  This
177
++    # function stores them away and replaces them with exactly the string
178
++    # '#line@N', where N is the index in the list 'line_directives'.
179
+     line_directives = []
180
+     def replace(m):
181
+         i = len(line_directives)
182
+diff --git a/testing/cffi0/test_parsing.py b/testing/cffi0/test_parsing.py
183
+index 5f2d7ec4..a5e45874 100644
184
+--- a/testing/cffi0/test_parsing.py
185
++++ b/testing/cffi0/test_parsing.py
186
+@@ -199,6 +199,21 @@ def test_dont_remove_comment_in_line_directives():
187
+ 
188
+         some syntax error here
189
+     """)
190
++    #
191
++    assert str(e.value) == "parse error\nfoo//bar.c:8:14: before: syntax"
192
++    ffi = FFI(backend=FakeBackend())
193
++    e = py.test.raises(CDefError, ffi.cdef, """
194
++        \t # \t 8 \t "baz.c" \t
195
++
196
++        some syntax error here
197
++    """)
198
++    assert str(e.value) == "parse error\nbaz.c:9:14: before: syntax"
199
++    #
200
++    e = py.test.raises(CDefError, ffi.cdef, """
201
++        # 7 "foo//bar.c"
202
++
203
++        some syntax error here
204
++    """)
205
+     assert str(e.value) == "parse error\nfoo//bar.c:8:14: before: syntax"
206
+ 
207
+ def test_multiple_line_directives():
208
+@@ -214,6 +229,18 @@ def test_multiple_line_directives():
209
+         extern int zz;
210
+     """)
211
+     assert str(e.value) == "parse error\nbaz.c:7:14: before: syntax"
212
++    #
213
++    e = py.test.raises(CDefError, ffi.cdef,
214
++    """ # 5 "foo.c"
215
++        extern int xx;
216
++        # 6 "bar.c"
217
++        extern int yy;
218
++        # 7 "baz.c"
219
++        some syntax error here
220
++        # 8 "yadda.c"
221
++        extern int zz;
222
++    """)
223
++    assert str(e.value) == "parse error\nbaz.c:7:14: before: syntax"
224
+ 
225
+ def test_commented_line_directive():
226
+     ffi = FFI(backend=FakeBackend())
227
+@@ -229,6 +256,20 @@ def test_commented_line_directive():
228
+         */
229
+         some syntax error
230
+     """)
231
++    #
232
++    assert str(e.value) == "parse error\nbar.c:9:14: before: syntax"
233
++    e = py.test.raises(CDefError, ffi.cdef, """
234
++        /*
235
++        # 5 "foo.c"
236
++        */
237
++        void xx(void);
238
++
239
++        # 6 "bar.c"
240
++        /*
241
++        # 35 "foo.c"
242
++        */
243
++        some syntax error
244
++    """)
245
+     assert str(e.value) == "parse error\nbar.c:9:14: before: syntax"
246
+ 
247
+ def test_line_continuation_in_defines():
248
+-- 
249
+2.26.2
250
+
... ...
@@ -1,2 +1,3 @@
1
+AUX pycryptodome-3.9.4-parallel-make.patch 756 BLAKE2B 06a79eff056ecb983131838287563d4d60896f27e28d5c2534f4ab008e50017694ac9355b43f8f387cc29abfd21ffd648233c3dbae33a06fcedb12a6c7e11e80 SHA512 06b42ea780bd374cf5cb5d6cef3fade5d695c1ee0d765e2659408da7645ad311eef2028f17d8ec0289d49c3a5851b4c63503d7c922de15873dbbf16d0db58b08
1 2
 DIST pycryptodome-3.9.8.tar.gz 15633268 BLAKE2B 8c4f8d4839be0fb09556677514ee6c7f832684f20eb4e355cee87eb5b52a5c09e12712c1865ff89fb5dd6c628ca027374c7cab8a2287aafa4eecedf1095f1a12 SHA512 894e763720df284804fd686d5805980853b86773bb3097bf03d929818b9944e5a257e47414275f302966864751e50ae34dea19ad749910f1ceac31833a53ef7c
2 3
 EBUILD pycryptodome-3.9.8.ebuild 1330 BLAKE2B 97e78373d4e5d2d7065d0ca60fa8374d225c48ccf89b51fd51d8bbd68897d5ed37ba237f346bd9347a6cdb3204b5b7b43a28426fa593e3d039259a4664ac4e60 SHA512 3596bf56db6f47c1e9c0ce9568988566a858541128e2962af886d1260f059a6542ec5588bf651c343db73a42e483b64e44ab8fdafacfdd6aa6f53cd46dc1df4f
... ...
@@ -0,0 +1,22 @@
1
+diff --git a/setup.py b/setup.py
2
+index 1d70caad..c72f64ff 100644
3
+--- a/setup.py
4
++++ b/setup.py
5
+@@ -364,7 +364,7 @@ ext_modules = [
6
+     Extension("Crypto.Cipher._raw_eksblowfish",
7
+         include_dirs=['src/'],
8
+         define_macros=[('EKS',None),],
9
+-        sources=["src/blowfish.c"]),
10
++        sources=["src/blowfish_eks.c"]),
11
+     Extension("Crypto.Cipher._raw_cast",
12
+         include_dirs=['src/'],
13
+         sources=["src/CAST.c"]),
14
+@@ -427,7 +427,7 @@ ext_modules = [
15
+     # Math
16
+     Extension("Crypto.Math._modexp",
17
+         include_dirs=['src/'],
18
+-        sources=['src/modexp.c', 'src/siphash.c', 'src/modexp_utils.c', 'src/mont.c'],
19
++        sources=['src/modexp.c', 'src/siphash.c', 'src/modexp_utils.c', 'src/mont_math.c'],
20
+         ),
21
+ ]
22
+ 
... ...
@@ -0,0 +1,2 @@
1
+EBUILD python-cffi-1.ebuild 583 BLAKE2B ec2bc45f0ec539df749667d5258724330c94bed602cf7db73e75ccbab872144d784bb547b021ca2aa603306e945092d5e4041bfb3bc12609b7c1baa61af3ba92 SHA512 97d8cbd4cf20f287e661e33af6943163814d2a76cf3fb6e0868f0db3ef071c1fba59656b15d887365b2060d01e80dffdabf3056744f5adddeacddbee01510491
2
+MISC metadata.xml 240 BLAKE2B 41e6a4d9da33dab2decc5ff419924f382a8f64d27a81fdb97576db8c6cf125be95911747946ec8be1b453f56617fef1084f5947f84b50a8db419d46df2ae8a0f SHA512 9c23321eaa853f851bf00195ea64ac2ba093e516f9b57855ee5aa58fbb1988130c9f0c17c2a9ce9fae4ee033e0a28a70c868e0f5acdfa1dd316ab533c5279d59
... ...
@@ -0,0 +1,8 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
3
+<pkgmetadata>
4
+	<maintainer type="project">
5
+		<email>python@gentoo.org</email>
6
+		<name>Python</name>
7
+	</maintainer>
8
+</pkgmetadata>
... ...
@@ -0,0 +1,17 @@
1
+# Copyright 1999-2020 Gentoo Authors
2
+# Distributed under the terms of the GNU General Public License v2
3
+
4
+EAPI=7
5
+
6
+PYTHON_COMPAT=( python2_7 python3_{6,7,8,9} pypy3 )
7
+
8
+inherit python-r1
9
+
10
+DESCRIPTION="A virtual for the Python cffi package"
11
+SLOT="0"
12
+KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~m68k ~mips ppc ppc64 ~riscv s390 sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~sparc-solaris ~x64-solaris"
13
+REQUIRED_USE="${PYTHON_REQUIRED_USE}"
14
+
15
+# built-in in PyPy and PyPy3
16
+RDEPEND="${PYTHON_DEPS}
17
+	$(python_gen_cond_dep 'dev-python/cffi[${PYTHON_USEDEP}]' 'python*')"
0 18