[Python-checkins] commit of r41904 - in python/branches/ssize_t: Include/abstract.h Include/object.h Modules/_bsddb.c Modules/arraymodule.c Modules/bsddbmodule.c Modules/collectionsmodule.c Modules/dbmmodule.c Modules/gdbmmodule.c Modules/mmapmodule.c Objects/abstract.c Objects/bufferobject.c Objects/classobject.c Objects/descrobject.c Objects/dictobject.c Objects/listobject.c Objects/object.c Objects/rangeobject.c Objects/setobject.c Objects/stringobject.c Objects/tupleobject.c Objects/typeobject.c Objects/unicodeobject.c Objects/weakrefobject.c
martin.v.loewis
python-checkins at python.org
Tue Jan 3 10:49:20 CET 2006
Author: martin.v.loewis
Date: Tue Jan 3 10:49:11 2006
New Revision: 41904
Modified:
python/branches/ssize_t/Include/abstract.h
python/branches/ssize_t/Include/object.h
python/branches/ssize_t/Modules/_bsddb.c
python/branches/ssize_t/Modules/arraymodule.c
python/branches/ssize_t/Modules/bsddbmodule.c
python/branches/ssize_t/Modules/collectionsmodule.c
python/branches/ssize_t/Modules/dbmmodule.c
python/branches/ssize_t/Modules/gdbmmodule.c
python/branches/ssize_t/Modules/mmapmodule.c
python/branches/ssize_t/Objects/abstract.c
python/branches/ssize_t/Objects/bufferobject.c
python/branches/ssize_t/Objects/classobject.c
python/branches/ssize_t/Objects/descrobject.c
python/branches/ssize_t/Objects/dictobject.c
python/branches/ssize_t/Objects/listobject.c
python/branches/ssize_t/Objects/object.c
python/branches/ssize_t/Objects/rangeobject.c
python/branches/ssize_t/Objects/setobject.c
python/branches/ssize_t/Objects/stringobject.c
python/branches/ssize_t/Objects/tupleobject.c
python/branches/ssize_t/Objects/typeobject.c
python/branches/ssize_t/Objects/unicodeobject.c
python/branches/ssize_t/Objects/weakrefobject.c
Log:
Make Length/Size return Py_ssize_t throughout.
Modified: python/branches/ssize_t/Include/abstract.h
==============================================================================
--- python/branches/ssize_t/Include/abstract.h (original)
+++ python/branches/ssize_t/Include/abstract.h Tue Jan 3 10:49:11 2006
@@ -407,7 +407,7 @@
equivalent to the Python expression: type(o).
*/
- PyAPI_FUNC(int) PyObject_Size(PyObject *o);
+ PyAPI_FUNC(Py_ssize_t) PyObject_Size(PyObject *o);
/*
Return the size of object o. If the object, o, provides
@@ -419,7 +419,7 @@
/* For DLL compatibility */
#undef PyObject_Length
- PyAPI_FUNC(int) PyObject_Length(PyObject *o);
+ PyAPI_FUNC(Py_ssize_t) PyObject_Length(PyObject *o);
#define PyObject_Length PyObject_Size
PyAPI_FUNC(int) _PyObject_LengthCue(PyObject *o);
@@ -906,7 +906,7 @@
*/
- PyAPI_FUNC(int) PySequence_Size(PyObject *o);
+ PyAPI_FUNC(Py_ssize_t) PySequence_Size(PyObject *o);
/*
Return the size of sequence object o, or -1 on failure.
@@ -915,7 +915,7 @@
/* For DLL compatibility */
#undef PySequence_Length
- PyAPI_FUNC(int) PySequence_Length(PyObject *o);
+ PyAPI_FUNC(Py_ssize_t) PySequence_Length(PyObject *o);
#define PySequence_Length PySequence_Size
@@ -1120,7 +1120,7 @@
This function always succeeds.
*/
- PyAPI_FUNC(int) PyMapping_Size(PyObject *o);
+ PyAPI_FUNC(Py_ssize_t) PyMapping_Size(PyObject *o);
/*
Returns the number of keys in object o on success, and -1 on
@@ -1130,7 +1130,7 @@
/* For DLL compatibility */
#undef PyMapping_Length
- PyAPI_FUNC(int) PyMapping_Length(PyObject *o);
+ PyAPI_FUNC(Py_ssize_t) PyMapping_Length(PyObject *o);
#define PyMapping_Length PyMapping_Size
Modified: python/branches/ssize_t/Include/object.h
==============================================================================
--- python/branches/ssize_t/Include/object.h (original)
+++ python/branches/ssize_t/Include/object.h Tue Jan 3 10:49:11 2006
@@ -128,6 +128,7 @@
typedef PyObject * (*binaryfunc)(PyObject *, PyObject *);
typedef PyObject * (*ternaryfunc)(PyObject *, PyObject *, PyObject *);
typedef int (*inquiry)(PyObject *);
+typedef Py_ssize_t (*lenfunc)(PyObject *);
typedef int (*coercion)(PyObject **, PyObject **);
typedef PyObject *(*intargfunc)(PyObject *, int) Py_DEPRECATED(2.5);
typedef PyObject *(*intintargfunc)(PyObject *, int, int) Py_DEPRECATED(2.5);
@@ -200,7 +201,7 @@
} PyNumberMethods;
typedef struct {
- inquiry sq_length;
+ lenfunc sq_length;
binaryfunc sq_concat;
ssizeargfunc sq_repeat;
ssizeargfunc sq_item;
@@ -214,7 +215,7 @@
} PySequenceMethods;
typedef struct {
- inquiry mp_length;
+ lenfunc mp_length;
binaryfunc mp_subscript;
objobjargproc mp_ass_subscript;
} PyMappingMethods;
Modified: python/branches/ssize_t/Modules/_bsddb.c
==============================================================================
--- python/branches/ssize_t/Modules/_bsddb.c (original)
+++ python/branches/ssize_t/Modules/_bsddb.c Tue Jan 3 10:49:11 2006
@@ -2603,7 +2603,7 @@
/*-------------------------------------------------------------- */
/* Mapping and Dictionary-like access routines */
-int DB_length(DBObject* self)
+Py_ssize_t DB_length(DBObject* self)
{
int err;
long size = 0;
@@ -4641,7 +4641,7 @@
static PyMappingMethods DB_mapping = {
- (inquiry)DB_length, /*mp_length*/
+ (lenfunc)DB_length, /*mp_length*/
(binaryfunc)DB_subscript, /*mp_subscript*/
(objobjargproc)DB_ass_sub, /*mp_ass_subscript*/
};
Modified: python/branches/ssize_t/Modules/arraymodule.c
==============================================================================
--- python/branches/ssize_t/Modules/arraymodule.c (original)
+++ python/branches/ssize_t/Modules/arraymodule.c Tue Jan 3 10:49:11 2006
@@ -1742,7 +1742,7 @@
}
static PyMappingMethods array_as_mapping = {
- (inquiry)array_length,
+ (lenfunc)array_length,
(binaryfunc)array_subscr,
(objobjargproc)array_ass_subscr
};
@@ -1780,7 +1780,7 @@
}
static PySequenceMethods array_as_sequence = {
- (inquiry)array_length, /*sq_length*/
+ (lenfunc)array_length, /*sq_length*/
(binaryfunc)array_concat, /*sq_concat*/
(ssizeargfunc)array_repeat, /*sq_repeat*/
(ssizeargfunc)array_item, /*sq_item*/
Modified: python/branches/ssize_t/Modules/bsddbmodule.c
==============================================================================
--- python/branches/ssize_t/Modules/bsddbmodule.c (original)
+++ python/branches/ssize_t/Modules/bsddbmodule.c Tue Jan 3 10:49:11 2006
@@ -240,7 +240,7 @@
#define BSDDB_END_SAVE(_dp) Py_END_ALLOW_THREADS
#endif
-static int
+static Py_ssize_t
bsddb_length(bsddbobject *dp)
{
check_bsddbobject_open(dp, -1);
@@ -374,7 +374,7 @@
}
static PyMappingMethods bsddb_as_mapping = {
- (inquiry)bsddb_length, /*mp_length*/
+ (lenfunc)bsddb_length, /*mp_length*/
(binaryfunc)bsddb_subscript, /*mp_subscript*/
(objobjargproc)bsddb_ass_sub, /*mp_ass_subscript*/
};
Modified: python/branches/ssize_t/Modules/collectionsmodule.c
==============================================================================
--- python/branches/ssize_t/Modules/collectionsmodule.c (original)
+++ python/branches/ssize_t/Modules/collectionsmodule.c Tue Jan 3 10:49:11 2006
@@ -365,7 +365,7 @@
PyDoc_STRVAR(rotate_doc,
"Rotate the deque n steps to the right (default n=1). If n is negative, rotates left.");
-static int
+static Py_ssize_t
deque_len(dequeobject *deque)
{
return deque->len;
@@ -776,7 +776,7 @@
}
static PySequenceMethods deque_as_sequence = {
- (inquiry)deque_len, /* sq_length */
+ (lenfunc)deque_len, /* sq_length */
0, /* sq_concat */
0, /* sq_repeat */
(ssizeargfunc)deque_item, /* sq_item */
Modified: python/branches/ssize_t/Modules/dbmmodule.c
==============================================================================
--- python/branches/ssize_t/Modules/dbmmodule.c (original)
+++ python/branches/ssize_t/Modules/dbmmodule.c Tue Jan 3 10:49:11 2006
@@ -70,7 +70,7 @@
PyObject_Del(dp);
}
-static int
+static Py_ssize_t
dbm_length(dbmobject *dp)
{
if (dp->di_dbm == NULL) {
@@ -162,7 +162,7 @@
}
static PyMappingMethods dbm_as_mapping = {
- (inquiry)dbm_length, /*mp_length*/
+ (lenfunc)dbm_length, /*mp_length*/
(binaryfunc)dbm_subscript, /*mp_subscript*/
(objobjargproc)dbm_ass_sub, /*mp_ass_subscript*/
};
Modified: python/branches/ssize_t/Modules/gdbmmodule.c
==============================================================================
--- python/branches/ssize_t/Modules/gdbmmodule.c (original)
+++ python/branches/ssize_t/Modules/gdbmmodule.c Tue Jan 3 10:49:11 2006
@@ -86,7 +86,7 @@
PyObject_Del(dp);
}
-static int
+static Py_ssize_t
dbm_length(dbmobject *dp)
{
if (dp->di_dbm == NULL) {
@@ -178,7 +178,7 @@
}
static PyMappingMethods dbm_as_mapping = {
- (inquiry)dbm_length, /*mp_length*/
+ (lenfunc)dbm_length, /*mp_length*/
(binaryfunc)dbm_subscript, /*mp_subscript*/
(objobjargproc)dbm_ass_sub, /*mp_ass_subscript*/
};
Modified: python/branches/ssize_t/Modules/mmapmodule.c
==============================================================================
--- python/branches/ssize_t/Modules/mmapmodule.c (original)
+++ python/branches/ssize_t/Modules/mmapmodule.c Tue Jan 3 10:49:11 2006
@@ -633,7 +633,7 @@
return Py_FindMethod (mmap_object_methods, (PyObject *)self, name);
}
-static int
+static Py_ssize_t
mmap_length(mmap_object *self)
{
CHECK_VALID(-1);
@@ -754,7 +754,7 @@
}
static PySequenceMethods mmap_as_sequence = {
- (inquiry)mmap_length, /*sq_length*/
+ (lenfunc)mmap_length, /*sq_length*/
(binaryfunc)mmap_concat, /*sq_concat*/
(ssizeargfunc)mmap_repeat, /*sq_repeat*/
(ssizeargfunc)mmap_item, /*sq_item*/
Modified: python/branches/ssize_t/Objects/abstract.c
==============================================================================
--- python/branches/ssize_t/Objects/abstract.c (original)
+++ python/branches/ssize_t/Objects/abstract.c Tue Jan 3 10:49:11 2006
@@ -56,7 +56,7 @@
return v;
}
-int
+Py_ssize_t
PyObject_Size(PyObject *o)
{
PySequenceMethods *m;
@@ -1236,7 +1236,7 @@
}
PyObject *
-PySequence_GetItem(PyObject *s, Py_ssize_t i) /* XXX negative values */
+PySequence_GetItem(PyObject *s, Py_ssize_t i)
{
PySequenceMethods *m;
@@ -1247,7 +1247,7 @@
if (m && m->sq_item) {
if (i < 0) {
if (m->sq_length) {
- int l = (*m->sq_length)(s);
+ Py_ssize_t l = (*m->sq_length)(s);
if (l < 0)
return NULL;
i += l;
@@ -1289,7 +1289,7 @@
if (m && m->sq_slice) {
if (i1 < 0 || i2 < 0) {
if (m->sq_length) {
- int l = (*m->sq_length)(s);
+ Py_ssize_t l = (*m->sq_length)(s);
if (l < 0)
return NULL;
if (i1 < 0)
@@ -1326,7 +1326,7 @@
if (m && m->sq_ass_item) {
if (i < 0) {
if (m->sq_length) {
- int l = (*m->sq_length)(s);
+ Py_ssize_t l = (*m->sq_length)(s);
if (l < 0)
return -1;
i += l;
@@ -1353,7 +1353,7 @@
if (m && m->sq_ass_item) {
if (i < 0) {
if (m->sq_length) {
- int l = (*m->sq_length)(s);
+ Py_ssize_t l = (*m->sq_length)(s);
if (l < 0)
return -1;
i += l;
@@ -1381,7 +1381,7 @@
if (m && m->sq_ass_slice) {
if (i1 < 0 || i2 < 0) {
if (m->sq_length) {
- int l = (*m->sq_length)(s);
+ Py_ssize_t l = (*m->sq_length)(s);
if (l < 0)
return -1;
if (i1 < 0)
@@ -1419,7 +1419,7 @@
if (m && m->sq_ass_slice) {
if (i1 < 0 || i2 < 0) {
if (m->sq_length) {
- int l = (*m->sq_length)(s);
+ Py_ssize_t l = (*m->sq_length)(s);
if (l < 0)
return -1;
if (i1 < 0)
@@ -1708,7 +1708,7 @@
o->ob_type->tp_as_sequence->sq_slice);
}
-int
+Py_ssize_t
PyMapping_Size(PyObject *o)
{
PyMappingMethods *m;
@@ -1727,7 +1727,7 @@
}
#undef PyMapping_Length
-int
+Py_ssize_t
PyMapping_Length(PyObject *o)
{
return PyMapping_Size(o);
Modified: python/branches/ssize_t/Objects/bufferobject.c
==============================================================================
--- python/branches/ssize_t/Objects/bufferobject.c (original)
+++ python/branches/ssize_t/Objects/bufferobject.c Tue Jan 3 10:49:11 2006
@@ -308,7 +308,7 @@
/* Sequence methods */
-static int
+static Py_ssize_t
buffer_length(PyBufferObject *self)
{
void *ptr;
@@ -596,7 +596,7 @@
static PySequenceMethods buffer_as_sequence = {
- (inquiry)buffer_length, /*sq_length*/
+ (lenfunc)buffer_length, /*sq_length*/
(binaryfunc)buffer_concat, /*sq_concat*/
(ssizeargfunc)buffer_repeat, /*sq_repeat*/
(ssizeargfunc)buffer_item, /*sq_item*/
Modified: python/branches/ssize_t/Objects/classobject.c
==============================================================================
--- python/branches/ssize_t/Objects/classobject.c (original)
+++ python/branches/ssize_t/Objects/classobject.c Tue Jan 3 10:49:11 2006
@@ -996,12 +996,12 @@
static PyObject *getitemstr, *setitemstr, *delitemstr, *lenstr;
static PyObject *iterstr, *nextstr;
-static int
+static Py_ssize_t
instance_length(PyInstanceObject *inst)
{
PyObject *func;
PyObject *res;
- int outcome;
+ Py_ssize_t outcome;
if (lenstr == NULL)
lenstr = PyString_InternFromString("__len__");
@@ -1013,9 +1013,13 @@
if (res == NULL)
return -1;
if (PyInt_Check(res)) {
- long temp = PyInt_AsLong(res);
- outcome = (int)temp;
-#if SIZEOF_INT < SIZEOF_LONG
+ Py_ssize_t temp = PyInt_AsSsize_t(res);
+ if (temp == -1 && PyErr_Occurred()) {
+ Py_DECREF(res);
+ return -1;
+ }
+ outcome = (Py_ssize_t)temp;
+#if SIZEOF_SIZE_T < SIZEOF_LONG
/* Overflow check -- range of PyInt is more than C int */
if (outcome != temp) {
PyErr_SetString(PyExc_OverflowError,
@@ -1097,7 +1101,7 @@
}
static PyMappingMethods instance_as_mapping = {
- (inquiry)instance_length, /* mp_length */
+ (lenfunc)instance_length, /* mp_length */
(binaryfunc)instance_subscript, /* mp_subscript */
(objobjargproc)instance_ass_subscript, /* mp_ass_subscript */
};
@@ -1322,7 +1326,7 @@
static PySequenceMethods
instance_as_sequence = {
- (inquiry)instance_length, /* sq_length */
+ (lenfunc)instance_length, /* sq_length */
0, /* sq_concat */
0, /* sq_repeat */
(ssizeargfunc)instance_item, /* sq_item */
Modified: python/branches/ssize_t/Objects/descrobject.c
==============================================================================
--- python/branches/ssize_t/Objects/descrobject.c (original)
+++ python/branches/ssize_t/Objects/descrobject.c Tue Jan 3 10:49:11 2006
@@ -669,7 +669,7 @@
PyObject *dict;
} proxyobject;
-static int
+static Py_ssize_t
proxy_len(proxyobject *pp)
{
return PyObject_Size(pp->dict);
@@ -682,7 +682,7 @@
}
static PyMappingMethods proxy_as_mapping = {
- (inquiry)proxy_len, /* mp_length */
+ (lenfunc)proxy_len, /* mp_length */
(binaryfunc)proxy_getitem, /* mp_subscript */
0, /* mp_ass_subscript */
};
Modified: python/branches/ssize_t/Objects/dictobject.c
==============================================================================
--- python/branches/ssize_t/Objects/dictobject.c (original)
+++ python/branches/ssize_t/Objects/dictobject.c Tue Jan 3 10:49:11 2006
@@ -862,7 +862,7 @@
return result;
}
-static int
+static Py_ssize_t
dict_length(dictobject *mp)
{
return mp->ma_used;
@@ -898,7 +898,7 @@
}
static PyMappingMethods dict_as_mapping = {
- (inquiry)dict_length, /*mp_length*/
+ (lenfunc)dict_length, /*mp_length*/
(binaryfunc)dict_subscript, /*mp_subscript*/
(objobjargproc)dict_ass_sub, /*mp_ass_subscript*/
};
Modified: python/branches/ssize_t/Objects/listobject.c
==============================================================================
--- python/branches/ssize_t/Objects/listobject.c (original)
+++ python/branches/ssize_t/Objects/listobject.c Tue Jan 3 10:49:11 2006
@@ -363,7 +363,7 @@
return result;
}
-static int
+static Py_ssize_t
list_length(PyListObject *a)
{
return a->ob_size;
@@ -2434,7 +2434,7 @@
};
static PySequenceMethods list_as_sequence = {
- (inquiry)list_length, /* sq_length */
+ (lenfunc)list_length, /* sq_length */
(binaryfunc)list_concat, /* sq_concat */
(ssizeargfunc)list_repeat, /* sq_repeat */
(ssizeargfunc)list_item, /* sq_item */
@@ -2641,7 +2641,7 @@
}
static PyMappingMethods list_as_mapping = {
- (inquiry)list_length,
+ (lenfunc)list_length,
(binaryfunc)list_subscript,
(objobjargproc)list_ass_subscript
};
@@ -2876,7 +2876,7 @@
return NULL;
}
-static int
+static Py_ssize_t
listreviter_len(listreviterobject *it)
{
Py_ssize_t len = it->it_index + 1;
@@ -2886,7 +2886,7 @@
}
static PySequenceMethods listreviter_as_sequence = {
- (inquiry)listreviter_len, /* sq_length */
+ (lenfunc)listreviter_len, /* sq_length */
0, /* sq_concat */
};
Modified: python/branches/ssize_t/Objects/object.c
==============================================================================
--- python/branches/ssize_t/Objects/object.c (original)
+++ python/branches/ssize_t/Objects/object.c Tue Jan 3 10:49:11 2006
@@ -1414,7 +1414,7 @@
int
PyObject_IsTrue(PyObject *v)
{
- int res;
+ Py_ssize_t res;
if (v == Py_True)
return 1;
if (v == Py_False)
Modified: python/branches/ssize_t/Objects/rangeobject.c
==============================================================================
--- python/branches/ssize_t/Objects/rangeobject.c (original)
+++ python/branches/ssize_t/Objects/rangeobject.c Tue Jan 3 10:49:11 2006
@@ -101,17 +101,17 @@
return PyInt_FromLong(r->start + (i % r->len) * r->step);
}
-static int
+static Py_ssize_t
range_length(rangeobject *r)
{
-#if LONG_MAX != INT_MAX
+#if LONG_MAX != INT_MAX /* XXX ssize_t_max */
if (r->len > INT_MAX) {
PyErr_SetString(PyExc_ValueError,
"xrange object size cannot be reported");
return -1;
}
#endif
- return (int)(r->len);
+ return (Py_ssize_t)(r->len);
}
static PyObject *
@@ -137,7 +137,7 @@
}
static PySequenceMethods range_as_sequence = {
- (inquiry)range_length, /* sq_length */
+ (lenfunc)range_length, /* sq_length */
0, /* sq_concat */
0, /* sq_repeat */
(ssizeargfunc)range_item, /* sq_item */
Modified: python/branches/ssize_t/Objects/setobject.c
==============================================================================
--- python/branches/ssize_t/Objects/setobject.c (original)
+++ python/branches/ssize_t/Objects/setobject.c Tue Jan 3 10:49:11 2006
@@ -551,7 +551,7 @@
return result;
}
-static int
+static Py_ssize_t
set_len(PyObject *so)
{
return ((PySetObject *)so)->used;
@@ -1687,7 +1687,7 @@
}
static PySequenceMethods set_as_sequence = {
- (inquiry)set_len, /* sq_length */
+ (lenfunc)set_len, /* sq_length */
0, /* sq_concat */
0, /* sq_repeat */
0, /* sq_item */
Modified: python/branches/ssize_t/Objects/stringobject.c
==============================================================================
--- python/branches/ssize_t/Objects/stringobject.c (original)
+++ python/branches/ssize_t/Objects/stringobject.c Tue Jan 3 10:49:11 2006
@@ -877,7 +877,7 @@
}
}
-static int
+static Py_ssize_t
string_length(PyStringObject *a)
{
return a->ob_size;
@@ -1257,7 +1257,7 @@
}
static PySequenceMethods string_as_sequence = {
- (inquiry)string_length, /*sq_length*/
+ (lenfunc)string_length, /*sq_length*/
(binaryfunc)string_concat, /*sq_concat*/
(ssizeargfunc)string_repeat, /*sq_repeat*/
(ssizeargfunc)string_item, /*sq_item*/
@@ -1268,7 +1268,7 @@
};
static PyMappingMethods string_as_mapping = {
- (inquiry)string_length,
+ (lenfunc)string_length,
(binaryfunc)string_subscript,
0,
};
Modified: python/branches/ssize_t/Objects/tupleobject.c
==============================================================================
--- python/branches/ssize_t/Objects/tupleobject.c (original)
+++ python/branches/ssize_t/Objects/tupleobject.c Tue Jan 3 10:49:11 2006
@@ -572,7 +572,7 @@
"If the argument is a tuple, the return value is the same object.");
static PySequenceMethods tuple_as_sequence = {
- (inquiry)tuplelength, /* sq_length */
+ (lenfunc)tuplelength, /* sq_length */
(binaryfunc)tupleconcat, /* sq_concat */
(ssizeargfunc)tuplerepeat, /* sq_repeat */
(ssizeargfunc)tupleitem, /* sq_item */
@@ -643,7 +643,7 @@
};
static PyMappingMethods tuple_as_mapping = {
- (inquiry)tuplelength,
+ (lenfunc)tuplelength,
(binaryfunc)tuplesubscript,
0
};
Modified: python/branches/ssize_t/Objects/typeobject.c
==============================================================================
--- python/branches/ssize_t/Objects/typeobject.c (original)
+++ python/branches/ssize_t/Objects/typeobject.c Tue Jan 3 10:49:11 2006
@@ -3386,10 +3386,10 @@
entries, one regular and one with reversed arguments. */
static PyObject *
-wrap_inquiry(PyObject *self, PyObject *args, void *wrapped)
+wrap_lenfunc(PyObject *self, PyObject *args, void *wrapped)
{
- inquiry func = (inquiry)wrapped;
- int res;
+ lenfunc func = (lenfunc)wrapped;
+ Py_ssize_t res;
if (!check_num_args(args, 0))
return NULL;
@@ -4104,23 +4104,23 @@
"(" ARGCODES ")", arg1, arg2); \
}
-static int
+static Py_ssize_t
slot_sq_length(PyObject *self)
{
static PyObject *len_str;
PyObject *res = call_method(self, "__len__", &len_str, "()");
- long temp;
- int len;
+ Py_ssize_t temp;
+ Py_ssize_t len;
if (res == NULL)
return -1;
- temp = PyInt_AsLong(res);
+ temp = PyInt_AsSsize_t(res);
len = (int)temp;
Py_DECREF(res);
if (len == -1 && PyErr_Occurred())
return -1;
-#if SIZEOF_INT < SIZEOF_LONG
- /* Overflow check -- range of PyInt is more than C int */
+#if SIZEOF_SIZE_T < SIZEOF_LONG
+ /* Overflow check -- range of PyInt is more than C ssize_t */
if (len != temp) {
PyErr_SetString(PyExc_OverflowError,
"__len__() should return 0 <= outcome < 2**31");
@@ -4958,7 +4958,7 @@
"x." NAME "(y) <==> " DOC)
static slotdef slotdefs[] = {
- SQSLOT("__len__", sq_length, slot_sq_length, wrap_inquiry,
+ SQSLOT("__len__", sq_length, slot_sq_length, wrap_lenfunc,
"x.__len__() <==> len(x)"),
/* Heap types defining __add__/__mul__ have sq_concat/sq_repeat == NULL.
The logic in abstract.c always falls back to nb_add/nb_multiply in
@@ -4997,7 +4997,7 @@
SQSLOT("__imul__", sq_inplace_repeat, NULL,
wrap_ssizeargfunc, "x.__imul__(y) <==> x*=y"),
- MPSLOT("__len__", mp_length, slot_mp_length, wrap_inquiry,
+ MPSLOT("__len__", mp_length, slot_mp_length, wrap_lenfunc,
"x.__len__() <==> len(x)"),
MPSLOT("__getitem__", mp_subscript, slot_mp_subscript,
wrap_binaryfunc,
Modified: python/branches/ssize_t/Objects/unicodeobject.c
==============================================================================
--- python/branches/ssize_t/Objects/unicodeobject.c (original)
+++ python/branches/ssize_t/Objects/unicodeobject.c Tue Jan 3 10:49:11 2006
@@ -5653,7 +5653,7 @@
return PyUnicode_Join(self, data);
}
-static int
+static Py_ssize_t
unicode_length(PyUnicodeObject *self)
{
return self->length;
@@ -6449,7 +6449,7 @@
};
static PySequenceMethods unicode_as_sequence = {
- (inquiry) unicode_length, /* sq_length */
+ (lenfunc) unicode_length, /* sq_length */
(binaryfunc) PyUnicode_Concat, /* sq_concat */
(ssizeargfunc) unicode_repeat, /* sq_repeat */
(ssizeargfunc) unicode_getitem, /* sq_item */
@@ -6501,7 +6501,7 @@
}
static PyMappingMethods unicode_as_mapping = {
- (inquiry)unicode_length, /* mp_length */
+ (lenfunc)unicode_length, /* mp_length */
(binaryfunc)unicode_subscript, /* mp_subscript */
(objobjargproc)0, /* mp_ass_subscript */
};
Modified: python/branches/ssize_t/Objects/weakrefobject.c
==============================================================================
--- python/branches/ssize_t/Objects/weakrefobject.c (original)
+++ python/branches/ssize_t/Objects/weakrefobject.c Tue Jan 3 10:49:11 2006
@@ -546,7 +546,7 @@
/* mapping slots */
-static int
+static Py_ssize_t
proxy_length(PyWeakReference *proxy)
{
if (!proxy_checkref(proxy))
@@ -625,7 +625,7 @@
};
static PySequenceMethods proxy_as_sequence = {
- (inquiry)proxy_length, /*sq_length*/
+ (lenfunc)proxy_length, /*sq_length*/
0, /*sq_concat*/
0, /*sq_repeat*/
0, /*sq_item*/
@@ -636,7 +636,7 @@
};
static PyMappingMethods proxy_as_mapping = {
- (inquiry)proxy_length, /*mp_length*/
+ (lenfunc)proxy_length, /*mp_length*/
(binaryfunc)proxy_getitem, /*mp_subscript*/
(objobjargproc)proxy_setitem, /*mp_ass_subscript*/
};
More information about the Python-checkins
mailing list