[pypy-svn] r4964 - pypy/branch/src-newobjectmodel/pypy/objspace/std

mwh at codespeak.net mwh at codespeak.net
Sat Jun 5 15:03:24 CEST 2004


Author: mwh
Date: Sat Jun  5 15:03:24 2004
New Revision: 4964

Modified:
   pypy/branch/src-newobjectmodel/pypy/objspace/std/sliceobject.py
   pypy/branch/src-newobjectmodel/pypy/objspace/std/slicetype.py
Log:
modernize slices


Modified: pypy/branch/src-newobjectmodel/pypy/objspace/std/sliceobject.py
==============================================================================
--- pypy/branch/src-newobjectmodel/pypy/objspace/std/sliceobject.py	(original)
+++ pypy/branch/src-newobjectmodel/pypy/objspace/std/sliceobject.py	Sat Jun  5 15:03:24 2004
@@ -19,24 +19,4 @@
 
 registerimplementation(W_SliceObject)
 
-
-def getattr__Slice_ANY(space, w_slice, w_attr):
-    # XXX later
-    if space.is_true(space.eq(w_attr, space.wrap('start'))):
-        if w_slice.w_start is None:
-            return space.w_None
-        else:
-            return w_slice.w_start
-    if space.is_true(space.eq(w_attr, space.wrap('stop'))):
-        if w_slice.w_stop is None:
-            return space.w_None
-        else:
-            return w_slice.w_stop
-    if space.is_true(space.eq(w_attr, space.wrap('step'))):
-        if w_slice.w_step is None:
-            return space.w_None
-        else:
-            return w_slice.w_step
-    raise FailedToImplement(space.w_AttributeError)
-
 register_all(vars())

Modified: pypy/branch/src-newobjectmodel/pypy/objspace/std/slicetype.py
==============================================================================
--- pypy/branch/src-newobjectmodel/pypy/objspace/std/slicetype.py	(original)
+++ pypy/branch/src-newobjectmodel/pypy/objspace/std/slicetype.py	Sat Jun  5 15:03:24 2004
@@ -1,6 +1,7 @@
 from pypy.objspace.std.stdtypedef import *
 from pypy.objspace.std.objecttype import object_typedef
 from pypy.objspace.std.register_all import register_all
+from pypy.interpreter.error import OperationError
 
 slice_indices = MultiMethod('indices', 2)
 
@@ -90,7 +91,7 @@
         w_start, w_stop = args_w
     elif len(args_w) == 3:
         w_start, w_stop, w_step = args_w
-    elif len(args) > 3:
+    elif len(args_w) > 3:
         raise OperationError(space.w_TypeError,
                              space.wrap("slice() takes at most 3 arguments"))
     else:
@@ -103,5 +104,8 @@
 
 slice_typedef = StdTypeDef("slice", [object_typedef],
     __new__ = newmethod(descr__new__),
+    start = attrproperty_w('w_start'),
+    stop  = attrproperty_w('w_stop'),
+    step  = attrproperty_w('w_step'),
     )
 slice_typedef.registermethods(globals())



More information about the Pypy-commit mailing list