public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] repo/gentoo:master commit in: dev-python/pycparser/, dev-python/pycparser/files/
@ 2017-08-27 18:07 Michał Górny
  0 siblings, 0 replies; 2+ messages in thread
From: Michał Górny @ 2017-08-27 18:07 UTC (permalink / raw
  To: gentoo-commits

commit:     d1e3eb8faa09741a67cc56a0ff6d5332a7bc6068
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Aug 27 18:07:13 2017 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun Aug 27 18:07:49 2017 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d1e3eb8f

dev-python/pycparser: Backport upstream -OO patch, #628386

 dev-python/pycparser/files/pycparser-2.18-OO.patch | 56 ++++++++++++++++++++++
 dev-python/pycparser/pycparser-2.18-r1.ebuild      |  4 ++
 2 files changed, 60 insertions(+)

diff --git a/dev-python/pycparser/files/pycparser-2.18-OO.patch b/dev-python/pycparser/files/pycparser-2.18-OO.patch
new file mode 100644
index 00000000000..ae42b2b9bd1
--- /dev/null
+++ b/dev-python/pycparser/files/pycparser-2.18-OO.patch
@@ -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
+ 
+ 

diff --git a/dev-python/pycparser/pycparser-2.18-r1.ebuild b/dev-python/pycparser/pycparser-2.18-r1.ebuild
index 3fb094f6ff3..9cbbb4ac2e8 100644
--- a/dev-python/pycparser/pycparser-2.18-r1.ebuild
+++ b/dev-python/pycparser/pycparser-2.18-r1.ebuild
@@ -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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: dev-python/pycparser/, dev-python/pycparser/files/
@ 2023-02-26 15:25 Michał Górny
  0 siblings, 0 replies; 2+ messages in thread
From: Michał Górny @ 2023-02-26 15:25 UTC (permalink / raw
  To: gentoo-commits

commit:     06668ccb9dd2920b55fc01fb5bc6a24129e69421
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Feb 26 15:06:16 2023 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun Feb 26 15:25:10 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=06668ccb

dev-python/pycparser: Backport lextab.py build failure fix

Closes: https://bugs.gentoo.org/701878
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 .../files/pycparser-2.21-lextab-cache.patch        | 66 ++++++++++++++++++++++
 dev-python/pycparser/pycparser-2.21-r1.ebuild      |  5 ++
 dev-python/pycparser/pycparser-2.21-r2.ebuild      |  5 ++
 3 files changed, 76 insertions(+)

diff --git a/dev-python/pycparser/files/pycparser-2.21-lextab-cache.patch b/dev-python/pycparser/files/pycparser-2.21-lextab-cache.patch
new file mode 100644
index 000000000000..d24999e7273a
--- /dev/null
+++ b/dev-python/pycparser/files/pycparser-2.21-lextab-cache.patch
@@ -0,0 +1,66 @@
+From 35a279ecb9af41a6f95ddbc6a0f1beaa2472d165 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
+Date: Sun, 26 Feb 2023 01:04:34 +0100
+Subject: [PATCH] _build_tables: Invalidate cache before importing generated
+ modules (#494)
+
+Make sure to invalidate finder caches before trying to import generated
+modules.  This is necessary according to the Python documentation:
+https://docs.python.org/3/library/importlib.html#importlib.invalidate_caches
+
+This fixes a hard-to-reproduce bug that Python would be unable to find
+just-generated `lextab.py` if mtime of the current directory did not
+change from the moment the script was started.  This could
+e.g. be the case if one has second-precision timestamps and removes
+the generated file just before starting the build, e.g.:
+
+    $ rm pycparser/lextab.py; python -m build -nw
+
+It could also be reproduced easier by doing something like:
+
+    $ cd pycparser
+    $ touch .; python -B _build_tables.py
+    Traceback (most recent call last):
+      File "/var/tmp/pycparser/pycparser/_build_tables.py", line 38, in <module>
+        import lextab
+    ModuleNotFoundError: No module named 'lextab'
+
+This is because the first command (`rm` or `touch`) updates the mtime
+of the directory to the current time.  If the script is run fast enough,
+it manages to scan the directory and then write the new `lextab.py`
+within the same second.  As a result, mtime of the directory after
+writing the new file is the same as when the script was started, finder
+does not invalidate the cache and assumes that `lextab.py` does not
+exist since it did not exist when the directory was scanned earlier.
+
+This potentially fixes #493.
+
+It was originally reported on https://bugs.gentoo.org/701878.
+Thanks to Gary E. Miller for patience in reproducing the problem
+and proxy-debugging it for me, as well as testing the final patch before
+submission.
+---
+ pycparser/_build_tables.py | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/pycparser/_build_tables.py b/pycparser/_build_tables.py
+index 958381ad..4f371079 100644
+--- a/pycparser/_build_tables.py
++++ b/pycparser/_build_tables.py
+@@ -13,6 +13,7 @@
+ # Insert '.' and '..' as first entries to the search path for modules.
+ # Restricted environments like embeddable python do not include the
+ # current working directory on startup.
++import importlib
+ import sys
+ sys.path[0:0] = ['.', '..']
+ 
+@@ -32,6 +33,8 @@
+ 
+ # Load to compile into .pyc
+ #
++importlib.invalidate_caches()
++
+ import lextab
+ import yacctab
+ import c_ast

diff --git a/dev-python/pycparser/pycparser-2.21-r1.ebuild b/dev-python/pycparser/pycparser-2.21-r1.ebuild
index 1b0d8e6f6901..3848eaeedd3a 100644
--- a/dev-python/pycparser/pycparser-2.21-r1.ebuild
+++ b/dev-python/pycparser/pycparser-2.21-r1.ebuild
@@ -30,6 +30,11 @@ BDEPEND="
 distutils_enable_tests unittest
 
 python_prepare_all() {
+	local PATCHES=(
+		# https://github.com/eliben/pycparser/pull/494
+		"${FILESDIR}"/${P}-lextab-cache.patch
+	)
+
 	# remove the original files to guarantee their regen
 	rm pycparser/{c_ast,lextab,yacctab}.py || die
 

diff --git a/dev-python/pycparser/pycparser-2.21-r2.ebuild b/dev-python/pycparser/pycparser-2.21-r2.ebuild
index edebc42725b5..08416104b7d4 100644
--- a/dev-python/pycparser/pycparser-2.21-r2.ebuild
+++ b/dev-python/pycparser/pycparser-2.21-r2.ebuild
@@ -29,6 +29,11 @@ BDEPEND="
 distutils_enable_tests unittest
 
 python_prepare_all() {
+	local PATCHES=(
+		# https://github.com/eliben/pycparser/pull/494
+		"${FILESDIR}"/${P}-lextab-cache.patch
+	)
+
 	# remove the original files to guarantee their regen
 	rm pycparser/{c_ast,lextab,yacctab}.py || die
 


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-02-26 15:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-26 15:25 [gentoo-commits] repo/gentoo:master commit in: dev-python/pycparser/, dev-python/pycparser/files/ Michał Górny
  -- strict thread matches above, loose matches on Subject: below --
2017-08-27 18:07 Michał Górny

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox