[Python-checkins] commit of r41905 - in python/branches/ssize_t: Include/dictobject.h Modules/_testcapimodule.c Modules/cPickle.c Modules/parsermodule.c Modules/selectmodule.c Modules/shamodule.c Objects/abstract.c Objects/dictobject.c Objects/funcobject.c Objects/moduleobject.c Objects/object.c Objects/setobject.c Objects/typeobject.c Python/bltinmodule.c Python/compile.c Python/getargs.c Python/import.c Python/marshal.c Python/symtable.c
martin.v.loewis
python-checkins at python.org
Tue Jan 3 11:26:02 CET 2006
Author: martin.v.loewis
Date: Tue Jan 3 11:25:55 2006
New Revision: 41905
Modified:
python/branches/ssize_t/Include/dictobject.h
python/branches/ssize_t/Modules/_testcapimodule.c
python/branches/ssize_t/Modules/cPickle.c
python/branches/ssize_t/Modules/parsermodule.c
python/branches/ssize_t/Modules/selectmodule.c
python/branches/ssize_t/Modules/shamodule.c
python/branches/ssize_t/Objects/abstract.c
python/branches/ssize_t/Objects/dictobject.c
python/branches/ssize_t/Objects/funcobject.c
python/branches/ssize_t/Objects/moduleobject.c
python/branches/ssize_t/Objects/object.c
python/branches/ssize_t/Objects/setobject.c
python/branches/ssize_t/Objects/typeobject.c
python/branches/ssize_t/Python/bltinmodule.c
python/branches/ssize_t/Python/compile.c
python/branches/ssize_t/Python/getargs.c
python/branches/ssize_t/Python/import.c
python/branches/ssize_t/Python/marshal.c
python/branches/ssize_t/Python/symtable.c
Log:
Adjust more places to ssize_t Size/Length/Dict_Next.
Modified: python/branches/ssize_t/Include/dictobject.h
==============================================================================
--- python/branches/ssize_t/Include/dictobject.h (original)
+++ python/branches/ssize_t/Include/dictobject.h Tue Jan 3 11:25:55 2006
@@ -95,11 +95,11 @@
PyAPI_FUNC(int) PyDict_DelItem(PyObject *mp, PyObject *key);
PyAPI_FUNC(void) PyDict_Clear(PyObject *mp);
PyAPI_FUNC(int) PyDict_Next(
- PyObject *mp, int *pos, PyObject **key, PyObject **value);
+ PyObject *mp, Py_ssize_t *pos, PyObject **key, PyObject **value);
PyAPI_FUNC(PyObject *) PyDict_Keys(PyObject *mp);
PyAPI_FUNC(PyObject *) PyDict_Values(PyObject *mp);
PyAPI_FUNC(PyObject *) PyDict_Items(PyObject *mp);
-PyAPI_FUNC(int) PyDict_Size(PyObject *mp);
+PyAPI_FUNC(Py_ssize_t) PyDict_Size(PyObject *mp);
PyAPI_FUNC(PyObject *) PyDict_Copy(PyObject *mp);
PyAPI_FUNC(int) PyDict_Contains(PyObject *mp, PyObject *key);
Modified: python/branches/ssize_t/Modules/_testcapimodule.c
==============================================================================
--- python/branches/ssize_t/Modules/_testcapimodule.c (original)
+++ python/branches/ssize_t/Modules/_testcapimodule.c Tue Jan 3 11:25:55 2006
@@ -115,7 +115,8 @@
static int
test_dict_inner(int count)
{
- int pos = 0, iterations = 0, i;
+ Py_ssize_t pos = 0, iterations = 0;
+ int i;
PyObject *dict = PyDict_New();
PyObject *v, *k;
Modified: python/branches/ssize_t/Modules/cPickle.c
==============================================================================
--- python/branches/ssize_t/Modules/cPickle.c (original)
+++ python/branches/ssize_t/Modules/cPickle.c Tue Jan 3 11:25:55 2006
@@ -368,8 +368,8 @@
int *marks;
int num_marks;
int marks_size;
- int (*read_func)(struct Unpicklerobject *, char **, int);
- int (*readline_func)(struct Unpicklerobject *, char **);
+ Py_ssize_t (*read_func)(struct Unpicklerobject *, char **, Py_ssize_t);
+ Py_ssize_t (*readline_func)(struct Unpicklerobject *, char **);
int buf_size;
char *buf;
PyObject *find_class;
@@ -515,8 +515,8 @@
}
-static int
-read_file(Unpicklerobject *self, char **s, int n)
+static Py_ssize_t
+read_file(Unpicklerobject *self, char **s, Py_ssize_t n)
{
size_t nbytesread;
@@ -559,7 +559,7 @@
}
-static int
+static Py_ssize_t
readline_file(Unpicklerobject *self, char **s)
{
int i;
@@ -598,8 +598,8 @@
}
-static int
-read_cStringIO(Unpicklerobject *self, char **s, int n)
+static Py_ssize_t
+read_cStringIO(Unpicklerobject *self, char **s, Py_ssize_t n)
{
char *ptr;
@@ -614,10 +614,10 @@
}
-static int
+static Py_ssize_t
readline_cStringIO(Unpicklerobject *self, char **s)
{
- int n;
+ Py_ssize_t n;
char *ptr;
if ((n = PycStringIO->creadline((PyObject *)self->file, &ptr)) < 0) {
@@ -630,12 +630,12 @@
}
-static int
-read_other(Unpicklerobject *self, char **s, int n)
+static Py_ssize_t
+read_other(Unpicklerobject *self, char **s, Py_ssize_t n)
{
PyObject *bytes, *str=0;
- if (!( bytes = PyInt_FromLong(n))) return -1;
+ if (!( bytes = PyInt_FromSsize_t(n))) return -1;
ARG_TUP(self, bytes);
if (self->arg) {
@@ -652,11 +652,11 @@
}
-static int
+static Py_ssize_t
readline_other(Unpicklerobject *self, char **s)
{
PyObject *str;
- int str_size;
+ Py_ssize_t str_size;
if (!( str = PyObject_CallObject(self->readline, empty_tuple))) {
return -1;
@@ -838,7 +838,7 @@
static PyObject *
whichmodule(PyObject *global, PyObject *global_name)
{
- int i, j;
+ Py_ssize_t i, j;
PyObject *module = 0, *modules_dict = 0,
*global_name_attr = 0, *name = 0;
@@ -3290,7 +3290,7 @@
static int
load_counted_long(Unpicklerobject *self, int size)
{
- int i;
+ Py_ssize_t i;
char *nbytes;
unsigned char *pdata;
PyObject *along;
@@ -4263,7 +4263,7 @@
PyObject *state, *inst, *slotstate;
PyObject *__setstate__;
PyObject *d_key, *d_value;
- int i;
+ Py_ssize_t i;
int res = -1;
/* Stack is ... instance, state. We want to leave instance at
@@ -5720,7 +5720,7 @@
initcPickle(void)
{
PyObject *m, *d, *di, *v, *k;
- int i;
+ Py_ssize_t i;
char *rev = "1.71"; /* XXX when does this change? */
PyObject *format_version;
PyObject *compatible_formats;
Modified: python/branches/ssize_t/Modules/parsermodule.c
==============================================================================
--- python/branches/ssize_t/Modules/parsermodule.c (original)
+++ python/branches/ssize_t/Modules/parsermodule.c Tue Jan 3 11:25:55 2006
@@ -632,8 +632,9 @@
static node*
build_node_children(PyObject *tuple, node *root, int *line_num)
{
- int len = PyObject_Size(tuple);
- int i, err;
+ Py_ssize_t len = PyObject_Size(tuple);
+ Py_ssize_t i;
+ int err;
for (i = 1; i < len; ++i) {
/* elem must always be a sequence, however simple */
@@ -663,7 +664,7 @@
return (0);
}
if (ISTERMINAL(type)) {
- int len = PyObject_Size(elem);
+ Py_ssize_t len = PyObject_Size(elem);
PyObject *temp;
if ((len != 2) && (len != 3)) {
Modified: python/branches/ssize_t/Modules/selectmodule.c
==============================================================================
--- python/branches/ssize_t/Modules/selectmodule.c (original)
+++ python/branches/ssize_t/Modules/selectmodule.c Tue Jan 3 11:25:55 2006
@@ -340,7 +340,7 @@
static int
update_ufd_array(pollObject *self)
{
- int i, pos;
+ Py_ssize_t i, pos;
PyObject *key, *value;
self->ufd_len = PyDict_Size(self->dict);
Modified: python/branches/ssize_t/Modules/shamodule.c
==============================================================================
--- python/branches/ssize_t/Modules/shamodule.c (original)
+++ python/branches/ssize_t/Modules/shamodule.c Tue Jan 3 11:25:55 2006
@@ -543,7 +543,7 @@
static PyObject *
SHA_new(PyObject *self, PyObject *args, PyObject *kwdict)
{
- static char *kwlist[] = {"string", NULL};
+ static const char *kwlist[] = {"string", NULL};
SHAobject *new;
unsigned char *cp = NULL;
int len;
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 11:25:55 2006
@@ -74,7 +74,7 @@
}
#undef PyObject_Length
-int
+Py_ssize_t
PyObject_Length(PyObject *o)
{
return PyObject_Size(o);
@@ -84,7 +84,7 @@
int
_PyObject_LengthCue(PyObject *o)
{
- int rv = PyObject_Size(o);
+ Py_ssize_t rv = PyObject_Size(o);
if (rv != -1)
return rv;
if (PyErr_ExceptionMatches(PyExc_TypeError) ||
@@ -1103,7 +1103,7 @@
s->ob_type->tp_as_sequence->sq_item != NULL;
}
-int
+Py_ssize_t
PySequence_Size(PyObject *s)
{
PySequenceMethods *m;
@@ -1122,7 +1122,7 @@
}
#undef PySequence_Length
-int
+Py_ssize_t
PySequence_Length(PyObject *s)
{
return PySequence_Size(s);
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 11:25:55 2006
@@ -690,7 +690,7 @@
* delete keys), via PyDict_SetItem().
*/
int
-PyDict_Next(PyObject *op, int *ppos, PyObject **pkey, PyObject **pvalue)
+PyDict_Next(PyObject *op, Py_ssize_t *ppos, PyObject **pkey, PyObject **pvalue)
{
register int i, mask;
register dictentry *ep;
@@ -786,7 +786,7 @@
static PyObject *
dict_repr(dictobject *mp)
{
- int i;
+ Py_ssize_t i;
PyObject *s, *temp, *colon = NULL;
PyObject *pieces = NULL, *result = NULL;
PyObject *key, *value;
@@ -1300,7 +1300,7 @@
return NULL;
}
-int
+Py_ssize_t
PyDict_Size(PyObject *mp)
{
if (mp == NULL || !PyDict_Check(mp)) {
@@ -1708,7 +1708,8 @@
static int
dict_traverse(PyObject *op, visitproc visit, void *arg)
{
- int i = 0, err;
+ Py_ssize_t i = 0;
+ int err;
PyObject *pk;
PyObject *pv;
Modified: python/branches/ssize_t/Objects/funcobject.c
==============================================================================
--- python/branches/ssize_t/Objects/funcobject.c (original)
+++ python/branches/ssize_t/Objects/funcobject.c Tue Jan 3 11:25:55 2006
@@ -529,7 +529,7 @@
}
if (kw != NULL && PyDict_Check(kw)) {
- int pos, i;
+ Py_ssize_t pos, i;
nk = PyDict_Size(kw);
k = PyMem_NEW(PyObject *, 2*nk);
if (k == NULL) {
Modified: python/branches/ssize_t/Objects/moduleobject.c
==============================================================================
--- python/branches/ssize_t/Objects/moduleobject.c (original)
+++ python/branches/ssize_t/Objects/moduleobject.c Tue Jan 3 11:25:55 2006
@@ -104,7 +104,7 @@
None, rather than deleting them from the dictionary, to
avoid rehashing the dictionary (to some extent). */
- int pos;
+ Py_ssize_t pos;
PyObject *key, *value;
PyObject *d;
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 11:25:55 2006
@@ -1949,7 +1949,7 @@
/* Hack to force loading of abstract.o */
-int (*_Py_abstract_hack)(PyObject *) = PyObject_Size;
+Py_ssize_t (*_Py_abstract_hack)(PyObject *) = PyObject_Size;
/* Python's malloc wrappers (see pymem.h) */
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 11:25:55 2006
@@ -468,9 +468,10 @@
* mutates the table.
*/
static int
-set_next(PySetObject *so, int *pos_ptr, setentry **entry_ptr)
+set_next(PySetObject *so, Py_ssize_t *pos_ptr, setentry **entry_ptr)
{
- register int i, mask;
+ Py_ssize_t i;
+ int mask;
register setentry *table;
assert (PyAnySet_Check(so));
@@ -517,7 +518,7 @@
set_tp_print(PySetObject *so, FILE *fp, int flags)
{
setentry *entry;
- int pos=0;
+ Py_ssize_t pos=0;
char *emit = ""; /* No separator emitted on first pass */
char *separator = ", ";
@@ -673,7 +674,7 @@
static int
set_traverse(PySetObject *so, visitproc visit, void *arg)
{
- int pos = 0;
+ Py_ssize_t pos = 0;
setentry *entry;
while (set_next(so, &pos, &entry))
@@ -687,7 +688,7 @@
PySetObject *so = (PySetObject *)self;
long h, hash = 1927868237L;
setentry *entry;
- int pos = 0;
+ Py_ssize_t pos = 0;
if (so->hash != -1)
return so->hash;
@@ -847,7 +848,7 @@
if (PyDict_Check(other)) {
PyObject *key, *value;
- int pos = 0;
+ Py_ssize_t pos = 0;
while (PyDict_Next(other, &pos, &key, &value)) {
if (set_add_key(so, key) == -1)
return -1;
@@ -1121,7 +1122,7 @@
return NULL;
if (PyAnySet_Check(other)) {
- int pos = 0;
+ Py_ssize_t pos = 0;
setentry *entry;
if (PySet_GET_SIZE(other) > PySet_GET_SIZE(so)) {
@@ -1222,7 +1223,7 @@
if (PyAnySet_Check(other)) {
setentry *entry;
- int pos = 0;
+ Py_ssize_t pos = 0;
while (set_next((PySetObject *)other, &pos, &entry))
set_discard_entry(so, entry);
@@ -1266,7 +1267,7 @@
{
PyObject *result;
setentry *entry;
- int pos = 0;
+ Py_ssize_t pos = 0;
if (!PyAnySet_Check(other) && !PyDict_Check(other)) {
result = set_copy(so);
@@ -1340,7 +1341,7 @@
{
PySetObject *otherset;
PyObject *key;
- int pos = 0;
+ Py_ssize_t pos = 0;
setentry *entry;
if ((PyObject *)so == other)
@@ -1442,7 +1443,7 @@
set_issubset(PySetObject *so, PyObject *other)
{
setentry *entry;
- int pos = 0;
+ Py_ssize_t pos = 0;
if (!PyAnySet_Check(other)) {
PyObject *tmp, *result;
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 11:25:55 2006
@@ -1101,7 +1101,7 @@
static void
set_mro_error(PyObject *to_merge, int *remain)
{
- int i, n, off, to_merge_size;
+ Py_ssize_t i, n, off, to_merge_size;
char buf[1000];
PyObject *k, *v;
PyObject *set = PyDict_New();
Modified: python/branches/ssize_t/Python/bltinmodule.c
==============================================================================
--- python/branches/ssize_t/Python/bltinmodule.c (original)
+++ python/branches/ssize_t/Python/bltinmodule.c Tue Jan 3 11:25:55 2006
@@ -824,7 +824,7 @@
PyObject *func, *result;
sequence *seqs = NULL, *sqp;
- int n, len;
+ Py_ssize_t n, len;
register int i, j;
n = PyTuple_Size(args);
@@ -1163,12 +1163,12 @@
static PyObject *
builtin_len(PyObject *self, PyObject *v)
{
- long res;
+ Py_ssize_t res;
res = PyObject_Size(v);
if (res < 0 && PyErr_Occurred())
return NULL;
- return PyInt_FromLong(res);
+ return PyInt_FromSsize_t(res);
}
PyDoc_STRVAR(len_doc,
@@ -2346,8 +2346,8 @@
filtertuple(PyObject *func, PyObject *tuple)
{
PyObject *result;
- register int i, j;
- int len = PyTuple_Size(tuple);
+ Py_ssize_t i, j;
+ Py_ssize_t len = PyTuple_Size(tuple);
if (len == 0) {
if (PyTuple_CheckExact(tuple))
@@ -2417,9 +2417,9 @@
filterstring(PyObject *func, PyObject *strobj)
{
PyObject *result;
- register int i, j;
- int len = PyString_Size(strobj);
- int outlen = len;
+ Py_ssize_t i, j;
+ Py_ssize_t len = PyString_Size(strobj);
+ Py_ssize_t outlen = len;
if (func == Py_None) {
/* If it's a real string we can return the original,
Modified: python/branches/ssize_t/Python/compile.c
==============================================================================
--- python/branches/ssize_t/Python/compile.c (original)
+++ python/branches/ssize_t/Python/compile.c Tue Jan 3 11:25:55 2006
@@ -317,7 +317,7 @@
static PyObject *
list2dict(PyObject *list)
{
- int i, n;
+ Py_ssize_t i, n;
PyObject *v, *k, *dict = PyDict_New();
n = PyList_Size(list);
@@ -352,7 +352,7 @@
static PyObject *
dictbytype(PyObject *src, int scope_type, int flag, int offset)
{
- int pos = 0, i = offset, scope;
+ Py_ssize_t pos = 0, i = offset, scope;
PyObject *k, *v, *dest = PyDict_New();
assert(offset >= 0);
@@ -407,7 +407,7 @@
tuple_of_constants(unsigned char *codestr, int n, PyObject *consts)
{
PyObject *newconst, *constant;
- int i, arg, len_consts;
+ Py_ssize_t i, arg, len_consts;
/* Pre-conditions */
assert(PyList_CheckExact(consts));
@@ -458,7 +458,8 @@
fold_binops_on_constants(unsigned char *codestr, PyObject *consts)
{
PyObject *newconst, *v, *w;
- int len_consts, opcode, size;
+ Py_ssize_t len_consts, size;
+ int opcode;
/* Pre-conditions */
assert(PyList_CheckExact(consts));
@@ -551,7 +552,8 @@
fold_unaryops_on_constants(unsigned char *codestr, PyObject *consts)
{
PyObject *newconst=NULL, *v;
- int len_consts, opcode;
+ Py_ssize_t len_consts;
+ int opcode;
/* Pre-conditions */
assert(PyList_CheckExact(consts));
@@ -653,7 +655,8 @@
static PyObject *
optimize_code(PyObject *code, PyObject* consts, PyObject *names, PyObject *lineno_obj)
{
- int i, j, codelen, nops, h, adj;
+ Py_ssize_t i, j, codelen;
+ int nops, h, adj;
int tgt, tgttgt, opcode;
unsigned char *codestr = NULL;
unsigned char *lineno;
@@ -989,7 +992,8 @@
compiler_display_symbols(PyObject *name, PyObject *symbols)
{
PyObject *key, *value;
- int flags, pos = 0;
+ int flags;
+ Py_ssize_t pos = 0;
fprintf(stderr, "block %s\n", PyString_AS_STRING(name));
while (PyDict_Next(symbols, &pos, &key, &value)) {
@@ -1498,7 +1502,7 @@
compiler_add_o(struct compiler *c, PyObject *dict, PyObject *o)
{
PyObject *t, *v;
- int arg;
+ Py_ssize_t arg;
/* necessary to make sure types aren't coerced (e.g., int and long) */
t = PyTuple_Pack(2, o, o->ob_type);
@@ -4032,7 +4036,7 @@
dict_keys_inorder(PyObject *dict, int offset)
{
PyObject *tuple, *k, *v;
- int i, pos = 0, size = PyDict_Size(dict);
+ Py_ssize_t i, pos = 0, size = PyDict_Size(dict);
tuple = PyTuple_New(size);
if (tuple == NULL)
Modified: python/branches/ssize_t/Python/getargs.c
==============================================================================
--- python/branches/ssize_t/Python/getargs.c (original)
+++ python/branches/ssize_t/Python/getargs.c Tue Jan 3 11:25:55 2006
@@ -1505,7 +1505,7 @@
/* make sure there are no extraneous keyword arguments */
if (nkeywords > 0) {
PyObject *key, *value;
- int pos = 0;
+ Py_ssize_t pos = 0;
while (PyDict_Next(keywords, &pos, &key, &value)) {
int match = 0;
char *ks;
Modified: python/branches/ssize_t/Python/import.c
==============================================================================
--- python/branches/ssize_t/Python/import.c (original)
+++ python/branches/ssize_t/Python/import.c Tue Jan 3 11:25:55 2006
@@ -351,7 +351,7 @@
void
PyImport_Cleanup(void)
{
- int pos, ndone;
+ Py_ssize_t pos, ndone;
char *name;
PyObject *key, *value, *dict;
PyInterpreterState *interp = PyThreadState_GET()->interp;
Modified: python/branches/ssize_t/Python/marshal.c
==============================================================================
--- python/branches/ssize_t/Python/marshal.c (original)
+++ python/branches/ssize_t/Python/marshal.c Tue Jan 3 11:25:55 2006
@@ -59,7 +59,7 @@
static void
w_more(int c, WFILE *p)
{
- int size, newsize;
+ Py_ssize_t size, newsize;
if (p->str == NULL)
return; /* An error already occurred */
size = PyString_Size(p->str);
@@ -117,7 +117,7 @@
static void
w_object(PyObject *v, WFILE *p)
{
- int i, n;
+ Py_ssize_t i, n;
p->depth++;
@@ -236,7 +236,7 @@
goto exit;
}
else {
- o = PyInt_FromLong(PyDict_Size(p->strings));
+ o = PyInt_FromSsize_t(PyDict_Size(p->strings));
PyDict_SetItem(p->strings, v, o);
Py_DECREF(o);
w_byte(TYPE_INTERNED, p);
@@ -282,7 +282,7 @@
}
}
else if (PyDict_Check(v)) {
- int pos;
+ Py_ssize_t pos;
PyObject *key, *value;
w_byte(TYPE_DICT, p);
/* This one is NULL object terminated! */
Modified: python/branches/ssize_t/Python/symtable.c
==============================================================================
--- python/branches/ssize_t/Python/symtable.c (original)
+++ python/branches/ssize_t/Python/symtable.c Tue Jan 3 11:25:55 2006
@@ -426,7 +426,8 @@
analyze_cells(PyObject *scope, PyObject *free)
{
PyObject *name, *v, *w;
- int flags, pos = 0, success = 0;
+ int flags, success = 0;
+ Py_ssize_t pos = 0;
w = PyInt_FromLong(CELL);
if (!w)
@@ -506,7 +507,8 @@
PyObject *bound, PyObject *free, int class)
{
PyObject *name, *v, *u, *w, *free_value = NULL;
- int i, flags, pos = 0;
+ int i, flags;
+ Py_ssize_t pos = 0;
while (PyDict_Next(symbols, &pos, &name, &v)) {
assert(PyInt_Check(v));
@@ -581,7 +583,8 @@
{
PyObject *name, *v, *local = NULL, *scope = NULL, *newbound = NULL;
PyObject *newglobal = NULL, *newfree = NULL;
- int i, flags, pos = 0, success = 0;
+ int i, flags, success = 0;
+ Py_ssize_t pos = 0;
local = PyDict_New();
if (!local)
More information about the Python-checkins
mailing list