[pypy-commit] pypy int_w-refactor: more reviewing of int_w(): conversions are not allowed here
antocuni
noreply at buildbot.pypy.org
Tue Feb 25 18:06:02 CET 2014
Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: int_w-refactor
Changeset: r69431:8a8a32a743e3
Date: 2014-02-25 17:41 +0100
http://bitbucket.org/pypy/pypy/changeset/8a8a32a743e3/
Log: more reviewing of int_w(): conversions are not allowed here
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -1217,7 +1217,7 @@
assert isinstance(w_index_or_slice, W_SliceObject)
start, stop, step = w_index_or_slice.indices3(self, seqlength)
else:
- start = self.int_w(w_index_or_slice)
+ start = self.int_w(w_index_or_slice, allow_conversion=False)
if start < 0:
start += seqlength
if not (0 <= start < seqlength):
diff --git a/pypy/module/array/test/test_array.py b/pypy/module/array/test/test_array.py
--- a/pypy/module/array/test/test_array.py
+++ b/pypy/module/array/test/test_array.py
@@ -1034,6 +1034,18 @@
assert len(b) == 13
assert str(b[12]) == "-0.0"
+ def test_getitem_only_ints(self):
+ class MyInt(object):
+ def __init__(self, x):
+ self.x = x
+
+ def __int__(self):
+ return self.x
+
+ a = self.array('i', [1, 2, 3, 4, 5, 6])
+ raises(TypeError, "a[MyInt(0)]")
+ raises(TypeError, "a[MyInt(0):MyInt(5)]")
+
class AppTestArrayBuiltinShortcut(AppTestArray):
spaceconfig = AppTestArray.spaceconfig.copy()
More information about the pypy-commit
mailing list