Merge ssize_t branch.

This commit is contained in:
Martin v. Löwis 2006-02-15 17:27:45 +00:00
parent 4482929734
commit 18e165558b
102 changed files with 2659 additions and 1677 deletions

View file

@ -599,7 +599,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throw)
/* Code access macros */
#define INSTR_OFFSET() (next_instr - first_instr)
#define INSTR_OFFSET() ((int)(next_instr - first_instr))
#define NEXTOP() (*next_instr++)
#define NEXTARG() (next_instr += 2, (next_instr[-1]<<8) + next_instr[-2])
#define PEEKARG() ((next_instr[2]<<8) + next_instr[1])
@ -637,7 +637,9 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throw)
/* Stack manipulation macros */
#define STACK_LEVEL() (stack_pointer - f->f_valuestack)
/* The stack can grow at most MAXINT deep, as co_nlocals and
co_stacksize are ints. */
#define STACK_LEVEL() ((int)(stack_pointer - f->f_valuestack))
#define EMPTY() (STACK_LEVEL() == 0)
#define TOP() (stack_pointer[-1])
#define SECOND() (stack_pointer[-2])
@ -3857,7 +3859,7 @@ ext_do_call(PyObject *func, PyObject ***pp_stack, int flags, int na, int nk)
called by the SLICE opcode with v and/or w equal to NULL.
*/
int
_PyEval_SliceIndex(PyObject *v, int *pi)
_PyEval_SliceIndex(PyObject *v, Py_ssize_t *pi)
{
if (v != NULL) {
long x;
@ -3906,6 +3908,7 @@ _PyEval_SliceIndex(PyObject *v, int *pi)
return 0;
}
/* Truncate -- very long indices are truncated anyway */
/* XXX truncate by ssize maximum */
if (x > INT_MAX)
x = INT_MAX;
else if (x < -INT_MAX)
@ -3925,7 +3928,7 @@ apply_slice(PyObject *u, PyObject *v, PyObject *w) /* return u[v:w] */
PySequenceMethods *sq = tp->tp_as_sequence;
if (sq && sq->sq_slice && ISINT(v) && ISINT(w)) {
int ilow = 0, ihigh = INT_MAX;
Py_ssize_t ilow = 0, ihigh = INT_MAX;
if (!_PyEval_SliceIndex(v, &ilow))
return NULL;
if (!_PyEval_SliceIndex(w, &ihigh))
@ -3952,7 +3955,7 @@ assign_slice(PyObject *u, PyObject *v, PyObject *w, PyObject *x)
PySequenceMethods *sq = tp->tp_as_sequence;
if (sq && sq->sq_slice && ISINT(v) && ISINT(w)) {
int ilow = 0, ihigh = INT_MAX;
Py_ssize_t ilow = 0, ihigh = INT_MAX;
if (!_PyEval_SliceIndex(v, &ilow))
return -1;
if (!_PyEval_SliceIndex(w, &ihigh))