[pypy-svn] r74769 - in pypy/trunk/pypy/module/cpyext: . test

afa at codespeak.net afa at codespeak.net
Wed May 26 12:00:10 CEST 2010


Author: afa
Date: Wed May 26 12:00:09 2010
New Revision: 74769

Modified:
   pypy/trunk/pypy/module/cpyext/api.py
   pypy/trunk/pypy/module/cpyext/test/test_sliceobject.py
Log:
Expose PySlice_Type


Modified: pypy/trunk/pypy/module/cpyext/api.py
==============================================================================
--- pypy/trunk/pypy/module/cpyext/api.py	(original)
+++ pypy/trunk/pypy/module/cpyext/api.py	Wed May 26 12:00:09 2010
@@ -19,6 +19,7 @@
 from pypy.interpreter.gateway import ObjSpace, unwrap_spec
 from pypy.interpreter.nestedscope import Cell
 from pypy.interpreter.module import Module
+from pypy.objspace.std.sliceobject import W_SliceObject
 from pypy.module.__builtin__.descriptor import W_Property
 from pypy.rlib.entrypoint import entrypoint
 from pypy.rlib.unroll import unrolling_iterable
@@ -335,6 +336,7 @@
         'Cell': 'space.gettypeobject(Cell.typedef)',
         'Module': 'space.gettypeobject(Module.typedef)',
         'Property': 'space.gettypeobject(W_Property.typedef)',
+        'Slice': 'space.gettypeobject(W_SliceObject.typedef)',
         }.items():
         GLOBALS['Py%s_Type#' % (cpyname, )] = ('PyTypeObject*', pypyexpr)
 

Modified: pypy/trunk/pypy/module/cpyext/test/test_sliceobject.py
==============================================================================
--- pypy/trunk/pypy/module/cpyext/test/test_sliceobject.py	(original)
+++ pypy/trunk/pypy/module/cpyext/test/test_sliceobject.py	Wed May 26 12:00:09 2010
@@ -32,6 +32,10 @@
             ("clone", "METH_O",
              """
                  PySliceObject *slice = (PySliceObject *)args;
+                 if (slice->ob_type != &PySlice_Type) {
+                     PyErr_SetNone(PyExc_ValueError);
+                     return NULL;
+                 }
                  return PySlice_New(slice->start,
                                     slice->stop,
                                     slice->step);



More information about the Pypy-commit mailing list