[pypy-commit] pypy flow-no-local-exception: Fix: had double-negative-detection in one path
arigo
noreply at buildbot.pypy.org
Thu Aug 8 12:19:44 CEST 2013
Author: Armin Rigo <arigo at tunes.org>
Branch: flow-no-local-exception
Changeset: r66010:96a686aaa962
Date: 2013-08-08 12:19 +0200
http://bitbucket.org/pypy/pypy/changeset/96a686aaa962/
Log: Fix: had double-negative-detection in one path
diff --git a/pypy/objspace/std/listobject.py b/pypy/objspace/std/listobject.py
--- a/pypy/objspace/std/listobject.py
+++ b/pypy/objspace/std/listobject.py
@@ -28,7 +28,7 @@
from pypy.objspace.std.tupleobject import W_AbstractTupleObject
from pypy.objspace.std.unicodeobject import W_UnicodeObject
from pypy.objspace.std.util import get_positive_index, negate
-from pypy.objspace.std.util import ListIndexError, getuindex
+from pypy.objspace.std.util import ListIndexError, getuindex, getuindex_nonneg
from rpython.rlib import debug, jit, rerased
from rpython.rlib.listsort import make_timsort_class
from rpython.rlib.objectmodel import (
@@ -1427,7 +1427,7 @@
def pop(self, w_list, index):
l = self.unerase(w_list.lstorage)
- uindex = getuindex(l, index)
+ uindex = getuindex_nonneg(l, index)
item = l.pop(uindex)
w_item = self.wrap(item)
return w_item
diff --git a/pypy/objspace/std/util.py b/pypy/objspace/std/util.py
--- a/pypy/objspace/std/util.py
+++ b/pypy/objspace/std/util.py
@@ -34,6 +34,13 @@
"""A custom RPython class, raised by getitem() and similar methods
from listobject.py, and from getuindex() below."""
+def getuindex_nonneg(lst, index):
+ ulength = len(lst)
+ uindex = r_uint(index)
+ if uindex >= ulength:
+ raise ListIndexError
+ return uindex
+
def getuindex(lst, index):
ulength = r_uint(len(lst))
uindex = r_uint(index)
More information about the pypy-commit
mailing list