Merge ssize_t branch.
diff --git a/Python/ceval.c b/Python/ceval.c
index 501a9a0..0f2b173 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -599,7 +599,7 @@
/* 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 @@
/* 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 @@
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 @@
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 @@
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 @@
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))