Gentoo Archives: gentoo-commits

From: "Michał Górny" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-python/pycparser/, dev-python/pycparser/files/
Date: Sun, 27 Aug 2017 18:07:58
Message-Id: 1503857269.d1e3eb8faa09741a67cc56a0ff6d5332a7bc6068.mgorny@gentoo
1 commit: d1e3eb8faa09741a67cc56a0ff6d5332a7bc6068
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Sun Aug 27 18:07:13 2017 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Sun Aug 27 18:07:49 2017 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d1e3eb8f
7
8 dev-python/pycparser: Backport upstream -OO patch, #628386
9
10 dev-python/pycparser/files/pycparser-2.18-OO.patch | 56 ++++++++++++++++++++++
11 dev-python/pycparser/pycparser-2.18-r1.ebuild | 4 ++
12 2 files changed, 60 insertions(+)
13
14 diff --git a/dev-python/pycparser/files/pycparser-2.18-OO.patch b/dev-python/pycparser/files/pycparser-2.18-OO.patch
15 new file mode 100644
16 index 00000000000..ae42b2b9bd1
17 --- /dev/null
18 +++ b/dev-python/pycparser/files/pycparser-2.18-OO.patch
19 @@ -0,0 +1,56 @@
20 +From 673accec311a027c22b0718d753f8da922915305 Mon Sep 17 00:00:00 2001
21 +From: Eli Bendersky <eliben@×××××.com>
22 +Date: Thu, 13 Jul 2017 20:25:29 -0700
23 +Subject: [PATCH] Address an import of pycparser in -OO mode.
24 +
25 +In this mode there are no docstrings; we don't want an instantiation of CParser
26 +to fail, though it won't actually work correctly if used.
27 +
28 +See #197 and #198
29 +---
30 + pycparser/plyparser.py | 21 +++++++++++++++++++--
31 + 1 file changed, 19 insertions(+), 2 deletions(-)
32 +
33 +diff --git a/pycparser/plyparser.py b/pycparser/plyparser.py
34 +index af91922..b6640fa 100644
35 +--- a/pycparser/plyparser.py
36 ++++ b/pycparser/plyparser.py
37 +@@ -8,6 +8,7 @@
38 + # License: BSD
39 + #-----------------------------------------------------------------
40 +
41 ++import warnings
42 +
43 + class Coord(object):
44 + """ Coordinates of a syntactic element. Consists of:
45 +@@ -87,12 +88,28 @@ def template(cls):
46 +
47 + See `parameterized` for more information on parameterized rules.
48 + """
49 ++ issued_nodoc_warning = False
50 + for attr_name in dir(cls):
51 + if attr_name.startswith('p_'):
52 + method = getattr(cls, attr_name)
53 + if hasattr(method, '_params'):
54 +- delattr(cls, attr_name) # Remove template method
55 +- _create_param_rules(cls, method)
56 ++ # Remove the template method
57 ++ delattr(cls, attr_name)
58 ++ # Create parameterized rules from this method; only run this if
59 ++ # the method has a docstring. This is to address an issue when
60 ++ # pycparser's users are installed in -OO mode which strips
61 ++ # docstrings away.
62 ++ # See: https://github.com/eliben/pycparser/pull/198/ and
63 ++ # https://github.com/eliben/pycparser/issues/197
64 ++ # for discussion.
65 ++ if method.__doc__ is not None:
66 ++ _create_param_rules(cls, method)
67 ++ elif not issued_nodoc_warning:
68 ++ warnings.warn(
69 ++ 'parsing methods must have __doc__ for pycparser to work properly',
70 ++ RuntimeWarning,
71 ++ stacklevel=2)
72 ++ issued_nodoc_warning = True
73 + return cls
74 +
75 +
76
77 diff --git a/dev-python/pycparser/pycparser-2.18-r1.ebuild b/dev-python/pycparser/pycparser-2.18-r1.ebuild
78 index 3fb094f6ff3..9cbbb4ac2e8 100644
79 --- a/dev-python/pycparser/pycparser-2.18-r1.ebuild
80 +++ b/dev-python/pycparser/pycparser-2.18-r1.ebuild
81 @@ -21,6 +21,10 @@ DEPEND="${RDEPEND}
82 dev-python/setuptools[${PYTHON_USEDEP}]
83 test? ( dev-python/nose[${PYTHON_USEDEP}] )"
84
85 +PATCHES=(
86 + "${FILESDIR}"/pycparser-2.18-OO.patch
87 +)
88 +
89 python_prepare_all() {
90 # remove the original files to guarantee their regen
91 rm pycparser/{c_ast,lextab,yacctab}.py || die