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

afa at codespeak.net afa at codespeak.net
Fri Jun 4 22:12:28 CEST 2010


Author: afa
Date: Fri Jun  4 22:12:26 2010
New Revision: 75120

Modified:
   pypy/trunk/pypy/module/cpyext/sliceobject.py
   pypy/trunk/pypy/module/cpyext/test/test_sliceobject.py
Log:
PySlice_New() allows NULLs. Test and fix.


Modified: pypy/trunk/pypy/module/cpyext/sliceobject.py
==============================================================================
--- pypy/trunk/pypy/module/cpyext/sliceobject.py	(original)
+++ pypy/trunk/pypy/module/cpyext/sliceobject.py	Fri Jun  4 22:12:26 2010
@@ -56,6 +56,12 @@
     the same names.  Any of the values may be NULL, in which case the
     None will be used for the corresponding attribute.  Return NULL if
     the new object could not be allocated."""
+    if w_start is None:
+        w_start = space.w_None
+    if w_stop is None:
+        w_stop = space.w_None
+    if w_step is None:
+        w_step = space.w_None
     return W_SliceObject(w_start, w_stop, w_step)
 
 @cpython_api([PySliceObject, Py_ssize_t, Py_ssize_tP, Py_ssize_tP, Py_ssize_tP,

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	Fri Jun  4 22:12:26 2010
@@ -43,3 +43,12 @@
             ])
         s = slice(10, 20, 30)
         assert module.clone(s) == s
+
+    def test_nulls(self):
+        module = self.import_extension('foo', [
+            ("nullslice", "METH_NOARGS",
+             """
+                 return PySlice_New(NULL, NULL, NULL);
+             """),
+            ])
+        assert module.nullslice() == slice(None, None, None)



More information about the Pypy-commit mailing list