[Python-checkins] r53041 - in python/branches/p3yk-noslice: Modules/mmapmodule.c Objects/bufferobject.c Objects/bytesobject.c Objects/stringobject.c Objects/typeobject.c Objects/unicodeobject.c Objects/weakrefobject.c Python/Python-ast.c

thomas.wouters python-checkins at python.org
Fri Dec 15 05:37:14 CET 2006


Author: thomas.wouters
Date: Fri Dec 15 05:37:10 2006
New Revision: 53041

Modified:
   python/branches/p3yk-noslice/Modules/mmapmodule.c
   python/branches/p3yk-noslice/Objects/bufferobject.c
   python/branches/p3yk-noslice/Objects/bytesobject.c
   python/branches/p3yk-noslice/Objects/stringobject.c
   python/branches/p3yk-noslice/Objects/typeobject.c
   python/branches/p3yk-noslice/Objects/unicodeobject.c
   python/branches/p3yk-noslice/Objects/weakrefobject.c
   python/branches/p3yk-noslice/Python/Python-ast.c
Log:

Throw away now-unused functions (and the warnings about same.)



Modified: python/branches/p3yk-noslice/Modules/mmapmodule.c
==============================================================================
--- python/branches/p3yk-noslice/Modules/mmapmodule.c	(original)
+++ python/branches/p3yk-noslice/Modules/mmapmodule.c	Fri Dec 15 05:37:10 2006
@@ -663,24 +663,6 @@
 }
 
 static PyObject *
-mmap_slice(mmap_object *self, Py_ssize_t ilow, Py_ssize_t ihigh)
-{
-	CHECK_VALID(NULL);
-	if (ilow < 0)
-		ilow = 0;
-	else if ((size_t)ilow > self->size)
-		ilow = self->size;
-	if (ihigh < 0)
-		ihigh = 0;
-	if (ihigh < ilow)
-		ihigh = ilow;
-	else if ((size_t)ihigh > self->size)
-		ihigh = self->size;
-
-	return PyString_FromStringAndSize(self->data + ilow, ihigh-ilow);
-}
-
-static PyObject *
 mmap_subscript(mmap_object *self, PyObject *item)
 {
 	CHECK_VALID(NULL);
@@ -753,45 +735,6 @@
 }
 
 static int
-mmap_ass_slice(mmap_object *self, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *v)
-{
-	const char *buf;
-
-	CHECK_VALID(-1);
-	if (ilow < 0)
-		ilow = 0;
-	else if ((size_t)ilow > self->size)
-		ilow = self->size;
-	if (ihigh < 0)
-		ihigh = 0;
-	if (ihigh < ilow)
-		ihigh = ilow;
-	else if ((size_t)ihigh > self->size)
-		ihigh = self->size;
-
-	if (v == NULL) {
-		PyErr_SetString(PyExc_TypeError,
-				"mmap object doesn't support slice deletion");
-		return -1;
-	}
-	if (! (PyString_Check(v)) ) {
-		PyErr_SetString(PyExc_IndexError,
-				"mmap slice assignment must be a string");
-		return -1;
-	}
-	if (PyString_Size(v) != (ihigh - ilow)) {
-		PyErr_SetString(PyExc_IndexError,
-				"mmap slice assignment is wrong size");
-		return -1;
-	}
-	if (!is_writeable(self))
-		return -1;
-	buf = PyString_AsString(v);
-	memcpy(self->data + ilow, buf, ihigh-ilow);
-	return 0;
-}
-
-static int
 mmap_ass_item(mmap_object *self, Py_ssize_t i, PyObject *v)
 {
 	const char *buf;

Modified: python/branches/p3yk-noslice/Objects/bufferobject.c
==============================================================================
--- python/branches/p3yk-noslice/Objects/bufferobject.c	(original)
+++ python/branches/p3yk-noslice/Objects/bufferobject.c	Fri Dec 15 05:37:10 2006
@@ -490,25 +490,6 @@
 }
 
 static PyObject *
-buffer_slice(PyBufferObject *self, Py_ssize_t left, Py_ssize_t right)
-{
-	void *ptr;
-	Py_ssize_t size;
-	if (!get_buf(self, &ptr, &size, ANY_BUFFER))
-		return NULL;
-	if ( left < 0 )
-		left = 0;
-	if ( right < 0 )
-		right = 0;
-	if ( right > size )
-		right = size;
-	if ( right < left )
-		right = left;
-	return PyString_FromStringAndSize((char *)ptr + left,
-					  right - left);
-}
-
-static PyObject *
 buffer_subscript(PyBufferObject *self, PyObject *item)
 {
 	void *p;
@@ -616,64 +597,6 @@
 }
 
 static int
-buffer_ass_slice(PyBufferObject *self, Py_ssize_t left, Py_ssize_t right, PyObject *other)
-{
-	PyBufferProcs *pb;
-	void *ptr1, *ptr2;
-	Py_ssize_t size;
-	Py_ssize_t slice_len;
-	Py_ssize_t count;
-
-	if ( self->b_readonly ) {
-		PyErr_SetString(PyExc_TypeError,
-				"buffer is read-only");
-		return -1;
-	}
-
-	pb = other ? other->ob_type->tp_as_buffer : NULL;
-	if ( pb == NULL ||
-	     pb->bf_getreadbuffer == NULL ||
-	     pb->bf_getsegcount == NULL )
-	{
-		PyErr_BadArgument();
-		return -1;
-	}
-	if ( (*pb->bf_getsegcount)(other, NULL) != 1 )
-	{
-		/* ### use a different exception type/message? */
-		PyErr_SetString(PyExc_TypeError,
-				"single-segment buffer object expected");
-		return -1;
-	}
-	if (!get_buf(self, &ptr1, &size, ANY_BUFFER))
-		return -1;
-	if ( (count = (*pb->bf_getreadbuffer)(other, 0, &ptr2)) < 0 )
-		return -1;
-
-	if ( left < 0 )
-		left = 0;
-	else if ( left > size )
-		left = size;
-	if ( right < left )
-		right = left;
-	else if ( right > size )
-		right = size;
-	slice_len = right - left;
-
-	if ( count != slice_len ) {
-		PyErr_SetString(
-			PyExc_TypeError,
-			"right operand length must match slice length");
-		return -1;
-	}
-
-	if ( slice_len )
-	    memcpy((char *)ptr1 + left, ptr2, slice_len);
-
-	return 0;
-}
-
-static int
 buffer_ass_subscript(PyBufferObject *self, PyObject *item, PyObject *value)
 {
 	PyBufferProcs *pb;

Modified: python/branches/p3yk-noslice/Objects/bytesobject.c
==============================================================================
--- python/branches/p3yk-noslice/Objects/bytesobject.c	(original)
+++ python/branches/p3yk-noslice/Objects/bytesobject.c	Fri Dec 15 05:37:10 2006
@@ -269,18 +269,6 @@
 }
 
 static PyObject *
-bytes_getslice(PyBytesObject *self, Py_ssize_t lo, Py_ssize_t hi)
-{
-    if (lo < 0)
-        lo = 0;
-    if (hi > self->ob_size)
-        hi = self->ob_size;
-    if (lo >= hi)
-        lo = hi = 0;
-    return PyBytes_FromStringAndSize(self->ob_bytes + lo, hi - lo);
-}
-
-static PyObject *
 bytes_subscript(PyBytesObject *self, PyObject *item)
 {
     if (PyIndex_Check(item)) {

Modified: python/branches/p3yk-noslice/Objects/stringobject.c
==============================================================================
--- python/branches/p3yk-noslice/Objects/stringobject.c	(original)
+++ python/branches/p3yk-noslice/Objects/stringobject.c	Fri Dec 15 05:37:10 2006
@@ -1039,29 +1039,6 @@
 	return (PyObject *) op;
 }
 
-/* String slice a[i:j] consists of characters a[i] ... a[j-1] */
-
-static PyObject *
-string_slice(register PyStringObject *a, register Py_ssize_t i,
-	     register Py_ssize_t j)
-     /* j -- may be negative! */
-{
-	if (i < 0)
-		i = 0;
-	if (j < 0)
-		j = 0; /* Avoid signed/unsigned bug in next line */
-	if (j > a->ob_size)
-		j = a->ob_size;
-	if (i == 0 && j == a->ob_size && PyString_CheckExact(a)) {
-		/* It's the same as a */
-		Py_INCREF(a);
-		return (PyObject *)a;
-	}
-	if (j < i)
-		j = i;
-	return PyString_FromStringAndSize(a->ob_sval + i, j-i);
-}
-
 static int
 string_contains(PyObject *str_obj, PyObject *sub_obj)
 {

Modified: python/branches/p3yk-noslice/Objects/typeobject.c
==============================================================================
--- python/branches/p3yk-noslice/Objects/typeobject.c	(original)
+++ python/branches/p3yk-noslice/Objects/typeobject.c	Fri Dec 15 05:37:10 2006
@@ -3471,17 +3471,6 @@
 }
 
 static PyObject *
-wrap_ssizessizeargfunc(PyObject *self, PyObject *args, void *wrapped)
-{
-	ssizessizeargfunc func = (ssizessizeargfunc)wrapped;
-	Py_ssize_t i, j;
-
-	if (!PyArg_ParseTuple(args, "nn", &i, &j))
-		return NULL;
-	return (*func)(self, i, j);
-}
-
-static PyObject *
 wrap_sq_setitem(PyObject *self, PyObject *args, void *wrapped)
 {
 	ssizeobjargproc func = (ssizeobjargproc)wrapped;
@@ -3522,23 +3511,6 @@
 	return Py_None;
 }
 
-static PyObject *
-wrap_ssizessizeobjargproc(PyObject *self, PyObject *args, void *wrapped)
-{
-	ssizessizeobjargproc func = (ssizessizeobjargproc)wrapped;
-	Py_ssize_t i, j;
-	int res;
-	PyObject *value;
-
-	if (!PyArg_ParseTuple(args, "nnO", &i, &j, &value))
-		return NULL;
-	res = (*func)(self, i, j, value);
-	if (res == -1 && PyErr_Occurred())
-		return NULL;
-	Py_INCREF(Py_None);
-	return Py_None;
-}
-
 /* XXX objobjproc is a misnomer; should be objargpred */
 static PyObject *
 wrap_objobjproc(PyObject *self, PyObject *args, void *wrapped)

Modified: python/branches/p3yk-noslice/Objects/unicodeobject.c
==============================================================================
--- python/branches/p3yk-noslice/Objects/unicodeobject.c	(original)
+++ python/branches/p3yk-noslice/Objects/unicodeobject.c	Fri Dec 15 05:37:10 2006
@@ -6574,28 +6574,6 @@
     return (PyObject*) pad(self, width - self->length, 0, fillchar);
 }
 
-static PyObject*
-unicode_slice(PyUnicodeObject *self, Py_ssize_t start, Py_ssize_t end)
-{
-    /* standard clamping */
-    if (start < 0)
-        start = 0;
-    if (end < 0)
-        end = 0;
-    if (end > self->length)
-        end = self->length;
-    if (start == 0 && end == self->length && PyUnicode_CheckExact(self)) {
-        /* full slice, return original string */
-        Py_INCREF(self);
-        return (PyObject*) self;
-    }
-    if (start > end)
-        start = end;
-    /* copy slice */
-    return (PyObject*) PyUnicode_FromUnicode(self->str + start,
-					     end - start);
-}
-
 PyObject *PyUnicode_Split(PyObject *s,
 			  PyObject *sep,
 			  Py_ssize_t maxsplit)

Modified: python/branches/p3yk-noslice/Objects/weakrefobject.c
==============================================================================
--- python/branches/p3yk-noslice/Objects/weakrefobject.c	(original)
+++ python/branches/p3yk-noslice/Objects/weakrefobject.c	Fri Dec 15 05:37:10 2006
@@ -518,14 +518,6 @@
 
 /* sequence slots */
 
-static PyObject *
-proxy_slice(PyWeakReference *proxy, Py_ssize_t i, Py_ssize_t j)
-{
-    if (!proxy_checkref(proxy))
-        return NULL;
-    return PySequence_GetSlice(PyWeakref_GET_OBJECT(proxy), i, j);
-}
-
 static int
 proxy_contains(PyWeakReference *proxy, PyObject *value)
 {

Modified: python/branches/p3yk-noslice/Python/Python-ast.c
==============================================================================
--- python/branches/p3yk-noslice/Python/Python-ast.c	(original)
+++ python/branches/p3yk-noslice/Python/Python-ast.c	Fri Dec 15 05:37:10 2006
@@ -3008,7 +3008,7 @@
         if (PyDict_SetItemString(d, "AST", (PyObject*)AST_type) < 0) return;
         if (PyModule_AddIntConstant(m, "PyCF_ONLY_AST", PyCF_ONLY_AST) < 0)
                 return;
-        if (PyModule_AddStringConstant(m, "__version__", "45597") < 0)
+        if (PyModule_AddStringConstant(m, "__version__", "53040") < 0)
                 return;
         if (PyDict_SetItemString(d, "mod", (PyObject*)mod_type) < 0) return;
         if (PyDict_SetItemString(d, "Module", (PyObject*)Module_type) < 0)


More information about the Python-checkins mailing list