Browse code

fix python2 stuff

Hanno Böck authored on24/09/2020 13:26:09
Showing7 changed files
... ...
@@ -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
3 4
new file mode 100644
... ...
@@ -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
+@@ -29,6 +29,7 @@ _r_comment = re.compile(r"/\*.*?\*/|//([^\n\\]|\\.)*?$",
16
+ _r_define  = re.compile(r"^\s*#\s*define\s+([A-Za-z_][A-Za-z_0-9]*)"
17
+                         r"\b((?:[^\n\\]|\\.)*?)$",
18
+                         re.DOTALL | re.MULTILINE)
19
++_r_line_directive = re.compile(r"^[ \t]*#[ \t]*line\b.*$", re.MULTILINE)
20
+ _r_partial_enum = re.compile(r"=\s*\.\.\.\s*[,}]|\.\.\.\s*\}")
21
+ _r_enum_dotdotdot = re.compile(r"__dotdotdot\d+__$")
22
+ _r_partial_array = re.compile(r"\[\s*\.\.\.\s*\]")
23
+@@ -163,10 +164,37 @@ def _warn_for_non_extern_non_static_global_variable(decl):
24
+                       "with C it should have a storage class specifier "
25
+                       "(usually 'extern')" % (decl.name,))
26
+ 
27
++def _remove_line_directives(csource):
28
++    # _r_line_directive matches whole lines, without the final \n, if they
29
++    # start with '#line' with some spacing allowed.  This function stores
30
++    # them away and replaces them with exactly the string '#line@N', where
31
++    # N is the index in the list 'line_directives'.
32
++    line_directives = []
33
++    def replace(m):
34
++        i = len(line_directives)
35
++        line_directives.append(m.group())
36
++        return '#line@%d' % i
37
++    csource = _r_line_directive.sub(replace, csource)
38
++    return csource, line_directives
39
++
40
++def _put_back_line_directives(csource, line_directives):
41
++    def replace(m):
42
++        s = m.group()
43
++        if not s.startswith('#line@'):
44
++            raise AssertionError("unexpected #line directive "
45
++                                 "(should have been processed and removed")
46
++        return line_directives[int(s[6:])]
47
++    return _r_line_directive.sub(replace, csource)
48
++
49
+ def _preprocess(csource):
50
++    # First, remove the lines of the form '#line N "filename"' because
51
++    # the "filename" part could confuse the rest
52
++    csource, line_directives = _remove_line_directives(csource)
53
+     # Remove comments.  NOTE: this only work because the cdef() section
54
+-    # should not contain any string literal!
55
+-    csource = _r_comment.sub(' ', csource)
56
++    # should not contain any string literals (except in line directives)!
57
++    def replace_keeping_newlines(m):
58
++        return ' ' + m.group().count('\n') * '\n'
59
++    csource = _r_comment.sub(replace_keeping_newlines, csource)
60
+     # Remove the "#define FOO x" lines
61
+     macros = {}
62
+     for match in _r_define.finditer(csource):
63
+@@ -219,7 +247,10 @@ def _preprocess(csource):
64
+     csource = _r_float_dotdotdot.sub(' __dotdotdotfloat__ ', csource)
65
+     # Replace all remaining "..." with the same name, "__dotdotdot__",
66
+     # which is declared with a typedef for the purpose of C parsing.
67
+-    return csource.replace('...', ' __dotdotdot__ '), macros
68
++    csource = csource.replace('...', ' __dotdotdot__ ')
69
++    # Finally, put back the line directives
70
++    csource = _put_back_line_directives(csource, line_directives)
71
++    return csource, macros
72
+ 
73
+ def _common_type_names(csource):
74
+     # Look in the source for what looks like usages of types from the
75
+diff --git a/testing/cffi0/test_parsing.py b/testing/cffi0/test_parsing.py
76
+index 3fc3783a..5f2d7ec4 100644
77
+--- a/testing/cffi0/test_parsing.py
78
+@@ -174,7 +174,7 @@ def test_remove_line_continuation_comments():
79
+         double // blah \\
80
+                   more comments
81
+         x(void);
82
+-        double // blah\\\\
83
++        double // blah // blah\\\\
84
+         y(void);
85
+         double // blah\\ \
86
+                   etc
87
+@@ -185,6 +185,52 @@ def test_remove_line_continuation_comments():
88
+     m.y
89
+     m.z
90
+ 
91
++def test_dont_remove_comment_in_line_directives():
92
++    ffi = FFI(backend=FakeBackend())
93
++    e = py.test.raises(CDefError, ffi.cdef, """
94
++        \t # \t line \t 8 \t "baz.c" \t
95
++
96
++        some syntax error here
97
++    """)
98
++    assert str(e.value) == "parse error\nbaz.c:9:14: before: syntax"
99
++    #
100
++    e = py.test.raises(CDefError, ffi.cdef, """
101
++        #line 7 "foo//bar.c"
102
++
103
++        some syntax error here
104
++    """)
105
++    assert str(e.value) == "parse error\nfoo//bar.c:8:14: before: syntax"
106
++
107
++def test_multiple_line_directives():
108
++    ffi = FFI(backend=FakeBackend())
109
++    e = py.test.raises(CDefError, ffi.cdef,
110
++    """ #line 5 "foo.c"
111
++        extern int xx;
112
++        #line 6 "bar.c"
113
++        extern int yy;
114
++        #line 7 "baz.c"
115
++        some syntax error here
116
++        #line 8 "yadda.c"
117
++        extern int zz;
118
++    """)
119
++    assert str(e.value) == "parse error\nbaz.c:7:14: before: syntax"
120
++
121
++def test_commented_line_directive():
122
++    ffi = FFI(backend=FakeBackend())
123
++    e = py.test.raises(CDefError, ffi.cdef, """
124
++        /*
125
++        #line 5 "foo.c"
126
++        */
127
++        void xx(void);
128
++
129
++        #line 6 "bar.c"
130
++        /*
131
++        #line 35 "foo.c"
132
++        */
133
++        some syntax error
134
++    """)
135
++    assert str(e.value) == "parse error\nbar.c:9:14: before: syntax"
136
++
137
+ def test_line_continuation_in_defines():
138
+     ffi = FFI(backend=FakeBackend())
139
+     ffi.cdef("""
140
+-- 
141
+2.26.2
142
+
143
+From 31249d786c833d4960bbbf4e0d7f7bcaecf92d1f Mon Sep 17 00:00:00 2001
144
+From: Armin Rigo <arigo@tunes.org>
145
+Date: Fri, 29 May 2020 10:27:40 +0200
146
+Subject: [PATCH] #454
147
+
148
+Second try with '# NUMBER' instead of '#line NUMBER', as gcc seems to output
149
+---
150
+ cffi/cparser.py               |  8 +++----
151
+ testing/cffi0/test_parsing.py | 41 +++++++++++++++++++++++++++++++++++
152
+ 2 files changed, 45 insertions(+), 4 deletions(-)
153
+
154
+diff --git a/cffi/cparser.py b/cffi/cparser.py
155
+index d9784655..74830e91 100644
156
+--- a/cffi/cparser.py
157
+@@ -29,7 +29,7 @@ _r_comment = re.compile(r"/\*.*?\*/|//([^\n\\]|\\.)*?$",
158
+ _r_define  = re.compile(r"^\s*#\s*define\s+([A-Za-z_][A-Za-z_0-9]*)"
159
+                         r"\b((?:[^\n\\]|\\.)*?)$",
160
+                         re.DOTALL | re.MULTILINE)
161
+-_r_line_directive = re.compile(r"^[ \t]*#[ \t]*line\b.*$", re.MULTILINE)
162
++_r_line_directive = re.compile(r"^[ \t]*#[ \t]*(?:line|\d+)\b.*$", re.MULTILINE)
163
+ _r_partial_enum = re.compile(r"=\s*\.\.\.\s*[,}]|\.\.\.\s*\}")
164
+ _r_enum_dotdotdot = re.compile(r"__dotdotdot\d+__$")
165
+ _r_partial_array = re.compile(r"\[\s*\.\.\.\s*\]")
166
+@@ -166,9 +166,9 @@ def _warn_for_non_extern_non_static_global_variable(decl):
167
+ 
168
+ def _remove_line_directives(csource):
169
+     # _r_line_directive matches whole lines, without the final \n, if they
170
+-    # start with '#line' with some spacing allowed.  This function stores
171
+-    # them away and replaces them with exactly the string '#line@N', where
172
+-    # N is the index in the list 'line_directives'.
173
++    # start with '#line' with some spacing allowed, or '#NUMBER'.  This
174
++    # function stores them away and replaces them with exactly the string
175
++    # '#line@N', where N is the index in the list 'line_directives'.
176
+     line_directives = []
177
+     def replace(m):
178
+         i = len(line_directives)
179
+diff --git a/testing/cffi0/test_parsing.py b/testing/cffi0/test_parsing.py
180
+index 5f2d7ec4..a5e45874 100644
181
+--- a/testing/cffi0/test_parsing.py
182
+@@ -199,6 +199,21 @@ def test_dont_remove_comment_in_line_directives():
183
+ 
184
+         some syntax error here
185
+     """)
186
++    #
187
++    assert str(e.value) == "parse error\nfoo//bar.c:8:14: before: syntax"
188
++    ffi = FFI(backend=FakeBackend())
189
++    e = py.test.raises(CDefError, ffi.cdef, """
190
++        \t # \t 8 \t "baz.c" \t
191
++
192
++        some syntax error here
193
++    """)
194
++    assert str(e.value) == "parse error\nbaz.c:9:14: before: syntax"
195
++    #
196
++    e = py.test.raises(CDefError, ffi.cdef, """
197
++        # 7 "foo//bar.c"
198
++
199
++        some syntax error here
200
++    """)
201
+     assert str(e.value) == "parse error\nfoo//bar.c:8:14: before: syntax"
202
+ 
203
+ def test_multiple_line_directives():
204
+@@ -214,6 +229,18 @@ def test_multiple_line_directives():
205
+         extern int zz;
206
+     """)
207
+     assert str(e.value) == "parse error\nbaz.c:7:14: before: syntax"
208
++    #
209
++    e = py.test.raises(CDefError, ffi.cdef,
210
++    """ # 5 "foo.c"
211
++        extern int xx;
212
++        # 6 "bar.c"
213
++        extern int yy;
214
++        # 7 "baz.c"
215
++        some syntax error here
216
++        # 8 "yadda.c"
217
++        extern int zz;
218
++    """)
219
++    assert str(e.value) == "parse error\nbaz.c:7:14: before: syntax"
220
+ 
221
+ def test_commented_line_directive():
222
+     ffi = FFI(backend=FakeBackend())
223
+@@ -229,6 +256,20 @@ def test_commented_line_directive():
224
+         */
225
+         some syntax error
226
+     """)
227
++    #
228
++    assert str(e.value) == "parse error\nbar.c:9:14: before: syntax"
229
++    e = py.test.raises(CDefError, ffi.cdef, """
230
++        /*
231
++        # 5 "foo.c"
232
++        */
233
++        void xx(void);
234
++
235
++        # 6 "bar.c"
236
++        /*
237
++        # 35 "foo.c"
238
++        */
239
++        some syntax error
240
++    """)
241
+     assert str(e.value) == "parse error\nbar.c:9:14: before: syntax"
242
+ 
243
+ def test_line_continuation_in_defines():
244
+-- 
245
+2.26.2
246
+
... ...
@@ -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
3 4
new file mode 100644
... ...
@@ -0,0 +1,22 @@
1
+diff --git a/setup.py b/setup.py
2
+index 1d70caad..c72f64ff 100644
3
+--- a/setup.py
4
+@@ -364,7 +364,7 @@ ext_modules = [
5
+     Extension("Crypto.Cipher._raw_eksblowfish",
6
+         include_dirs=['src/'],
7
+         define_macros=[('EKS',None),],
8
+-        sources=["src/blowfish.c"]),
9
++        sources=["src/blowfish_eks.c"]),
10
+     Extension("Crypto.Cipher._raw_cast",
11
+         include_dirs=['src/'],
12
+         sources=["src/CAST.c"]),
13
+@@ -427,7 +427,7 @@ ext_modules = [
14
+     # Math
15
+     Extension("Crypto.Math._modexp",
16
+         include_dirs=['src/'],
17
+-        sources=['src/modexp.c', 'src/siphash.c', 'src/modexp_utils.c', 'src/mont.c'],
18
++        sources=['src/modexp.c', 'src/siphash.c', 'src/modexp_utils.c', 'src/mont_math.c'],
19
+         ),
20
+ ]
21
+ 
0 22
new file mode 100644
... ...
@@ -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 3
new file mode 100644
... ...
@@ -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 9
new file mode 100644
... ...
@@ -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*')"