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
Fix PyInteger / float division #6195
base: master
Are you sure you want to change the base?
Conversation
This was broken due to changes to type inference. It infers the type as a double, but "py_operations" for binops need to have a Python result. Therefore I've separated into a two step: * calculate Python result * coerce to known C type. In principle Optimize.c could take this back to 1 step. But at the moment it doesn't. Fixes cython#6183 Fixes cython#6004
@@ -187,6 +187,8 @@ def arithmetic(): | |||
assert typeof(f) == "long", typeof(f) | |||
g = 4 // <int>2 | |||
assert typeof(g) == "long", typeof(g) | |||
h = int(2) / 3.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR changes also other operators (e.g. *
). They are not tested here. Should not be added here?
Implementation seems OK (but I cannot tell for 100%). I added just one comment regarding tests. |
Did you mean the transforms in |
Yes I do mean the transforms in
Yes I think you're probably right. We've only had complaints about |
This was broken due to changes to type inference. It infers the type as a double, but "py_operations" for binops need to have a Python result. Therefore I've separated into a two step:
In principle Optimize.c could take this back to 1 step. But at the moment it doesn't.
Fixes #6183
Fixes #6004