mirror of
https://github.com/gentoo-mirror/gentoo.git
synced 2026-07-25 21:08:35 -07:00
dev-python/pycparser: Backport upstream -OO patch, #628386
This commit is contained in:
56
dev-python/pycparser/files/pycparser-2.18-OO.patch
Normal file
56
dev-python/pycparser/files/pycparser-2.18-OO.patch
Normal file
@@ -0,0 +1,56 @@
|
||||
From 673accec311a027c22b0718d753f8da922915305 Mon Sep 17 00:00:00 2001
|
||||
From: Eli Bendersky <eliben@gmail.com>
|
||||
Date: Thu, 13 Jul 2017 20:25:29 -0700
|
||||
Subject: [PATCH] Address an import of pycparser in -OO mode.
|
||||
|
||||
In this mode there are no docstrings; we don't want an instantiation of CParser
|
||||
to fail, though it won't actually work correctly if used.
|
||||
|
||||
See #197 and #198
|
||||
---
|
||||
pycparser/plyparser.py | 21 +++++++++++++++++++--
|
||||
1 file changed, 19 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/pycparser/plyparser.py b/pycparser/plyparser.py
|
||||
index af91922..b6640fa 100644
|
||||
--- a/pycparser/plyparser.py
|
||||
+++ b/pycparser/plyparser.py
|
||||
@@ -8,6 +8,7 @@
|
||||
# License: BSD
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
+import warnings
|
||||
|
||||
class Coord(object):
|
||||
""" Coordinates of a syntactic element. Consists of:
|
||||
@@ -87,12 +88,28 @@ def template(cls):
|
||||
|
||||
See `parameterized` for more information on parameterized rules.
|
||||
"""
|
||||
+ issued_nodoc_warning = False
|
||||
for attr_name in dir(cls):
|
||||
if attr_name.startswith('p_'):
|
||||
method = getattr(cls, attr_name)
|
||||
if hasattr(method, '_params'):
|
||||
- delattr(cls, attr_name) # Remove template method
|
||||
- _create_param_rules(cls, method)
|
||||
+ # Remove the template method
|
||||
+ delattr(cls, attr_name)
|
||||
+ # Create parameterized rules from this method; only run this if
|
||||
+ # the method has a docstring. This is to address an issue when
|
||||
+ # pycparser's users are installed in -OO mode which strips
|
||||
+ # docstrings away.
|
||||
+ # See: https://github.com/eliben/pycparser/pull/198/ and
|
||||
+ # https://github.com/eliben/pycparser/issues/197
|
||||
+ # for discussion.
|
||||
+ if method.__doc__ is not None:
|
||||
+ _create_param_rules(cls, method)
|
||||
+ elif not issued_nodoc_warning:
|
||||
+ warnings.warn(
|
||||
+ 'parsing methods must have __doc__ for pycparser to work properly',
|
||||
+ RuntimeWarning,
|
||||
+ stacklevel=2)
|
||||
+ issued_nodoc_warning = True
|
||||
return cls
|
||||
|
||||
|
||||
@@ -21,6 +21,10 @@ DEPEND="${RDEPEND}
|
||||
dev-python/setuptools[${PYTHON_USEDEP}]
|
||||
test? ( dev-python/nose[${PYTHON_USEDEP}] )"
|
||||
|
||||
PATCHES=(
|
||||
"${FILESDIR}"/pycparser-2.18-OO.patch
|
||||
)
|
||||
|
||||
python_prepare_all() {
|
||||
# remove the original files to guarantee their regen
|
||||
rm pycparser/{c_ast,lextab,yacctab}.py || die
|
||||
|
||||
Reference in New Issue
Block a user