[Python-checkins] r54178 - in python/branches/release25-maint: Lib/test/test_operator.py Misc/NEWS Modules/operator.c

georg.brandl python-checkins at python.org
Tue Mar 6 20:00:10 CET 2007


Author: georg.brandl
Date: Tue Mar 6 20:00:09 2007
New Revision: 54178
Modified:
 python/branches/release25-maint/Lib/test/test_operator.py
 python/branches/release25-maint/Misc/NEWS
 python/branches/release25-maint/Modules/operator.c
Log:
Patch #1654417: make operator.{get,set,del}slice use the full range
of Py_ssize_t.
 (backport from rev. 54177)
Modified: python/branches/release25-maint/Lib/test/test_operator.py
==============================================================================
--- python/branches/release25-maint/Lib/test/test_operator.py	(original)
+++ python/branches/release25-maint/Lib/test/test_operator.py	Tue Mar 6 20:00:09 2007
@@ -143,6 +143,8 @@
 self.failUnlessRaises(TypeError, operator.delslice, a, None, None)
 self.failUnless(operator.delslice(a, 2, 8) is None)
 self.assert_(a == [0, 1, 8, 9])
+ operator.delslice(a, 0, test_support.MAX_Py_ssize_t)
+ self.assert_(a == [])
 
 def test_div(self):
 self.failUnlessRaises(TypeError, operator.div, 5)
@@ -170,6 +172,8 @@
 self.failUnlessRaises(TypeError, operator.getslice)
 self.failUnlessRaises(TypeError, operator.getslice, a, None, None)
 self.failUnless(operator.getslice(a, 4, 6) == [4, 5])
+ b = operator.getslice(a, 0, test_support.MAX_Py_ssize_t)
+ self.assert_(b == a)
 
 def test_indexOf(self):
 self.failUnlessRaises(TypeError, operator.indexOf)
@@ -318,6 +322,8 @@
 self.failUnlessRaises(TypeError, operator.setslice, a, None, None, None)
 self.failUnless(operator.setslice(a, 1, 3, [2, 1]) is None)
 self.assert_(a == [0, 2, 1, 3])
+ operator.setslice(a, 0, test_support.MAX_Py_ssize_t, [])
+ self.assert_(a == [])
 
 def test_sub(self):
 self.failUnlessRaises(TypeError, operator.sub)
Modified: python/branches/release25-maint/Misc/NEWS
==============================================================================
--- python/branches/release25-maint/Misc/NEWS	(original)
+++ python/branches/release25-maint/Misc/NEWS	Tue Mar 6 20:00:09 2007
@@ -120,6 +120,9 @@
 Extension Modules
 -----------------
 
+- Patch #1654417: make operator.{get,set,del}slice use the full range
+ of Py_ssize_t.
+
 - Patch #1646728: datetime.fromtimestamp fails with negative
 fractional times. With unittest.
 
Modified: python/branches/release25-maint/Modules/operator.c
==============================================================================
--- python/branches/release25-maint/Modules/operator.c	(original)
+++ python/branches/release25-maint/Modules/operator.c	Tue Mar 6 20:00:09 2007
@@ -168,43 +168,41 @@
 op_getslice(PyObject *s, PyObject *a)
 {
 PyObject *a1;
- int a2,a3;
+ Py_ssize_t a2, a3;
 
- if (!PyArg_ParseTuple(a,"Oii:getslice",&a1,&a2,&a3))
+ if (!PyArg_ParseTuple(a, "Onn:getslice", &a1, &a2, &a3))
 return NULL;
- return PySequence_GetSlice(a1,a2,a3);
+ return PySequence_GetSlice(a1, a2, a3);
 }
 
 static PyObject*
 op_setslice(PyObject *s, PyObject *a)
 {
 PyObject *a1, *a4;
- int a2,a3;
+ Py_ssize_t a2, a3;
 
- if (!PyArg_ParseTuple(a,"OiiO:setslice",&a1,&a2,&a3,&a4))
+ if (!PyArg_ParseTuple(a, "OnnO:setslice", &a1, &a2, &a3, &a4))
 return NULL;
 
- if (-1 == PySequence_SetSlice(a1,a2,a3,a4))
+ if (-1 == PySequence_SetSlice(a1, a2, a3, a4))
 return NULL;
 
- Py_INCREF(Py_None);
- return Py_None;
+	Py_RETURN_NONE;
 }
 
 static PyObject*
 op_delslice(PyObject *s, PyObject *a)
 {
 PyObject *a1;
- int a2,a3;
+ Py_ssize_t a2, a3;
 
- if(! PyArg_ParseTuple(a,"Oii:delslice",&a1,&a2,&a3))
+ if (!PyArg_ParseTuple(a, "Onn:delslice", &a1, &a2, &a3))
 return NULL;
 
- if (-1 == PySequence_DelSlice(a1,a2,a3))
+ if (-1 == PySequence_DelSlice(a1, a2, a3))
 return NULL;
 
- Py_INCREF(Py_None);
- return Py_None;
+	Py_RETURN_NONE;
 }
 
 #undef spam1


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /