[Cython] Failure with asarray(memoryview) on Python 2.4

Pauli Virtanen pav at iki.fi
Mon Jun 11 21:08:33 CEST 2012


Hi,

This doesn't work on Python 2.4 (works on >= 2.5):

------------
cimport numpy as np
import numpy as np

def _foo():
    cdef double[:] a
    a = np.array([1.0])
    return np.asarray(a)

def foo():
    print _foo()
------------

Spotted when using Cython 1.6 in Scipy. Results to:

Python 2.4.6 (#1, Nov 20 2010, 00:52:41)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import fail
>>> fail.foo()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "fail.pyx", line 10, in fail.foo (fail.c:1776)
    print _foo()
  File "fail.pyx", line 7, in fail._foo (fail.c:1715)
    return np.asarray(a)
  File
"/usr/local/stow/python-easy-install//lib/python2.4/site-packages/numpy/core/numeric.py",
line 235, in asarray
    return array(a, dtype, copy=False, order=order)
  File "stringsource", line 366, in
View.MemoryView.memoryview.__getitem__ (fail.c:5975)
  File "stringsource", line 650, in View.MemoryView._unellipsify
(fail.c:9236)
TypeError: Cannot index with type '<type 'int'>'



More information about the cython-devel mailing list