New issue 2533: Error
https://bitbucket.org/pypy/pypy/issues/2533/error

rowillia:

Minimal repro: Works in CPython, fails in PyPy -

```python
#  requires rtree==0.8.3
from rtree import index
def generator():
     yield (0, (0.0, 0.0, 1.0, 1.0), {'id': '1', 'polygon': 'hello'})

idx = index.Index(generator())
```

Exception in PyPy:
```
  File "/usr/lib/pypy/lib_pypy/_ctypes/function.py", line 280, in f
    return to_call(*args)
  File "/usr/local/lib/service_venv_pypy/site-packages/rtree/index.py", line 
713, in py_next_item
    p_mins[0] = ctypes.cast(mins, ctypes.POINTER(ctypes.c_double))
  File "/usr/lib/pypy/lib_pypy/_ctypes/pointer.py", line 116, in __setitem__
    store_reference(self, index, cobj._objects)
  File "/usr/lib/pypy/lib_pypy/_ctypes/basics.py", line 23, in store_reference
    while '_index' in where.__dict__:
AttributeError: 'NoneType' object has no attribute '__dict__'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/service_venv_pypy/site-packages/rtree/index.py", line 
264, in __init__
    self.handle = self._create_idx_from_stream(stream)
  File "/usr/local/lib/service_venv_pypy/site-packages/rtree/index.py", line 
728, in _create_idx_from_stream
    return IndexStreamHandle(self.properties.handle, stream)
  File "/usr/local/lib/service_venv_pypy/site-packages/rtree/index.py", line 
854, in __init__
    self._ptr = self._create(*args, **kwargs)
  File "/usr/lib/pypy/lib_pypy/_ctypes/function.py", line 720, in __call__
    return CFuncPtr.__call__(self, *args)
  File "/usr/lib/pypy/lib_pypy/_ctypes/function.py", line 354, in __call__
    result, forced = self._do_errcheck(result, errcheckargs)
  File "/usr/lib/pypy/lib_pypy/_ctypes/function.py", line 398, in _do_errcheck
    v = self._errcheck_(result, self, tuple(args))
  File "/usr/local/lib/service_venv_pypy/site-packages/rtree/core.py", line 28, 
in check_void
    raise RTreeError(msg)
RTreeError: Error in "Index_CreateWithStream": IllegalArgumentException: 
Region::combineRegion: Region has different number of dimensions.
```


RTree has an issue open leading me to believe this is the real exception:
```
  File "/usr/lib/pypy/lib_pypy/_ctypes/function.py", line 280, in f
    return to_call(*args)
  File "/usr/local/lib/service_venv_pypy/site-packages/rtree/index.py", line 
713, in py_next_item
    p_mins[0] = ctypes.cast(mins, ctypes.POINTER(ctypes.c_double))
  File "/usr/lib/pypy/lib_pypy/_ctypes/pointer.py", line 116, in __setitem__
    store_reference(self, index, cobj._objects)
  File "/usr/lib/pypy/lib_pypy/_ctypes/basics.py", line 23, in store_reference
    while '_index' in where.__dict__:
AttributeError: 'NoneType' object has no attribute '__dict__'
```

Here is the snipped of code that's failing:
https://github.com/Toblerity/rtree/blob/master/rtree/index.py#L713

```python
darray = ctypes.c_double * dimension
mins = darray()
maxs = darray()
....
for i in range(dimension):
    mins[i] = coordinates[i*2]
    maxs[i] = coordinates[(i*2)+1]

p_mins[0] = ctypes.cast(mins, ctypes.POINTER(ctypes.c_double))  # Fails in 
PyPy, not CPython
```



Version Info:
```
$ python -V
Python 2.7.12 (5.6.0+dfsg-0~ppa2~ubuntu14.04, Nov 11 2016, 17:08:28)
[PyPy 5.6.0 with GCC 4.8.4]
```


_______________________________________________
pypy-issue mailing list
pypy-issue@python.org
https://mail.python.org/mailman/listinfo/pypy-issue

Reply via email to