[pypy-issue] Issue #2101: cast float to bool spurious behaviour (pypy/pypy)

Richard Plangger issues-reply at bitbucket.org
Wed Jul 29 11:58:06 CEST 2015


New issue 2101: cast float to bool spurious behaviour
https://bitbucket.org/pypy/pypy/issues/2101/cast-float-to-bool-spurious-behaviour

Richard Plangger:

Related to #2087 float cast to bool is handled wrong in the JIT. Consider this example:

```
#!python
try:
    from _numpypy import multiarray as np
except ImportError:
    import numpy as np
a = np.array([0] * 100, dtype='float')
a[50] = 0.1
for i in range(10000):
    assert a.any()
```

Python 2.7.10 does not assert, whereas PyPy 2.6.0 does.
Problem: JIT emits cast_float_to_int, which cuts of the numbers after the comma. The right behavior would be to use float_is_ture. See 4fead7c7623f (jtransform.py & flatten.py)

Can someone confirm that this is the right solution?






More information about the pypy-issue mailing list