oracle / graalpython

GraalPy – A high-performance embeddable Python 3 runtime for Java
https://www.graalvm.org/python/
Other
1.24k stars 108 forks source link

TypeError when calling numpy.loadtxt with default max_rows parameter (GraalVM CE 21.0.0) #201

Closed d-leroy closed 3 years ago

d-leroy commented 3 years ago

Calling numpy.loadtxt without specifying the optional max_rows parameter results in TypeError.

Example program:

import sys
import numpy

filename = 'test_max_rows'
fic = open(filename,'w')

for i in range(10):
    fic.write("1 2 3 4\n")

fic.flush()

#Works
a = numpy.loadtxt(filename, max_rows=10)
print(a)

#Crashes with TypeError: 'NoneType' object cannot be interpreted as an int
b = numpy.loadtxt(filename)
print(b)

The complete trace is: File "venv-graalpython/lib/python3.8/site-packages/numpy-1.16.4-py3.8-linux-x86_64.egg/numpy/lib/npyio.py", line 1141, in loadtxt for x in read_data(_loadtxt_chunksize): File "venv-graalpython/lib/python3.8/site-packages/numpy-1.16.4-py3.8-linux-x86_64.egg/numpy/lib/npyio.py", line 1055, in read_data line_iter = itertools.islice(line_iter, max_rows) TypeError: 'NoneType' object cannot be interpreted as an int

msimacek commented 3 years ago

Hi @d-leroy, thank you for the report. The problem is reproducible on the released version, but it seems it already fixed on our master - I couldn't reproduce the problem with the latest snapshot, so I believe it is already fixed. You can try using the snapshot from https://github.com/graalvm/graalvm-ce-dev-builds/releases/ (graalpython-dev-linux-amd64.tar.gz)