Importing symtable causes traceback
I am trying to run the Roundup Issue Tracker under PyPy. Part of the code uses the symtable module. When trying to import it I get:
$ pypy3 -c 'import symtable'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/opt/pypy/lib-python/3/symtable.py", line 3, in <module>
import _symtable
This is with a dockerized version of PyPY:
% pypy -V
Python 3.7.12 (44db26267d0a, Oct 24 2021, 14:21:50)
[PyPy 7.3.7 with GCC 7.3.1 20180303 (Red Hat 7.3.1-5)]
The code is used by Zope Page Templates (ZPT). I think it's using the Python interpreter to exec Python expressions in the templates then using has_children() and get_children() to recursively walk the expression pulling out variable values.
This code in PythonExpr.py looks like the use cases:
def _get_from_symtab(self):
"""
Get the variables used in the 'f' function.
"""
variables = set()
table = symtable.symtable(self.f_code, "<string>", "exec")
if table.has_children():
variables.update(self._walk_children(table))
return variables
def _walk_children(self, sym):
"""
Get the variables at this level. Recurse to get them all.
"""
variables = set()
for child in sym.get_children():
variables.update(set(child.get_identifiers()))
if child.has_children():
variables.update(self._walk_children(child))
return variables
I brought this up on irc #pypy and cfboltz recommended opening an issue.