Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: _generate_type() got an unexpected keyword argument 'emit_declname' #48

Open
zehanort opened this issue Mar 19, 2020 · 2 comments

Comments

@zehanort
Copy link

zehanort commented Mar 19, 2020

I am using pycparserext to parse, edit and then re-generate OpenCL kernels. During the re-generation phase, with some kernels, I get the following error:

File "<path>/test.py", line 131, in instrument_file
    f.write(gen.visit(ast))
File "<path>/env/lib/python3.7/site-packages/pycparser/c_generator.py", line 28, in visit
    return getattr(self, method, self.generic_visit)(node)
File "<path>/env/lib/python3.7/site-packages/pycparserext/ext_c_generator.py", line 155, in visit_FileAST
    s += self.visit(ext)
File "<path>/env/lib/python3.7/site-packages/pycparser/c_generator.py", line 28, in visit
    return getattr(self, method, self.generic_visit)(node)

... (long list of calls here) ...

File "<path>/env/lib/python3.7/site-packages/pycparser/c_generator.py", line 122, in visit_Cast
    s = '(' + self._generate_type(n.to_type, emit_declname=False) + ')'
TypeError: _generate_type() got an unexpected keyword argument 'emit_declname'

This error happens only when a call to visit_Cast occurs somewhere along the way.
Whats more, the only place where pycparserext is being used (and not pycparser) seems to be the second call in the trace above. Note that gen comes from pycparserext. From somewhere near the start of my script:

from pycparserext.ext_c_generator import OpenCLCGenerator
...
gen = OpenCLCGenerator()

It seems to me that your _generate_type() is called and not the one from pycparser, despite the fact that the trace says otherwise, given that it is the implementation of _generate_type() from pycparserext (and not from pycparser) that does not have the keyword argument emit_declname.

@zehanort
Copy link
Author

I downgraded pycparser from version 2.20 to 2.19 and it worked. Problem is that the version of pycparserext that is available from pip does not forbid version 2.20 of pycparser, something that you have added in your latest commit.

Please feel free to leave the issue open or close it.

@inducer
Copy link
Owner

inducer commented Mar 20, 2020

Released 2020.1 to the package index that includes the version hint on pycparser. I'll leave this open since, at some point, the incompatibility with 2.20 will need to get resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants