[pypy-commit] pypy default: fix list.pop with rangelists.
alex_gaynor
noreply at buildbot.pypy.org
Sat Oct 1 19:45:52 CEST 2011
Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch:
Changeset: r47755:117dc445ce1f
Date: 2011-10-01 13:45 -0400
http://bitbucket.org/pypy/pypy/changeset/117dc445ce1f/
Log: fix list.pop with rangelists.
diff --git a/pypy/objspace/std/rangeobject.py b/pypy/objspace/std/rangeobject.py
--- a/pypy/objspace/std/rangeobject.py
+++ b/pypy/objspace/std/rangeobject.py
@@ -23,7 +23,7 @@
class W_RangeListObject(W_Object):
typedef = listtype.list_typedef
-
+
def __init__(w_self, start, step, length):
assert step != 0
w_self.start = start
@@ -40,7 +40,7 @@
if not length:
w_self.w_list = space.newlist([])
return w_self.w_list
-
+
arr = [None] * length # this is to avoid using append.
i = start
@@ -146,7 +146,11 @@
if length == 0:
raise OperationError(space.w_IndexError,
space.wrap("pop from empty list"))
- idx = space.int_w(w_idx)
+ if space.isinstance_w(w_idx, space.w_float):
+ raise OperationError(space.w_TypeError,
+ space.wrap("integer argument expected, got float")
+ )
+ idx = space.int_w(space.int(w_idx))
if idx == 0:
result = w_rangelist.start
w_rangelist.start += w_rangelist.step
diff --git a/pypy/rpython/lltypesystem/rlist.py b/pypy/rpython/lltypesystem/rlist.py
--- a/pypy/rpython/lltypesystem/rlist.py
+++ b/pypy/rpython/lltypesystem/rlist.py
@@ -1,15 +1,15 @@
+from pypy.rlib import rgc, jit
+from pypy.rlib.debug import ll_assert
+from pypy.rlib.objectmodel import enforceargs
+from pypy.rpython.lltypesystem import rstr
+from pypy.rpython.lltypesystem.lltype import (GcForwardReference, Ptr, GcArray,
+ GcStruct, Void, Signed, malloc, typeOf, nullptr, typeMethod)
+from pypy.rpython.rlist import (AbstractBaseListRepr, AbstractListRepr,
+ AbstractFixedSizeListRepr, AbstractListIteratorRepr, ll_setitem_nonneg,
+ ADTIList, ADTIFixedList, dum_nocheck)
+from pypy.rpython.rmodel import Repr, inputconst, externalvsinternal
from pypy.tool.pairtype import pairtype, pair
-from pypy.rpython.rmodel import Repr, inputconst
-from pypy.rpython.rmodel import externalvsinternal
-from pypy.rpython.rlist import AbstractBaseListRepr, AbstractListRepr, \
- AbstractFixedSizeListRepr, AbstractListIteratorRepr, \
- ll_setitem_nonneg, ADTIList, ADTIFixedList
-from pypy.rpython.rlist import dum_nocheck
-from pypy.rpython.lltypesystem.lltype import GcForwardReference, Ptr, GcArray,\
- GcStruct, Void, Signed, malloc, typeOf, nullptr, typeMethod
-from pypy.rpython.lltypesystem import rstr
-from pypy.rlib.debug import ll_assert
-from pypy.rlib import rgc, jit
+
# ____________________________________________________________
#
@@ -171,6 +171,7 @@
# adapted C code
+ at enforceargs(None, int)
def _ll_list_resize_really(l, newsize):
"""
Ensure l.items has room for at least newsize elements, and set
@@ -210,7 +211,6 @@
rgc.ll_arraycopy(items, newitems, 0, 0, p)
l.length = newsize
l.items = newitems
-_ll_list_resize_really._annenforceargs_ = (None, int)
# this common case was factored out of _ll_list_resize
# to see if inlining it gives some speed-up.
More information about the pypy-commit
mailing list