Index: __builtin__.java =================================================================== --- __builtin__.java (revision 3355) +++ __builtin__.java (working copy) @@ -2,6 +2,7 @@ package org.python.core; import java.util.Hashtable; +import java.util.Vector; class BuiltinFunctions extends PyBuiltinFunctionSet { @@ -39,7 +40,7 @@ case 1: return Py.newInteger(__builtin__.len(arg1)); case 2: - return __builtin__.range(Py.py2int(arg1, "range(): 1st arg can't be coerced to int")); + return __builtin__.range(Py.py2long(arg1)); case 3: return Py.newInteger(__builtin__.ord(Py.py2char(arg1, "ord(): 1st arg can't be coerced to char"))); case 5: @@ -113,8 +114,7 @@ public PyObject __call__(PyObject arg1, PyObject arg2) { switch (this.index) { case 2: - return __builtin__.range(Py.py2int(arg1, "range(): 1st arg can't be coerced to int"), Py.py2int(arg2, - "range(): 2nd arg can't be coerced to int")); + return __builtin__.range(Py.py2long(arg1 ), Py.py2long(arg2)); case 6: return Py.newInteger(__builtin__.cmp(arg1, arg2)); case 9: @@ -175,9 +175,7 @@ public PyObject __call__(PyObject arg1, PyObject arg2, PyObject arg3) { switch (this.index) { case 2: - return __builtin__.range(Py.py2int(arg1, "range(): 1st arg can't be coerced to int"), Py.py2int(arg2, - "range(): 2nd arg can't be coerced to int"), Py.py2int(arg3, - "range(): 3rd arg can't be coerced to int")); + return __builtin__.range(Py.py2long(arg1), Py.py2long(arg2), Py.py2long(arg3)); case 9: try { if (arg3 instanceof PyStringMap) { @@ -875,11 +873,11 @@ throw Py.TypeError("__pow__ not defined for these operands"); } - public static PyObject range(int start, int stop, int step) { + public static PyObject range(long start, long stop, long step) { if (step == 0) { throw Py.ValueError("zero step for range()"); } - int n; + long n; if (step > 0) { n = (stop - start + step - 1) / step; } else { @@ -888,20 +886,22 @@ if (n <= 0) { return new PyList(); } - PyObject[] l = new PyObject[n]; - int j = start; + + Vector l = new Vector(); + long j = start; + for (int i = 0; i < n; i++) { - l[i] = Py.newInteger(j); + l.add( Py.newInteger(j)); j += step; } return new PyList(l); } - public static PyObject range(int n) { + public static PyObject range(long n) { return range(0, n, 1); } - public static PyObject range(int start, int stop) { + public static PyObject range(long start, long stop) { return range(start, stop, 1); }