You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not sure if this is a bug. This kind of issues is not easy to avoid, using regexps for code transformations. Have you considered to use something like the pycparser?
Thanks for the project.
The text was updated successfully, but these errors were encountered:
This kind of issues is not easy to avoid, using regexps for code transformations. Have you considered to use something like the pycparser?
Many parsers cannot be used to modify source code, only to parse it. This project needs to modify the C code.
I know that the regex approach causes such surprising issues, but usually a very low number of lines is impacted, and it's quick to fix it by hand.
A better approach would be to use https://coccinelle.gitlabpages.inria.fr/website/ which is used in the Linux kernel for refactoring. It uses a DSL to match code and then replace code with an expression.
I tried to avoid a dependency to coccinelle to make the project easier to install (only need Python). If too many users complain, maybe I should consider moving to coccinelle.
vstinner
changed the title
Wrong transformations for Py_Is
upgrade_pythoncapi.py: Wrong transformations for Py_Is
Apr 4, 2024
I wondered if zig might offer a different path to allowing C source transformations without introducing a non-Python dependency, but ziglang/zig#2082 indicates that's not likely to be a viable option.
If the dual maintenance burden wouldn't be too bad, maybe coccinelle could be used if shutil.which finds it, and otherwise fall back to the existing regex based approach?
Consider an example:
After
upgrade_pythoncapi.py
I got:Real world example:
https://github.com/aleaxit/gmpy/blob/eb8dfcbd84abcfcb36b4adcb0d5c6d050731dd75/src/gmpy2_xmpz_misc.c#L237
I'm not sure if this is a bug. This kind of issues is not easy to avoid, using regexps for code transformations. Have you considered to use something like the pycparser?
Thanks for the project.
The text was updated successfully, but these errors were encountered: