Status: Accepted
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 2832 by [email protected]: bool(Relational) should raise ValueError
http://code.google.com/p/sympy/issues/detail?id=2832

This has been discussed before, but I didn't find an explicit issue for it, so here it is.

This is very closely related to issue 1887, and I kind of doubt it can be fixed correctly without fixing that first.

There are some places in the code with tests like

if x > 3:
   do stuff

implicitly assuming x is a number. But if x is a Symbol, which is all to easy to pass to a function in SymPy, this will silently work:

In [17]: bool(x > 3)
Out[17]: True

Thus, we have problems like issue 1740.

I think that we should make bool(Relational) raise ValueError, unless we can explicitly determine from the assumptions if it is True or False (in other words, if the assumptions give None, raise an error). This will prevent hidden bugs like the above, and will also fit in with the Python 3 standard that you should not be able to compare incomparable types.

See also the discussion at https://github.com/sympy/sympy/pull/695#issuecomment-2651875.

--
You received this message because you are subscribed to the Google Groups 
"sympy-issues" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy-issues?hl=en.

Reply via email to