-
Notifications
You must be signed in to change notification settings - Fork 81
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
Handling reserved Python words in f90wrap #157
Comments
I obtained a working solution by having f90wrap's fortran code generator completely ignore the renaming of types with reserved keywords (supposedly handled by f2py) and using .orig_name everywhere; what worked is when I got f90wrap's pywrapgen to implement the renaming of classes. However, I had to manually change source code for pywrapgen.py in the beginning of
Then normalize the class name after filtering out reserved keywords |
That looks like an OK solution. Does f90wrap still pass all the regression tests? ( |
Sure, I can make the PR after running the tests. Fingers crossed... |
Edit: nvm, found that I had to change @jameskermode it seems that some of the tests fail on master: the arrayderivedtype test failed on the master branch (i.e., without any of my changes) with the following error
|
so all the default tests passed with my changes (good). Added a new test on my fork and making it more complex. |
@jameskermode I've submitted a PR with another test. There are edge cases like when a user creates an array of a derived type called |
@jameskermode I'm working with a legacy code that unfortunately has a derived type called "Size" (and for other reasons, I'm not allowed to rename it). Unfortunately, f90wrap does not seem to be able to auto-rename size to size_bn (as suggested by f2py).
I got far enough into f90wrap source to identify what appears to be a bug in f90wrapgen.py, line 785 ish. The dictionary key for self.types in RenameReservedWords still retains the name size, but the extra_uses invocation is
extra_uses[self.types[t.name].mod_name] = [t.name]
The entry t.name is not present in self.types, so I added a try/except to use t.orig_name on if the first one fails; would appreciate some guidance on whether it should also appear on the right hand side? I haven't fully tracked it down..
I tried this fix and it proceeded all the way to invoking f2py, at which point f2py complains that size_bn is being used before it is declared.. any help/pointers would be appreciated! I'm mostly stuck at figuring out where the derived type is renamed in the module before being compiled; I can "see" the individual elements in the derived type being renamed.
The text was updated successfully, but these errors were encountered: