Author: Manuel Jacob
Branch: remove-list-smm-2
Changeset: r64319:394ccea84eb4
Date: 2013-05-18 14:05 +0200
http://bitbucket.org/pypy/pypy/changeset/394ccea84eb4/

Log:    Move get_positive_index() into util.py.

diff --git a/pypy/objspace/std/bytearrayobject.py 
b/pypy/objspace/std/bytearrayobject.py
--- a/pypy/objspace/std/bytearrayobject.py
+++ b/pypy/objspace/std/bytearrayobject.py
@@ -8,7 +8,6 @@
     getbytevalue, makebytearraydata_w, new_bytearray)
 from pypy.objspace.std.intobject import W_IntObject
 from pypy.objspace.std.inttype import wrapint
-from pypy.objspace.std.listobject import get_positive_index
 from pypy.objspace.std.model import W_Object, registerimplementation
 from pypy.objspace.std.multimethod import FailedToImplement
 from pypy.objspace.std.noneobject import W_NoneObject
@@ -17,6 +16,7 @@
 from pypy.objspace.std.stringobject import W_StringObject
 from pypy.objspace.std.tupleobject import W_TupleObject
 from pypy.objspace.std.unicodeobject import W_UnicodeObject
+from pypy.objspace.std.util import get_positive_index
 from rpython.rlib.rstring import StringBuilder
 
 
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
@@ -10,7 +10,7 @@
 from pypy.objspace.std.inttype import wrapint
 from pypy.objspace.std.sliceobject import W_SliceObject, normalize_simple_slice
 from pypy.objspace.std.stdtypedef import StdTypeDef
-from pypy.objspace.std.util import negate
+from pypy.objspace.std.util import negate, get_positive_index
 from rpython.rlib import rerased, jit, debug
 from rpython.rlib.listsort import make_timsort_class
 from rpython.rlib.objectmodel import (instantiate, newlist_hint, specialize,
@@ -1604,16 +1604,6 @@
 
 listrepr = app.interphook("listrepr")
 
-def get_positive_index(where, length):
-    if where < 0:
-        where += length
-        if where < 0:
-            where = 0
-    elif where > length:
-        where = length
-    assert where >= 0
-    return where
-
 # ____________________________________________________________
 # Sorting
 
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
@@ -16,3 +16,12 @@
     _negator.func_name = 'negate-%s' % f.func_name
     return _negator
 
+def get_positive_index(where, length):
+    if where < 0:
+        where += length
+        if where < 0:
+            where = 0
+    elif where > length:
+        where = length
+    assert where >= 0
+    return where
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to