-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
Sympy incorrectly attempts to eval reprs in its __eq__ method #18056
Comments
…Number (#2655) - Reorder the sympy checks to come before generic number checks - Rename json.py to json_serialization.py to avoid collisions with the built-in json library - Detect integral values when deserializing symbolic protos, so that x - y does not become x - 1.0*y. - Pin to 1.4 until sympy/sympy#18056 is fixed Fixes #2650 Fixes #2646
See also #12524 |
Safe flag or no, == should call _sympify since an expression shouldn't equal a string. I also think we should deprecate the string fallback in sympify. It has led to serious performance issues in the past and clearly has security issues as well. |
Actually, it looks like we also have
which is a major regression since 1.4. I bisected it to 73caef3. The bug in the issue doesn't exist in 1.4 either. So we could consider doing a 1.5.1 release fixing this. |
The thing is, I could have swore this behavior was tested. But I don't see anything in the test changes from #16924 about string comparisons. |
This also avoids some major security/performance issues that could happen by trying to convert the rhs of an == to a string. Fixes sympy#18056.
I suspect this change can also lead to major performance issues as well. |
Yeah, there is. SymPy 1.4
SymPy 1.5
So we should probably do a patch release. @oscarbenjamin |
Agreed. |
I'm pretty sure the author had no appreciation for theses implications when adding the code ;-) |
Well we need to deprecate the string fallback in sympify. This isn't the first time it's bitten performance, and I wouldn't be surprised if there are latent issues with it elsewhere. We also should phase out the use of strict=False |
Sympy v1.5.1 is now available, fixes sympy/sympy#18056.
Sympy v1.5.1 is now available, fixes sympy/sympy#18056. See https://github.com/sympy/sympy/releases/tag/sympy-1.5.1 & changelog: https://github.com/sympy/sympy/wiki/Release-Notes-for-1.5.1 Ref: #2648 #2655
I think that default_sort_key internally calls |
Passing strings produced by unknown objects into eval is very bad. It is especially surprising for an equality check to trigger that kind of behavior. This should be fixed ASAP.
Repro code:
Results in:
On the line:
Where code is:
Full trace:
Related issue: an unknown object whose repr is
x
will incorrectly compare as equal to a sympy symbol x:The text was updated successfully, but these errors were encountered: