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

@ -407,7 +407,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
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,10 +419,10 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
/* 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_LengthHint(PyObject *o);
PyAPI_FUNC(Py_ssize_t) _PyObject_LengthHint(PyObject *o);
/*
Return the size of object o. If the object, o, provides
@ -477,7 +477,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
PyAPI_FUNC(int) PyObject_AsCharBuffer(PyObject *obj,
const char **buffer,
int *buffer_len);
Py_ssize_t *buffer_len);
/*
Takes an arbitrary object which must support the (character,
@ -502,7 +502,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
PyAPI_FUNC(int) PyObject_AsReadBuffer(PyObject *obj,
const void **buffer,
int *buffer_len);
Py_ssize_t *buffer_len);
/*
Same as PyObject_AsCharBuffer() except that this API expects
@ -518,7 +518,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
PyAPI_FUNC(int) PyObject_AsWriteBuffer(PyObject *obj,
void **buffer,
int *buffer_len);
Py_ssize_t *buffer_len);
/*
Takes an arbitrary object which must support the (writeable,
@ -911,7 +911,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
*/
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.
@ -920,7 +920,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
/* 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
@ -933,7 +933,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
*/
PyAPI_FUNC(PyObject *) PySequence_Repeat(PyObject *o, int count);
PyAPI_FUNC(PyObject *) PySequence_Repeat(PyObject *o, Py_ssize_t count);
/*
Return the result of repeating sequence object o count times,
@ -942,14 +942,14 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
*/
PyAPI_FUNC(PyObject *) PySequence_GetItem(PyObject *o, int i);
PyAPI_FUNC(PyObject *) PySequence_GetItem(PyObject *o, Py_ssize_t i);
/*
Return the ith element of o, or NULL on failure. This is the
equivalent of the Python expression: o[i].
*/
PyAPI_FUNC(PyObject *) PySequence_GetSlice(PyObject *o, int i1, int i2);
PyAPI_FUNC(PyObject *) PySequence_GetSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2);
/*
Return the slice of sequence object o between i1 and i2, or
@ -958,7 +958,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
*/
PyAPI_FUNC(int) PySequence_SetItem(PyObject *o, int i, PyObject *v);
PyAPI_FUNC(int) PySequence_SetItem(PyObject *o, Py_ssize_t i, PyObject *v);
/*
Assign object v to the ith element of o. Returns
@ -967,7 +967,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
*/
PyAPI_FUNC(int) PySequence_DelItem(PyObject *o, int i);
PyAPI_FUNC(int) PySequence_DelItem(PyObject *o, Py_ssize_t i);
/*
Delete the ith element of object v. Returns
@ -975,7 +975,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
statement: del o[i].
*/
PyAPI_FUNC(int) PySequence_SetSlice(PyObject *o, int i1, int i2,
PyAPI_FUNC(int) PySequence_SetSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2,
PyObject *v);
/*
@ -984,7 +984,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
equivalent of the Python statement: o[i1:i2]=v.
*/
PyAPI_FUNC(int) PySequence_DelSlice(PyObject *o, int i1, int i2);
PyAPI_FUNC(int) PySequence_DelSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2);
/*
Delete the slice in sequence object, o, from i1 to i2.
@ -1105,7 +1105,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
*/
PyAPI_FUNC(PyObject *) PySequence_InPlaceRepeat(PyObject *o, int count);
PyAPI_FUNC(PyObject *) PySequence_InPlaceRepeat(PyObject *o, Py_ssize_t count);
/*
Repeat o1 by count, in-place when possible. Return the resulting
@ -1125,7 +1125,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
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
@ -1135,7 +1135,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
/* 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

View File

@ -17,15 +17,15 @@ PyAPI_DATA(PyTypeObject) PyBuffer_Type;
#define Py_END_OF_BUFFER (-1)
PyAPI_FUNC(PyObject *) PyBuffer_FromObject(PyObject *base,
int offset, int size);
Py_ssize_t offset, Py_ssize_t size);
PyAPI_FUNC(PyObject *) PyBuffer_FromReadWriteObject(PyObject *base,
int offset,
int size);
Py_ssize_t offset,
Py_ssize_t size);
PyAPI_FUNC(PyObject *) PyBuffer_FromMemory(void *ptr, int size);
PyAPI_FUNC(PyObject *) PyBuffer_FromReadWriteMemory(void *ptr, int size);
PyAPI_FUNC(PyObject *) PyBuffer_FromMemory(void *ptr, Py_ssize_t size);
PyAPI_FUNC(PyObject *) PyBuffer_FromReadWriteMemory(void *ptr, Py_ssize_t size);
PyAPI_FUNC(PyObject *) PyBuffer_New(int size);
PyAPI_FUNC(PyObject *) PyBuffer_New(Py_ssize_t size);
#ifdef __cplusplus
}

View File

@ -29,7 +29,7 @@ static struct PycStringIO_CAPI {
/* Read a string from an input object. If the last argument
is -1, the remainder will be read.
*/
int(*cread)(PyObject *, char **, int);
int(*cread)(PyObject *, char **, Py_ssize_t);
/* Read a line from an input object. Returns the length of the read
line as an int and a pointer inside the object buffer as char** (so
@ -38,7 +38,7 @@ static struct PycStringIO_CAPI {
int(*creadline)(PyObject *, char **);
/* Write a string to an output object*/
int(*cwrite)(PyObject *, const char *, int);
int(*cwrite)(PyObject *, const char *, Py_ssize_t);
/* Get the output object as a Python string (returns new reference). */
PyObject *(*cgetvalue)(PyObject *);

View File

@ -148,7 +148,7 @@ PyAPI_FUNC(void) PyEval_ReInitThreads(void);
#endif /* !WITH_THREAD */
PyAPI_FUNC(int) _PyEval_SliceIndex(PyObject *, int *);
PyAPI_FUNC(int) _PyEval_SliceIndex(PyObject *, Py_ssize_t *);
#ifdef __cplusplus

View File

@ -95,11 +95,11 @@ PyAPI_FUNC(int) PyDict_SetItem(PyObject *mp, PyObject *key, PyObject *item);
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);

View File

@ -32,10 +32,13 @@ PyAPI_DATA(PyTypeObject) PyInt_Type;
PyAPI_FUNC(PyObject *) PyInt_FromString(char*, char**, int);
#ifdef Py_USING_UNICODE
PyAPI_FUNC(PyObject *) PyInt_FromUnicode(Py_UNICODE*, int, int);
PyAPI_FUNC(PyObject *) PyInt_FromUnicode(Py_UNICODE*, Py_ssize_t, int);
#endif
PyAPI_FUNC(PyObject *) PyInt_FromLong(long);
PyAPI_FUNC(PyObject *) PyInt_FromSize_t(size_t);
PyAPI_FUNC(PyObject *) PyInt_FromSsize_t(Py_ssize_t);
PyAPI_FUNC(long) PyInt_AsLong(PyObject *);
PyAPI_FUNC(Py_ssize_t) PyInt_AsSsize_t(PyObject *);
PyAPI_FUNC(unsigned long) PyInt_AsUnsignedLongMask(PyObject *);
#ifdef HAVE_LONG_LONG
PyAPI_FUNC(unsigned PY_LONG_LONG) PyInt_AsUnsignedLongLongMask(PyObject *);

View File

@ -35,7 +35,7 @@ typedef struct {
* Items must normally not be NULL, except during construction when
* the list is not yet visible outside the function that builds it.
*/
int allocated;
Py_ssize_t allocated;
} PyListObject;
PyAPI_DATA(PyTypeObject) PyList_Type;
@ -43,14 +43,14 @@ PyAPI_DATA(PyTypeObject) PyList_Type;
#define PyList_Check(op) PyObject_TypeCheck(op, &PyList_Type)
#define PyList_CheckExact(op) ((op)->ob_type == &PyList_Type)
PyAPI_FUNC(PyObject *) PyList_New(int size);
PyAPI_FUNC(int) PyList_Size(PyObject *);
PyAPI_FUNC(PyObject *) PyList_GetItem(PyObject *, int);
PyAPI_FUNC(int) PyList_SetItem(PyObject *, int, PyObject *);
PyAPI_FUNC(int) PyList_Insert(PyObject *, int, PyObject *);
PyAPI_FUNC(PyObject *) PyList_New(Py_ssize_t size);
PyAPI_FUNC(Py_ssize_t) PyList_Size(PyObject *);
PyAPI_FUNC(PyObject *) PyList_GetItem(PyObject *, Py_ssize_t);
PyAPI_FUNC(int) PyList_SetItem(PyObject *, Py_ssize_t, PyObject *);
PyAPI_FUNC(int) PyList_Insert(PyObject *, Py_ssize_t, PyObject *);
PyAPI_FUNC(int) PyList_Append(PyObject *, PyObject *);
PyAPI_FUNC(PyObject *) PyList_GetSlice(PyObject *, int, int);
PyAPI_FUNC(int) PyList_SetSlice(PyObject *, int, int, PyObject *);
PyAPI_FUNC(PyObject *) PyList_GetSlice(PyObject *, Py_ssize_t, Py_ssize_t);
PyAPI_FUNC(int) PyList_SetSlice(PyObject *, Py_ssize_t, Py_ssize_t, PyObject *);
PyAPI_FUNC(int) PyList_Sort(PyObject *);
PyAPI_FUNC(int) PyList_Reverse(PyObject *);
PyAPI_FUNC(PyObject *) PyList_AsTuple(PyObject *);

View File

@ -52,7 +52,7 @@ struct _longobject {
digit ob_digit[1];
};
PyAPI_FUNC(PyLongObject *) _PyLong_New(int);
PyAPI_FUNC(PyLongObject *) _PyLong_New(Py_ssize_t);
/* Return a copy of src. */
PyAPI_FUNC(PyObject *) _PyLong_Copy(PyLongObject *src);

View File

@ -21,6 +21,11 @@ PyAPI_FUNC(long) PyLong_AsLong(PyObject *);
PyAPI_FUNC(unsigned long) PyLong_AsUnsignedLong(PyObject *);
PyAPI_FUNC(unsigned long) PyLong_AsUnsignedLongMask(PyObject *);
/* For use by intobject.c only */
PyAPI_FUNC(Py_ssize_t) _PyLong_AsSsize_t(PyObject *);
PyAPI_FUNC(PyObject *) _PyLong_FromSize_t(size_t);
PyAPI_FUNC(PyObject *) _PyLong_FromSsize_t(Py_ssize_t);
/* _PyLong_AsScaledDouble returns a double x and an exponent e such that
the true value is approximately equal to x * 2**(SHIFT*e). e is >= 0.
x is 0.0 if and only if the input is 0 (in which case, e and x are both
@ -43,7 +48,7 @@ PyAPI_FUNC(unsigned PY_LONG_LONG) PyLong_AsUnsignedLongLongMask(PyObject *);
PyAPI_FUNC(PyObject *) PyLong_FromString(char *, char **, int);
#ifdef Py_USING_UNICODE
PyAPI_FUNC(PyObject *) PyLong_FromUnicode(Py_UNICODE*, int, int);
PyAPI_FUNC(PyObject *) PyLong_FromUnicode(Py_UNICODE*, Py_ssize_t, int);
#endif
/* _PyLong_Sign. Return 0 if v is 0, -1 if v < 0, +1 if v > 0.

View File

@ -17,7 +17,7 @@ PyAPI_FUNC(long) PyMarshal_ReadLongFromFile(FILE *);
PyAPI_FUNC(int) PyMarshal_ReadShortFromFile(FILE *);
PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromFile(FILE *);
PyAPI_FUNC(PyObject *) PyMarshal_ReadLastObjectFromFile(FILE *);
PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromString(char *, int);
PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromString(char *, Py_ssize_t);
#ifdef __cplusplus
}

View File

@ -9,6 +9,18 @@ extern "C" {
#include <stdarg.h>
/* If PY_SSIZE_T_CLEAN is defined, each functions treats #-specifier
to mean Py_ssize_t */
#ifdef PY_SSIZE_T_CLEAN
#define PyArg_Parse _PyArg_Parse_SizeT
#define PyArg_ParseTuple _PyArg_ParseTuple_SizeT
#define PyArg_ParseTupleAndKeywords _PyArg_ParseTupleAndKeywords_SizeT
#define PyArg_VaParse _PyArg_VaParse_SizeT
#define PyArg_VaParseTupleAndKeywords _PyArg_VaParseTupleAndKeywords_SizeT
#define PyArg_BuildValue _PyArg_BuildValue_SizeT
#define PyArg_VaBuildValue _PyArg_VaBuildValue_SizeT
#endif
PyAPI_FUNC(int) PyArg_Parse(PyObject *, const char *, ...);
PyAPI_FUNC(int) PyArg_ParseTuple(PyObject *, const char *, ...);
PyAPI_FUNC(int) PyArg_ParseTupleAndKeywords(PyObject *, PyObject *,
@ -26,6 +38,7 @@ PyAPI_FUNC(int) PyModule_AddObject(PyObject *, const char *, PyObject *);
PyAPI_FUNC(int) PyModule_AddIntConstant(PyObject *, const char *, long);
PyAPI_FUNC(int) PyModule_AddStringConstant(PyObject *, const char *, const char *);
#define PYTHON_API_VERSION 1012
#define PYTHON_API_STRING "1012"
/* The API version is maintained (independently from the Python version)
@ -77,11 +90,22 @@ PyAPI_FUNC(int) PyModule_AddStringConstant(PyObject *, const char *, const char
without actually needing a recompile. */
#endif /* MS_WINDOWS */
#if SIZEOF_SIZE_T != SIZEOF_INT
/* On a 64-bit system, rename the Py_InitModule4 so that 2.4
modules cannot get loaded into a 2.5 interpreter */
#define Py_InitModule4 Py_InitModule4_64
#endif
#ifdef Py_TRACE_REFS
/* When we are tracing reference counts, rename Py_InitModule4 so
/* When we are tracing reference counts, rename Py_InitModule4 so
modules compiled with incompatible settings will generate a
link-time error. */
#define Py_InitModule4 Py_InitModule4TraceRefs
#if SIZEOF_SIZE_T != SIZEOF_INT
#undef Py_InitModule4
#define Py_InitModule4 Py_InitModule4TraceRefs_64
#else
#define Py_InitModule4 Py_InitModule4TraceRefs
#endif
#endif
PyAPI_FUNC(PyObject *) Py_InitModule4(const char *name, PyMethodDef *methods,

View File

@ -92,7 +92,8 @@ whose size is determined when the object is allocated.
*/
#define PyObject_VAR_HEAD \
PyObject_HEAD \
int ob_size; /* Number of items in variable part */
Py_ssize_t ob_size; /* Number of items in variable part */
#define Py_INVALID_SIZE (Py_ssize_t)-1
/* Nothing is actually declared to be a PyObject, but every pointer to
* a Python object can be cast to a PyObject*. This is inheritance built
@ -127,16 +128,29 @@ typedef PyObject * (*unaryfunc)(PyObject *);
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);
typedef PyObject *(*intintargfunc)(PyObject *, int, int);
typedef PyObject *(*intargfunc)(PyObject *, int) Py_DEPRECATED(2.5);
typedef PyObject *(*intintargfunc)(PyObject *, int, int) Py_DEPRECATED(2.5);
typedef PyObject *(*ssizeargfunc)(PyObject *, Py_ssize_t);
typedef PyObject *(*ssizessizeargfunc)(PyObject *, Py_ssize_t, Py_ssize_t);
typedef int(*intobjargproc)(PyObject *, int, PyObject *);
typedef int(*intintobjargproc)(PyObject *, int, int, PyObject *);
typedef int(*ssizeobjargproc)(PyObject *, Py_ssize_t, PyObject *);
typedef int(*ssizessizeobjargproc)(PyObject *, Py_ssize_t, Py_ssize_t, PyObject *);
typedef int(*objobjargproc)(PyObject *, PyObject *, PyObject *);
/* int-based buffer interface */
typedef int (*getreadbufferproc)(PyObject *, int, void **);
typedef int (*getwritebufferproc)(PyObject *, int, void **);
typedef int (*getsegcountproc)(PyObject *, int *);
typedef int (*getcharbufferproc)(PyObject *, int, const char **);
/* ssize_t-based buffer interface */
typedef Py_ssize_t (*readbufferproc)(PyObject *, Py_ssize_t, void **);
typedef Py_ssize_t (*writebufferproc)(PyObject *, Py_ssize_t, void **);
typedef Py_ssize_t (*segcountproc)(PyObject *, Py_ssize_t *);
typedef Py_ssize_t (*charbufferproc)(PyObject *, Py_ssize_t, const char **);
typedef int (*objobjproc)(PyObject *, PyObject *);
typedef int (*visitproc)(PyObject *, void *);
typedef int (*traverseproc)(PyObject *, visitproc, void *);
@ -195,30 +209,30 @@ typedef struct {
} PyNumberMethods;
typedef struct {
inquiry sq_length;
lenfunc sq_length;
binaryfunc sq_concat;
intargfunc sq_repeat;
intargfunc sq_item;
intintargfunc sq_slice;
intobjargproc sq_ass_item;
intintobjargproc sq_ass_slice;
ssizeargfunc sq_repeat;
ssizeargfunc sq_item;
ssizessizeargfunc sq_slice;
ssizeobjargproc sq_ass_item;
ssizessizeobjargproc sq_ass_slice;
objobjproc sq_contains;
/* Added in release 2.0 */
binaryfunc sq_inplace_concat;
intargfunc sq_inplace_repeat;
ssizeargfunc sq_inplace_repeat;
} PySequenceMethods;
typedef struct {
inquiry mp_length;
lenfunc mp_length;
binaryfunc mp_subscript;
objobjargproc mp_ass_subscript;
} PyMappingMethods;
typedef struct {
getreadbufferproc bf_getreadbuffer;
getwritebufferproc bf_getwritebuffer;
getsegcountproc bf_getsegcount;
getcharbufferproc bf_getcharbuffer;
readbufferproc bf_getreadbuffer;
writebufferproc bf_getwritebuffer;
segcountproc bf_getsegcount;
charbufferproc bf_getcharbuffer;
} PyBufferProcs;
@ -239,7 +253,7 @@ typedef PyObject *(*descrgetfunc) (PyObject *, PyObject *, PyObject *);
typedef int (*descrsetfunc) (PyObject *, PyObject *, PyObject *);
typedef int (*initproc)(PyObject *, PyObject *, PyObject *);
typedef PyObject *(*newfunc)(struct _typeobject *, PyObject *, PyObject *);
typedef PyObject *(*allocfunc)(struct _typeobject *, int);
typedef PyObject *(*allocfunc)(struct _typeobject *, Py_ssize_t);
typedef struct _typeobject {
PyObject_VAR_HEAD
@ -362,7 +376,7 @@ PyAPI_DATA(PyTypeObject) PySuper_Type; /* built-in 'super' */
#define PyType_CheckExact(op) ((op)->ob_type == &PyType_Type)
PyAPI_FUNC(int) PyType_Ready(PyTypeObject *);
PyAPI_FUNC(PyObject *) PyType_GenericAlloc(PyTypeObject *, int);
PyAPI_FUNC(PyObject *) PyType_GenericAlloc(PyTypeObject *, Py_ssize_t);
PyAPI_FUNC(PyObject *) PyType_GenericNew(PyTypeObject *,
PyObject *, PyObject *);
PyAPI_FUNC(PyObject *) _PyType_Lookup(PyTypeObject *, PyObject *);

View File

@ -146,9 +146,9 @@ PyAPI_FUNC(void) _PyObject_DebugMallocStats(void);
/* Functions */
PyAPI_FUNC(PyObject *) PyObject_Init(PyObject *, PyTypeObject *);
PyAPI_FUNC(PyVarObject *) PyObject_InitVar(PyVarObject *,
PyTypeObject *, int);
PyTypeObject *, Py_ssize_t);
PyAPI_FUNC(PyObject *) _PyObject_New(PyTypeObject *);
PyAPI_FUNC(PyVarObject *) _PyObject_NewVar(PyTypeObject *, int);
PyAPI_FUNC(PyVarObject *) _PyObject_NewVar(PyTypeObject *, Py_ssize_t);
#define PyObject_New(type, typeobj) \
( (type *) _PyObject_New(typeobj) )
@ -291,7 +291,7 @@ extern PyGC_Head *_PyGC_generation0;
PyAPI_FUNC(PyObject *) _PyObject_GC_Malloc(size_t);
PyAPI_FUNC(PyObject *) _PyObject_GC_New(PyTypeObject *);
PyAPI_FUNC(PyVarObject *) _PyObject_GC_NewVar(PyTypeObject *, int);
PyAPI_FUNC(PyVarObject *) _PyObject_GC_NewVar(PyTypeObject *, Py_ssize_t);
PyAPI_FUNC(void) PyObject_GC_Track(void *);
PyAPI_FUNC(void) PyObject_GC_UnTrack(void *);
PyAPI_FUNC(void) PyObject_GC_Del(void *);

View File

@ -156,15 +156,15 @@ PyAPI_FUNC(PyObject *) PyErr_ProgramText(const char *, int);
/* create a UnicodeDecodeError object */
PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_Create(
const char *, const char *, int, int, int, const char *);
const char *, const char *, Py_ssize_t, Py_ssize_t, Py_ssize_t, const char *);
/* create a UnicodeEncodeError object */
PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_Create(
const char *, const Py_UNICODE *, int, int, int, const char *);
const char *, const Py_UNICODE *, Py_ssize_t, Py_ssize_t, Py_ssize_t, const char *);
/* create a UnicodeTranslateError object */
PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_Create(
const Py_UNICODE *, int, int, int, const char *);
const Py_UNICODE *, Py_ssize_t, Py_ssize_t, Py_ssize_t, const char *);
/* get the encoding attribute */
PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_GetEncoding(PyObject *);
@ -177,27 +177,27 @@ PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_GetObject(PyObject *);
/* get the value of the start attribute (the int * may not be NULL)
return 0 on success, -1 on failure */
PyAPI_FUNC(int) PyUnicodeEncodeError_GetStart(PyObject *, int *);
PyAPI_FUNC(int) PyUnicodeDecodeError_GetStart(PyObject *, int *);
PyAPI_FUNC(int) PyUnicodeTranslateError_GetStart(PyObject *, int *);
PyAPI_FUNC(int) PyUnicodeEncodeError_GetStart(PyObject *, Py_ssize_t *);
PyAPI_FUNC(int) PyUnicodeDecodeError_GetStart(PyObject *, Py_ssize_t *);
PyAPI_FUNC(int) PyUnicodeTranslateError_GetStart(PyObject *, Py_ssize_t *);
/* assign a new value to the start attribute
return 0 on success, -1 on failure */
PyAPI_FUNC(int) PyUnicodeEncodeError_SetStart(PyObject *, int);
PyAPI_FUNC(int) PyUnicodeDecodeError_SetStart(PyObject *, int);
PyAPI_FUNC(int) PyUnicodeTranslateError_SetStart(PyObject *, int);
PyAPI_FUNC(int) PyUnicodeEncodeError_SetStart(PyObject *, Py_ssize_t);
PyAPI_FUNC(int) PyUnicodeDecodeError_SetStart(PyObject *, Py_ssize_t);
PyAPI_FUNC(int) PyUnicodeTranslateError_SetStart(PyObject *, Py_ssize_t);
/* get the value of the end attribute (the int *may not be NULL)
return 0 on success, -1 on failure */
PyAPI_FUNC(int) PyUnicodeEncodeError_GetEnd(PyObject *, int *);
PyAPI_FUNC(int) PyUnicodeDecodeError_GetEnd(PyObject *, int *);
PyAPI_FUNC(int) PyUnicodeTranslateError_GetEnd(PyObject *, int *);
PyAPI_FUNC(int) PyUnicodeEncodeError_GetEnd(PyObject *, Py_ssize_t *);
PyAPI_FUNC(int) PyUnicodeDecodeError_GetEnd(PyObject *, Py_ssize_t *);
PyAPI_FUNC(int) PyUnicodeTranslateError_GetEnd(PyObject *, Py_ssize_t *);
/* assign a new value to the end attribute
return 0 on success, -1 on failure */
PyAPI_FUNC(int) PyUnicodeEncodeError_SetEnd(PyObject *, int);
PyAPI_FUNC(int) PyUnicodeDecodeError_SetEnd(PyObject *, int);
PyAPI_FUNC(int) PyUnicodeTranslateError_SetEnd(PyObject *, int);
PyAPI_FUNC(int) PyUnicodeEncodeError_SetEnd(PyObject *, Py_ssize_t);
PyAPI_FUNC(int) PyUnicodeDecodeError_SetEnd(PyObject *, Py_ssize_t);
PyAPI_FUNC(int) PyUnicodeTranslateError_SetEnd(PyObject *, Py_ssize_t);
/* get the value of the reason attribute */
PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_GetReason(PyObject *);

View File

@ -85,6 +85,15 @@ typedef PY_LONG_LONG Py_intptr_t;
# error "Python needs a typedef for Py_uintptr_t in pyport.h."
#endif /* HAVE_UINTPTR_T */
#ifdef HAVE_SSIZE_T
typedef ssize_t Py_ssize_t;
#elif SIZEOF_VOID_P == SIZEOF_SIZE_T
typedef Py_uintptr_t Py_ssize_t;
#else
# error "Python needs a typedef for Py_ssize_t in pyport.h."
#endif
#define PY_SSIZE_T_MAX ((Py_ssize_t)(((size_t)-1)>>1))
#include <stdlib.h>
#include <math.h> /* Moved here from the math section, before extern "C" */

View File

@ -8,7 +8,7 @@ extern "C" {
PyAPI_FUNC(double) PyOS_ascii_strtod(const char *str, char **ptr);
PyAPI_FUNC(double) PyOS_ascii_atof(const char *str);
PyAPI_FUNC(char *) PyOS_ascii_formatd(char *buffer, int buf_len, const char *format, double d);
PyAPI_FUNC(char *) PyOS_ascii_formatd(char *buffer, size_t buf_len, const char *format, double d);
#ifdef __cplusplus

View File

@ -30,11 +30,11 @@ PyAPI_DATA(PyTypeObject) PySlice_Type;
PyAPI_FUNC(PyObject *) PySlice_New(PyObject* start, PyObject* stop,
PyObject* step);
PyAPI_FUNC(int) PySlice_GetIndices(PySliceObject *r, int length,
int *start, int *stop, int *step);
PyAPI_FUNC(int) PySlice_GetIndicesEx(PySliceObject *r, int length,
int *start, int *stop,
int *step, int *slicelength);
PyAPI_FUNC(int) PySlice_GetIndices(PySliceObject *r, Py_ssize_t length,
Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step);
PyAPI_FUNC(int) PySlice_GetIndicesEx(PySliceObject *r, Py_ssize_t length,
Py_ssize_t *start, Py_ssize_t *stop,
Py_ssize_t *step, Py_ssize_t *slicelength);
#ifdef __cplusplus
}

View File

@ -58,24 +58,24 @@ PyAPI_DATA(PyTypeObject) PyString_Type;
#define PyString_Check(op) PyObject_TypeCheck(op, &PyString_Type)
#define PyString_CheckExact(op) ((op)->ob_type == &PyString_Type)
PyAPI_FUNC(PyObject *) PyString_FromStringAndSize(const char *, int);
PyAPI_FUNC(PyObject *) PyString_FromStringAndSize(const char *, Py_ssize_t);
PyAPI_FUNC(PyObject *) PyString_FromString(const char *);
PyAPI_FUNC(PyObject *) PyString_FromFormatV(const char*, va_list)
Py_GCC_ATTRIBUTE((format(printf, 1, 0)));
PyAPI_FUNC(PyObject *) PyString_FromFormat(const char*, ...)
Py_GCC_ATTRIBUTE((format(printf, 1, 2)));
PyAPI_FUNC(int) PyString_Size(PyObject *);
PyAPI_FUNC(Py_ssize_t) PyString_Size(PyObject *);
PyAPI_FUNC(char *) PyString_AsString(PyObject *);
PyAPI_FUNC(PyObject *) PyString_Repr(PyObject *, int);
PyAPI_FUNC(void) PyString_Concat(PyObject **, PyObject *);
PyAPI_FUNC(void) PyString_ConcatAndDel(PyObject **, PyObject *);
PyAPI_FUNC(int) _PyString_Resize(PyObject **, int);
PyAPI_FUNC(int) _PyString_Resize(PyObject **, Py_ssize_t);
PyAPI_FUNC(int) _PyString_Eq(PyObject *, PyObject*);
PyAPI_FUNC(PyObject *) PyString_Format(PyObject *, PyObject *);
PyAPI_FUNC(PyObject *) _PyString_FormatLong(PyObject*, int, int,
int, char**, int*);
PyAPI_FUNC(PyObject *) PyString_DecodeEscape(const char *, int,
const char *, int,
PyAPI_FUNC(PyObject *) PyString_DecodeEscape(const char *, Py_ssize_t,
const char *, Py_ssize_t,
const char *);
PyAPI_FUNC(void) PyString_InternInPlace(PyObject **);
@ -101,7 +101,7 @@ PyAPI_FUNC(PyObject *) _PyString_Join(PyObject *sep, PyObject *x);
PyAPI_FUNC(PyObject*) PyString_Decode(
const char *s, /* encoded string */
int size, /* size of buffer */
Py_ssize_t size, /* size of buffer */
const char *encoding, /* encoding */
const char *errors /* error handling */
);
@ -111,7 +111,7 @@ PyAPI_FUNC(PyObject*) PyString_Decode(
PyAPI_FUNC(PyObject*) PyString_Encode(
const char *s, /* string char buffer */
int size, /* number of chars to encode */
Py_ssize_t size, /* number of chars to encode */
const char *encoding, /* encoding */
const char *errors /* error handling */
);
@ -171,7 +171,7 @@ PyAPI_FUNC(PyObject*) PyString_AsDecodedString(
PyAPI_FUNC(int) PyString_AsStringAndSize(
register PyObject *obj, /* string or Unicode object */
register char **s, /* pointer to buffer variable */
register int *len /* pointer to length variable or NULL
register Py_ssize_t *len /* pointer to length variable or NULL
(only possible for 0-terminated
strings) */
);

View File

@ -36,13 +36,13 @@ PyAPI_DATA(PyTypeObject) PyTuple_Type;
#define PyTuple_Check(op) PyObject_TypeCheck(op, &PyTuple_Type)
#define PyTuple_CheckExact(op) ((op)->ob_type == &PyTuple_Type)
PyAPI_FUNC(PyObject *) PyTuple_New(int size);
PyAPI_FUNC(int) PyTuple_Size(PyObject *);
PyAPI_FUNC(PyObject *) PyTuple_GetItem(PyObject *, int);
PyAPI_FUNC(int) PyTuple_SetItem(PyObject *, int, PyObject *);
PyAPI_FUNC(PyObject *) PyTuple_GetSlice(PyObject *, int, int);
PyAPI_FUNC(int) _PyTuple_Resize(PyObject **, int);
PyAPI_FUNC(PyObject *) PyTuple_Pack(int, ...);
PyAPI_FUNC(PyObject *) PyTuple_New(Py_ssize_t size);
PyAPI_FUNC(Py_ssize_t) PyTuple_Size(PyObject *);
PyAPI_FUNC(PyObject *) PyTuple_GetItem(PyObject *, Py_ssize_t);
PyAPI_FUNC(int) PyTuple_SetItem(PyObject *, Py_ssize_t, PyObject *);
PyAPI_FUNC(PyObject *) PyTuple_GetSlice(PyObject *, Py_ssize_t, Py_ssize_t);
PyAPI_FUNC(int) _PyTuple_Resize(PyObject **, Py_ssize_t);
PyAPI_FUNC(PyObject *) PyTuple_Pack(Py_ssize_t, ...);
/* Macro, trading safety for speed */
#define PyTuple_GET_ITEM(op, i) (((PyTupleObject *)(op))->ob_item[i])

View File

@ -372,7 +372,7 @@ extern "C" {
typedef struct {
PyObject_HEAD
int length; /* Length of raw Unicode data in buffer */
Py_ssize_t length; /* Length of raw Unicode data in buffer */
Py_UNICODE *str; /* Raw Unicode buffer */
long hash; /* Hash value; -1 if not set */
PyObject *defenc; /* (Default) Encoded version as Python
@ -420,7 +420,7 @@ PyAPI_DATA(PyTypeObject) PyUnicode_Type;
PyAPI_FUNC(PyObject*) PyUnicode_FromUnicode(
const Py_UNICODE *u, /* Unicode buffer */
int size /* size of buffer */
Py_ssize_t size /* size of buffer */
);
/* Return a read-only pointer to the Unicode object's internal
@ -432,7 +432,7 @@ PyAPI_FUNC(Py_UNICODE *) PyUnicode_AsUnicode(
/* Get the length of the Unicode object. */
PyAPI_FUNC(int) PyUnicode_GetSize(
PyAPI_FUNC(Py_ssize_t) PyUnicode_GetSize(
PyObject *unicode /* Unicode object */
);
@ -455,7 +455,7 @@ PyAPI_FUNC(Py_UNICODE) PyUnicode_GetMax(void);
PyAPI_FUNC(int) PyUnicode_Resize(
PyObject **unicode, /* Pointer to the Unicode object */
int length /* New length */
Py_ssize_t length /* New length */
);
/* Coerce obj to an Unicode object and return a reference with
@ -509,7 +509,7 @@ PyAPI_FUNC(PyObject*) PyUnicode_FromObject(
PyAPI_FUNC(PyObject*) PyUnicode_FromWideChar(
register const wchar_t *w, /* wchar_t buffer */
int size /* size of buffer */
Py_ssize_t size /* size of buffer */
);
/* Copies the Unicode Object contents into the wchar_t buffer w. At
@ -524,10 +524,10 @@ PyAPI_FUNC(PyObject*) PyUnicode_FromWideChar(
possibly trailing 0-termination character) or -1 in case of an
error. */
PyAPI_FUNC(int) PyUnicode_AsWideChar(
PyAPI_FUNC(Py_ssize_t) PyUnicode_AsWideChar(
PyUnicodeObject *unicode, /* Unicode object */
register wchar_t *w, /* wchar_t buffer */
int size /* size of buffer */
Py_ssize_t size /* size of buffer */
);
#endif
@ -609,7 +609,7 @@ PyAPI_FUNC(int) PyUnicode_SetDefaultEncoding(
PyAPI_FUNC(PyObject*) PyUnicode_Decode(
const char *s, /* encoded string */
int size, /* size of buffer */
Py_ssize_t size, /* size of buffer */
const char *encoding, /* encoding */
const char *errors /* error handling */
);
@ -619,7 +619,7 @@ PyAPI_FUNC(PyObject*) PyUnicode_Decode(
PyAPI_FUNC(PyObject*) PyUnicode_Encode(
const Py_UNICODE *s, /* Unicode char buffer */
int size, /* number of Py_UNICODE chars to encode */
Py_ssize_t size, /* number of Py_UNICODE chars to encode */
const char *encoding, /* encoding */
const char *errors /* error handling */
);
@ -646,13 +646,13 @@ PyAPI_FUNC(PyObject*) PyUnicode_AsEncodedString(
PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF7(
const char *string, /* UTF-7 encoded string */
int length, /* size of string */
Py_ssize_t length, /* size of string */
const char *errors /* error handling */
);
PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF7(
const Py_UNICODE *data, /* Unicode char buffer */
int length, /* number of Py_UNICODE chars to encode */
Py_ssize_t length, /* number of Py_UNICODE chars to encode */
int encodeSetO, /* force the encoder to encode characters in
Set O, as described in RFC2152 */
int encodeWhiteSpace, /* force the encoder to encode space, tab,
@ -664,15 +664,15 @@ PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF7(
PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF8(
const char *string, /* UTF-8 encoded string */
int length, /* size of string */
Py_ssize_t length, /* size of string */
const char *errors /* error handling */
);
PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF8Stateful(
const char *string, /* UTF-8 encoded string */
int length, /* size of string */
Py_ssize_t length, /* size of string */
const char *errors, /* error handling */
int *consumed /* bytes consumed */
Py_ssize_t *consumed /* bytes consumed */
);
PyAPI_FUNC(PyObject*) PyUnicode_AsUTF8String(
@ -681,7 +681,7 @@ PyAPI_FUNC(PyObject*) PyUnicode_AsUTF8String(
PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF8(
const Py_UNICODE *data, /* Unicode char buffer */
int length, /* number of Py_UNICODE chars to encode */
Py_ssize_t length, /* number of Py_UNICODE chars to encode */
const char *errors /* error handling */
);
@ -712,7 +712,7 @@ PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF8(
PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF16(
const char *string, /* UTF-16 encoded string */
int length, /* size of string */
Py_ssize_t length, /* size of string */
const char *errors, /* error handling */
int *byteorder /* pointer to byteorder to use
0=native;-1=LE,1=BE; updated on
@ -721,12 +721,12 @@ PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF16(
PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF16Stateful(
const char *string, /* UTF-16 encoded string */
int length, /* size of string */
Py_ssize_t length, /* size of string */
const char *errors, /* error handling */
int *byteorder, /* pointer to byteorder to use
0=native;-1=LE,1=BE; updated on
exit */
int *consumed /* bytes consumed */
Py_ssize_t *consumed /* bytes consumed */
);
/* Returns a Python string using the UTF-16 encoding in native byte
@ -758,7 +758,7 @@ PyAPI_FUNC(PyObject*) PyUnicode_AsUTF16String(
PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF16(
const Py_UNICODE *data, /* Unicode char buffer */
int length, /* number of Py_UNICODE chars to encode */
Py_ssize_t length, /* number of Py_UNICODE chars to encode */
const char *errors, /* error handling */
int byteorder /* byteorder to use 0=BOM+native;-1=LE,1=BE */
);
@ -767,7 +767,7 @@ PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF16(
PyAPI_FUNC(PyObject*) PyUnicode_DecodeUnicodeEscape(
const char *string, /* Unicode-Escape encoded string */
int length, /* size of string */
Py_ssize_t length, /* size of string */
const char *errors /* error handling */
);
@ -777,14 +777,14 @@ PyAPI_FUNC(PyObject*) PyUnicode_AsUnicodeEscapeString(
PyAPI_FUNC(PyObject*) PyUnicode_EncodeUnicodeEscape(
const Py_UNICODE *data, /* Unicode char buffer */
int length /* Number of Py_UNICODE chars to encode */
Py_ssize_t length /* Number of Py_UNICODE chars to encode */
);
/* --- Raw-Unicode-Escape Codecs ------------------------------------------ */
PyAPI_FUNC(PyObject*) PyUnicode_DecodeRawUnicodeEscape(
const char *string, /* Raw-Unicode-Escape encoded string */
int length, /* size of string */
Py_ssize_t length, /* size of string */
const char *errors /* error handling */
);
@ -794,7 +794,7 @@ PyAPI_FUNC(PyObject*) PyUnicode_AsRawUnicodeEscapeString(
PyAPI_FUNC(PyObject*) PyUnicode_EncodeRawUnicodeEscape(
const Py_UNICODE *data, /* Unicode char buffer */
int length /* Number of Py_UNICODE chars to encode */
Py_ssize_t length /* Number of Py_UNICODE chars to encode */
);
/* --- Unicode Internal Codec ---------------------------------------------
@ -803,7 +803,7 @@ PyAPI_FUNC(PyObject*) PyUnicode_EncodeRawUnicodeEscape(
PyObject *_PyUnicode_DecodeUnicodeInternal(
const char *string,
int length,
Py_ssize_t length,
const char *errors
);
@ -815,7 +815,7 @@ PyObject *_PyUnicode_DecodeUnicodeInternal(
PyAPI_FUNC(PyObject*) PyUnicode_DecodeLatin1(
const char *string, /* Latin-1 encoded string */
int length, /* size of string */
Py_ssize_t length, /* size of string */
const char *errors /* error handling */
);
@ -825,7 +825,7 @@ PyAPI_FUNC(PyObject*) PyUnicode_AsLatin1String(
PyAPI_FUNC(PyObject*) PyUnicode_EncodeLatin1(
const Py_UNICODE *data, /* Unicode char buffer */
int length, /* Number of Py_UNICODE chars to encode */
Py_ssize_t length, /* Number of Py_UNICODE chars to encode */
const char *errors /* error handling */
);
@ -837,7 +837,7 @@ PyAPI_FUNC(PyObject*) PyUnicode_EncodeLatin1(
PyAPI_FUNC(PyObject*) PyUnicode_DecodeASCII(
const char *string, /* ASCII encoded string */
int length, /* size of string */
Py_ssize_t length, /* size of string */
const char *errors /* error handling */
);
@ -847,7 +847,7 @@ PyAPI_FUNC(PyObject*) PyUnicode_AsASCIIString(
PyAPI_FUNC(PyObject*) PyUnicode_EncodeASCII(
const Py_UNICODE *data, /* Unicode char buffer */
int length, /* Number of Py_UNICODE chars to encode */
Py_ssize_t length, /* Number of Py_UNICODE chars to encode */
const char *errors /* error handling */
);
@ -875,7 +875,7 @@ PyAPI_FUNC(PyObject*) PyUnicode_EncodeASCII(
PyAPI_FUNC(PyObject*) PyUnicode_DecodeCharmap(
const char *string, /* Encoded string */
int length, /* size of string */
Py_ssize_t length, /* size of string */
PyObject *mapping, /* character mapping
(char ordinal -> unicode ordinal) */
const char *errors /* error handling */
@ -889,7 +889,7 @@ PyAPI_FUNC(PyObject*) PyUnicode_AsCharmapString(
PyAPI_FUNC(PyObject*) PyUnicode_EncodeCharmap(
const Py_UNICODE *data, /* Unicode char buffer */
int length, /* Number of Py_UNICODE chars to encode */
Py_ssize_t length, /* Number of Py_UNICODE chars to encode */
PyObject *mapping, /* character mapping
(unicode ordinal -> char ordinal) */
const char *errors /* error handling */
@ -910,7 +910,7 @@ PyAPI_FUNC(PyObject*) PyUnicode_EncodeCharmap(
PyAPI_FUNC(PyObject *) PyUnicode_TranslateCharmap(
const Py_UNICODE *data, /* Unicode char buffer */
int length, /* Number of Py_UNICODE chars to encode */
Py_ssize_t length, /* Number of Py_UNICODE chars to encode */
PyObject *table, /* Translate table */
const char *errors /* error handling */
);
@ -921,7 +921,7 @@ PyAPI_FUNC(PyObject *) PyUnicode_TranslateCharmap(
PyAPI_FUNC(PyObject*) PyUnicode_DecodeMBCS(
const char *string, /* MBCS encoded string */
int length, /* size of string */
Py_ssize_t length, /* size of string */
const char *errors /* error handling */
);
@ -931,7 +931,7 @@ PyAPI_FUNC(PyObject*) PyUnicode_AsMBCSString(
PyAPI_FUNC(PyObject*) PyUnicode_EncodeMBCS(
const Py_UNICODE *data, /* Unicode char buffer */
int length, /* Number of Py_UNICODE chars to encode */
Py_ssize_t length, /* Number of Py_UNICODE chars to encode */
const char *errors /* error handling */
);
@ -963,7 +963,7 @@ PyAPI_FUNC(PyObject*) PyUnicode_EncodeMBCS(
PyAPI_FUNC(int) PyUnicode_EncodeDecimal(
Py_UNICODE *s, /* Unicode buffer */
int length, /* Number of Py_UNICODE chars to encode */
Py_ssize_t length, /* Number of Py_UNICODE chars to encode */
char *output, /* Output buffer; must have size >= length */
const char *errors /* error handling */
);
@ -995,7 +995,7 @@ PyAPI_FUNC(PyObject*) PyUnicode_Concat(
PyAPI_FUNC(PyObject*) PyUnicode_Split(
PyObject *s, /* String to split */
PyObject *sep, /* String separator */
int maxsplit /* Maxsplit count */
Py_ssize_t maxsplit /* Maxsplit count */
);
/* Dito, but split at line breaks.
@ -1024,7 +1024,7 @@ PyAPI_FUNC(PyObject*) PyUnicode_Splitlines(
PyAPI_FUNC(PyObject*) PyUnicode_RSplit(
PyObject *s, /* String to split */
PyObject *sep, /* String separator */
int maxsplit /* Maxsplit count */
Py_ssize_t maxsplit /* Maxsplit count */
);
/* Translate a string by applying a character mapping table to it and
@ -1056,11 +1056,11 @@ PyAPI_FUNC(PyObject*) PyUnicode_Join(
/* Return 1 if substr matches str[start:end] at the given tail end, 0
otherwise. */
PyAPI_FUNC(int) PyUnicode_Tailmatch(
PyAPI_FUNC(Py_ssize_t) PyUnicode_Tailmatch(
PyObject *str, /* String */
PyObject *substr, /* Prefix or Suffix string */
int start, /* Start index */
int end, /* Stop index */
Py_ssize_t start, /* Start index */
Py_ssize_t end, /* Stop index */
int direction /* Tail end: -1 prefix, +1 suffix */
);
@ -1068,21 +1068,21 @@ PyAPI_FUNC(int) PyUnicode_Tailmatch(
given search direction or -1 if not found. -2 is returned in case
an error occurred and an exception is set. */
PyAPI_FUNC(int) PyUnicode_Find(
PyAPI_FUNC(Py_ssize_t) PyUnicode_Find(
PyObject *str, /* String */
PyObject *substr, /* Substring to find */
int start, /* Start index */
int end, /* Stop index */
Py_ssize_t start, /* Start index */
Py_ssize_t end, /* Stop index */
int direction /* Find direction: +1 forward, -1 backward */
);
/* Count the number of occurrences of substr in str[start:end]. */
PyAPI_FUNC(int) PyUnicode_Count(
PyAPI_FUNC(Py_ssize_t) PyUnicode_Count(
PyObject *str, /* String */
PyObject *substr, /* Substring to count */
int start, /* Start index */
int end /* Stop index */
Py_ssize_t start, /* Start index */
Py_ssize_t end /* Stop index */
);
/* Replace at most maxcount occurrences of substr in str with replstr
@ -1092,7 +1092,7 @@ PyAPI_FUNC(PyObject *) PyUnicode_Replace(
PyObject *str, /* String */
PyObject *substr, /* Substring to find */
PyObject *replstr, /* Substring to replace */
int maxcount /* Max. number of replacements to apply;
Py_ssize_t maxcount /* Max. number of replacements to apply;
-1 = all */
);

View File

@ -627,7 +627,9 @@ class MixinStrUnicodeUserStringTest:
self.checkequal('abcabcabc', 'abc', '__mul__', 3)
self.checkraises(TypeError, 'abc', '__mul__')
self.checkraises(TypeError, 'abc', '__mul__', '')
self.checkraises(OverflowError, 10000*'abc', '__mul__', 2000000000)
# XXX: on a 64-bit system, this doesn't raise an overflow error,
# but either raises a MemoryError, or succeeds (if you have 54TiB)
#self.checkraises(OverflowError, 10000*'abc', '__mul__', 2000000000)
def test_join(self):
# join now works with any sequence type

View File

@ -12,6 +12,8 @@ What's New in Python 2.5 alpha 1?
Core and builtins
-----------------
- PEP 353: Using ssize_t as the index type.
- Patch #1400181, fix unicode string formatting to not use the locale.
This is how string objects work. u'%f' could use , instead of .
for the decimal point. Now both strings and unicode always use periods.

View File

@ -1100,7 +1100,7 @@ _db_associateCallback(DB* db, const DBT* priKey, const DBT* priData,
}
else if (PyString_Check(result)) {
char* data;
int size;
Py_ssize_t size;
CLEAR_DBT(*secKey);
#if PYTHON_API_VERSION <= 1007
@ -2614,7 +2614,7 @@ DB_set_encrypt(DBObject* self, PyObject* args, PyObject* kwargs)
/*-------------------------------------------------------------- */
/* Mapping and Dictionary-like access routines */
int DB_length(DBObject* self)
Py_ssize_t DB_length(DBObject* self)
{
int err;
long size = 0;
@ -4679,7 +4679,7 @@ static PyMethodDef DB_methods[] = {
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*/
};

View File

@ -35,6 +35,7 @@ Copyright (c) Corporation for National Research Initiatives.
------------------------------------------------------------------------ */
#define PY_SSIZE_T_CLEAN
#include "Python.h"
/* --- Registry ----------------------------------------------------------- */
@ -196,7 +197,7 @@ escape_decode(PyObject *self,
{
const char *errors = NULL;
const char *data;
int size;
Py_ssize_t size;
if (!PyArg_ParseTuple(args, "s#|z:escape_decode",
&data, &size, &errors))
@ -241,7 +242,7 @@ unicode_internal_decode(PyObject *self,
PyObject *obj;
const char *errors = NULL;
const char *data;
int size;
Py_ssize_t size;
if (!PyArg_ParseTuple(args, "O|z:unicode_internal_decode",
&obj, &errors))
@ -265,7 +266,7 @@ utf_7_decode(PyObject *self,
PyObject *args)
{
const char *data;
int size;
Py_ssize_t size;
const char *errors = NULL;
if (!PyArg_ParseTuple(args, "t#|z:utf_7_decode",
@ -281,15 +282,19 @@ utf_8_decode(PyObject *self,
PyObject *args)
{
const char *data;
int size;
Py_ssize_t size;
const char *errors = NULL;
int final = 0;
int consumed;
Py_ssize_t consumed;
PyObject *decoded = NULL;
if (!PyArg_ParseTuple(args, "t#|zi:utf_8_decode",
&data, &size, &errors, &final))
return NULL;
if (size < 0) {
PyErr_SetString(PyExc_ValueError, "negative argument");
return 0;
}
consumed = size;
decoded = PyUnicode_DecodeUTF8Stateful(data, size, errors,
@ -304,16 +309,21 @@ utf_16_decode(PyObject *self,
PyObject *args)
{
const char *data;
int size;
Py_ssize_t size;
const char *errors = NULL;
int byteorder = 0;
int final = 0;
int consumed;
Py_ssize_t consumed;
PyObject *decoded;
if (!PyArg_ParseTuple(args, "t#|zi:utf_16_decode",
&data, &size, &errors, &final))
return NULL;
/* XXX Why is consumed initialized to size? mvl */
if (size < 0) {
PyErr_SetString(PyExc_ValueError, "negative argument");
return 0;
}
consumed = size;
decoded = PyUnicode_DecodeUTF16Stateful(data, size, errors, &byteorder,
final ? NULL : &consumed);
@ -327,16 +337,22 @@ utf_16_le_decode(PyObject *self,
PyObject *args)
{
const char *data;
int size;
Py_ssize_t size;
const char *errors = NULL;
int byteorder = -1;
int final = 0;
int consumed;
Py_ssize_t consumed;
PyObject *decoded = NULL;
if (!PyArg_ParseTuple(args, "t#|zi:utf_16_le_decode",
&data, &size, &errors, &final))
return NULL;
/* XXX Why is consumed initialized to size? mvl */
if (size < 0) {
PyErr_SetString(PyExc_ValueError, "negative argument");
return 0;
}
consumed = size;
decoded = PyUnicode_DecodeUTF16Stateful(data, size, errors,
&byteorder, final ? NULL : &consumed);
@ -351,16 +367,21 @@ utf_16_be_decode(PyObject *self,
PyObject *args)
{
const char *data;
int size;
Py_ssize_t size;
const char *errors = NULL;
int byteorder = 1;
int final = 0;
int consumed;
Py_ssize_t consumed;
PyObject *decoded = NULL;
if (!PyArg_ParseTuple(args, "t#|zi:utf_16_be_decode",
&data, &size, &errors, &final))
return NULL;
/* XXX Why is consumed initialized to size? mvl */
if (size < 0) {
PyErr_SetString(PyExc_ValueError, "negative argument");
return 0;
}
consumed = size;
decoded = PyUnicode_DecodeUTF16Stateful(data, size, errors,
&byteorder, final ? NULL : &consumed);
@ -382,17 +403,21 @@ utf_16_ex_decode(PyObject *self,
PyObject *args)
{
const char *data;
int size;
Py_ssize_t size;
const char *errors = NULL;
int byteorder = 0;
PyObject *unicode, *tuple;
int final = 0;
int consumed;
Py_ssize_t consumed;
if (!PyArg_ParseTuple(args, "t#|zii:utf_16_ex_decode",
&data, &size, &errors, &byteorder, &final))
return NULL;
/* XXX Why is consumed initialized to size? mvl */
if (size < 0) {
PyErr_SetString(PyExc_ValueError, "negative argument");
return 0;
}
consumed = size;
unicode = PyUnicode_DecodeUTF16Stateful(data, size, errors, &byteorder,
final ? NULL : &consumed);
@ -408,7 +433,7 @@ unicode_escape_decode(PyObject *self,
PyObject *args)
{
const char *data;
int size;
Py_ssize_t size;
const char *errors = NULL;
if (!PyArg_ParseTuple(args, "t#|z:unicode_escape_decode",
@ -424,7 +449,7 @@ raw_unicode_escape_decode(PyObject *self,
PyObject *args)
{
const char *data;
int size;
Py_ssize_t size;
const char *errors = NULL;
if (!PyArg_ParseTuple(args, "t#|z:raw_unicode_escape_decode",
@ -440,7 +465,7 @@ latin_1_decode(PyObject *self,
PyObject *args)
{
const char *data;
int size;
Py_ssize_t size;
const char *errors = NULL;
if (!PyArg_ParseTuple(args, "t#|z:latin_1_decode",
@ -456,7 +481,7 @@ ascii_decode(PyObject *self,
PyObject *args)
{
const char *data;
int size;
Py_ssize_t size;
const char *errors = NULL;
if (!PyArg_ParseTuple(args, "t#|z:ascii_decode",
@ -472,7 +497,7 @@ charmap_decode(PyObject *self,
PyObject *args)
{
const char *data;
int size;
Py_ssize_t size;
const char *errors = NULL;
PyObject *mapping = NULL;
@ -493,7 +518,7 @@ mbcs_decode(PyObject *self,
PyObject *args)
{
const char *data;
int size;
Py_ssize_t size;
const char *errors = NULL;
if (!PyArg_ParseTuple(args, "t#|z:mbcs_decode",
@ -513,7 +538,7 @@ readbuffer_encode(PyObject *self,
PyObject *args)
{
const char *data;
int size;
Py_ssize_t size;
const char *errors = NULL;
if (!PyArg_ParseTuple(args, "s#|z:readbuffer_encode",
@ -529,7 +554,7 @@ charbuffer_encode(PyObject *self,
PyObject *args)
{
const char *data;
int size;
Py_ssize_t size;
const char *errors = NULL;
if (!PyArg_ParseTuple(args, "t#|z:charbuffer_encode",
@ -547,7 +572,7 @@ unicode_internal_encode(PyObject *self,
PyObject *obj;
const char *errors = NULL;
const char *data;
int size;
Py_ssize_t size;
if (!PyArg_ParseTuple(args, "O|z:unicode_internal_encode",
&obj, &errors))

View File

@ -92,6 +92,9 @@ do { memory -= size; printf("%8d - %s\n", memory, comment); } while (0)
#endif
/* compatibility macros */
#if (PY_VERSION_HEX < 0x02050000)
typedef int Py_ssize_t;
#endif
#if (PY_VERSION_HEX < 0x02040000)
#define PyDict_CheckExact PyDict_Check
#if (PY_VERSION_HEX < 0x02020000)
@ -919,8 +922,9 @@ element_getiterator(ElementObject* self, PyObject* args)
}
static PyObject*
element_getitem(ElementObject* self, int index)
element_getitem(PyObject* _self, Py_ssize_t index)
{
ElementObject* self = (ElementObject*)_self;
if (!self->extra || index < 0 || index >= self->extra->length) {
PyErr_SetString(
PyExc_IndexError,
@ -934,9 +938,10 @@ element_getitem(ElementObject* self, int index)
}
static PyObject*
element_getslice(ElementObject* self, int start, int end)
element_getslice(PyObject* _self, Py_ssize_t start, Py_ssize_t end)
{
int i;
ElementObject* self = (ElementObject*)_self;
Py_ssize_t i;
PyObject* list;
if (!self->extra)
@ -1022,7 +1027,7 @@ element_keys(ElementObject* self, PyObject* args)
return PyDict_Keys(self->extra->attrib);
}
static int
static Py_ssize_t
element_length(ElementObject* self)
{
if (!self->extra)
@ -1161,8 +1166,9 @@ element_set(ElementObject* self, PyObject* args)
}
static int
element_setslice(ElementObject* self, int start, int end, PyObject* item)
element_setslice(PyObject* _self, Py_ssize_t start, Py_ssize_t end, PyObject* item)
{
ElementObject* self = (ElementObject*)_self;
int i, new, old;
PyObject* recycle = NULL;
@ -1231,8 +1237,9 @@ element_setslice(ElementObject* self, int start, int end, PyObject* item)
}
static int
element_setitem(ElementObject* self, int index, PyObject* item)
element_setitem(PyObject* _self, Py_ssize_t index, PyObject* item)
{
ElementObject* self = (ElementObject*)_self;
int i;
PyObject* old;
@ -1371,13 +1378,13 @@ element_setattr(ElementObject* self, const char* name, PyObject* value)
}
static PySequenceMethods element_as_sequence = {
(inquiry) element_length,
(lenfunc) element_length,
0, /* sq_concat */
0, /* sq_repeat */
(intargfunc) element_getitem,
(intintargfunc) element_getslice,
(intobjargproc) element_setitem,
(intintobjargproc) element_setslice,
element_getitem,
element_getslice,
element_setitem,
element_setslice,
};
statichere PyTypeObject Element_Type = {

View File

@ -71,7 +71,7 @@ typedef struct {
PyObject_HEAD
PyObject *filemap;
PyObject *logfilename;
int index;
Py_ssize_t index;
unsigned char buffer[BUFFERSIZE];
FILE *logfp;
int lineevents;
@ -526,7 +526,7 @@ logreader_dealloc(LogReaderObject *self)
}
static PyObject *
logreader_sq_item(LogReaderObject *self, int index)
logreader_sq_item(LogReaderObject *self, Py_ssize_t index)
{
PyObject *result = logreader_tp_iternext(self);
if (result == NULL && !PyErr_Occurred()) {
@ -610,13 +610,14 @@ pack_modified_packed_int(ProfilerObject *self, int value,
}
static int
pack_string(ProfilerObject *self, const char *s, int len)
pack_string(ProfilerObject *self, const char *s, Py_ssize_t len)
{
if (len + PISIZE + self->index >= BUFFERSIZE) {
if (flush_data(self) < 0)
return -1;
}
if (pack_packed_int(self, len) < 0)
assert(len < INT_MAX);
if (pack_packed_int(self, (int)len) < 0)
return -1;
memcpy(self->buffer + self->index, s, len);
self->index += len;
@ -626,8 +627,8 @@ pack_string(ProfilerObject *self, const char *s, int len)
static int
pack_add_info(ProfilerObject *self, const char *s1, const char *s2)
{
int len1 = strlen(s1);
int len2 = strlen(s2);
Py_ssize_t len1 = strlen(s1);
Py_ssize_t len2 = strlen(s2);
if (len1 + len2 + PISIZE*2 + 1 + self->index >= BUFFERSIZE) {
if (flush_data(self) < 0)
@ -643,7 +644,7 @@ pack_add_info(ProfilerObject *self, const char *s1, const char *s2)
static int
pack_define_file(ProfilerObject *self, int fileno, const char *filename)
{
int len = strlen(filename);
Py_ssize_t len = strlen(filename);
if (len + PISIZE*2 + 1 + self->index >= BUFFERSIZE) {
if (flush_data(self) < 0)
@ -660,7 +661,7 @@ static int
pack_define_func(ProfilerObject *self, int fileno, int lineno,
const char *funcname)
{
int len = strlen(funcname);
Py_ssize_t len = strlen(funcname);
if (len + PISIZE*3 + 1 + self->index >= BUFFERSIZE) {
if (flush_data(self) < 0)
@ -1269,7 +1270,7 @@ static PySequenceMethods logreader_as_sequence = {
0, /* sq_length */
0, /* sq_concat */
0, /* sq_repeat */
(intargfunc)logreader_sq_item, /* sq_item */
(ssizeargfunc)logreader_sq_item, /* sq_item */
0, /* sq_slice */
0, /* sq_ass_item */
0, /* sq_ass_slice */

View File

@ -382,11 +382,11 @@ PyLocale_getdefaultlocale(PyObject* self)
if (GetLocaleInfo(LOCALE_USER_DEFAULT,
LOCALE_SISO639LANGNAME,
locale, sizeof(locale))) {
int i = strlen(locale);
Py_ssize_t i = strlen(locale);
locale[i++] = '_';
if (GetLocaleInfo(LOCALE_USER_DEFAULT,
LOCALE_SISO3166CTRYNAME,
locale+i, sizeof(locale)-i))
locale+i, (int)(sizeof(locale)-i)))
return Py_BuildValue("ss", locale, encoding);
}

View File

@ -115,7 +115,8 @@ test_list_api(PyObject *self)
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;

View File

@ -3,6 +3,7 @@
/* An array is a uniform list -- all items have the same type.
The item type is restricted to simple C types like int or float */
#define PY_SSIZE_T_CLEAN
#include "Python.h"
#include "structmember.h"
@ -23,15 +24,15 @@ struct arrayobject; /* Forward */
struct arraydescr {
int typecode;
int itemsize;
PyObject * (*getitem)(struct arrayobject *, int);
int (*setitem)(struct arrayobject *, int, PyObject *);
PyObject * (*getitem)(struct arrayobject *, Py_ssize_t);
int (*setitem)(struct arrayobject *, Py_ssize_t, PyObject *);
};
typedef struct arrayobject {
PyObject_HEAD
int ob_size;
Py_ssize_t ob_size;
char *ob_item;
int allocated;
Py_ssize_t allocated;
struct arraydescr *ob_descr;
PyObject *weakreflist; /* List of weak references */
} arrayobject;
@ -42,7 +43,7 @@ static PyTypeObject Arraytype;
#define array_CheckExact(op) ((op)->ob_type == &Arraytype)
static int
array_resize(arrayobject *self, int newsize)
array_resize(arrayobject *self, Py_ssize_t newsize)
{
char *items;
size_t _new_size;
@ -102,13 +103,13 @@ in bounds; that's the responsibility of the caller.
****************************************************************************/
static PyObject *
c_getitem(arrayobject *ap, int i)
c_getitem(arrayobject *ap, Py_ssize_t i)
{
return PyString_FromStringAndSize(&((char *)ap->ob_item)[i], 1);
}
static int
c_setitem(arrayobject *ap, int i, PyObject *v)
c_setitem(arrayobject *ap, Py_ssize_t i, PyObject *v)
{
char x;
if (!PyArg_Parse(v, "c;array item must be char", &x))
@ -119,7 +120,7 @@ c_setitem(arrayobject *ap, int i, PyObject *v)
}
static PyObject *
b_getitem(arrayobject *ap, int i)
b_getitem(arrayobject *ap, Py_ssize_t i)
{
long x = ((char *)ap->ob_item)[i];
if (x >= 128)
@ -128,7 +129,7 @@ b_getitem(arrayobject *ap, int i)
}
static int
b_setitem(arrayobject *ap, int i, PyObject *v)
b_setitem(arrayobject *ap, Py_ssize_t i, PyObject *v)
{
short x;
/* PyArg_Parse's 'b' formatter is for an unsigned char, therefore
@ -152,14 +153,14 @@ b_setitem(arrayobject *ap, int i, PyObject *v)
}
static PyObject *
BB_getitem(arrayobject *ap, int i)
BB_getitem(arrayobject *ap, Py_ssize_t i)
{
long x = ((unsigned char *)ap->ob_item)[i];
return PyInt_FromLong(x);
}
static int
BB_setitem(arrayobject *ap, int i, PyObject *v)
BB_setitem(arrayobject *ap, Py_ssize_t i, PyObject *v)
{
unsigned char x;
/* 'B' == unsigned char, maps to PyArg_Parse's 'b' formatter */
@ -172,16 +173,16 @@ BB_setitem(arrayobject *ap, int i, PyObject *v)
#ifdef Py_USING_UNICODE
static PyObject *
u_getitem(arrayobject *ap, int i)
u_getitem(arrayobject *ap, Py_ssize_t i)
{
return PyUnicode_FromUnicode(&((Py_UNICODE *) ap->ob_item)[i], 1);
}
static int
u_setitem(arrayobject *ap, int i, PyObject *v)
u_setitem(arrayobject *ap, Py_ssize_t i, PyObject *v)
{
Py_UNICODE *p;
int len;
Py_ssize_t len;
if (!PyArg_Parse(v, "u#;array item must be unicode character", &p, &len))
return -1;
@ -196,13 +197,13 @@ u_setitem(arrayobject *ap, int i, PyObject *v)
#endif
static PyObject *
h_getitem(arrayobject *ap, int i)
h_getitem(arrayobject *ap, Py_ssize_t i)
{
return PyInt_FromLong((long) ((short *)ap->ob_item)[i]);
}
static int
h_setitem(arrayobject *ap, int i, PyObject *v)
h_setitem(arrayobject *ap, Py_ssize_t i, PyObject *v)
{
short x;
/* 'h' == signed short, maps to PyArg_Parse's 'h' formatter */
@ -214,13 +215,13 @@ h_setitem(arrayobject *ap, int i, PyObject *v)
}
static PyObject *
HH_getitem(arrayobject *ap, int i)
HH_getitem(arrayobject *ap, Py_ssize_t i)
{
return PyInt_FromLong((long) ((unsigned short *)ap->ob_item)[i]);
}
static int
HH_setitem(arrayobject *ap, int i, PyObject *v)
HH_setitem(arrayobject *ap, Py_ssize_t i, PyObject *v)
{
int x;
/* PyArg_Parse's 'h' formatter is for a signed short, therefore
@ -243,13 +244,13 @@ HH_setitem(arrayobject *ap, int i, PyObject *v)
}
static PyObject *
i_getitem(arrayobject *ap, int i)
i_getitem(arrayobject *ap, Py_ssize_t i)
{
return PyInt_FromLong((long) ((int *)ap->ob_item)[i]);
}
static int
i_setitem(arrayobject *ap, int i, PyObject *v)
i_setitem(arrayobject *ap, Py_ssize_t i, PyObject *v)
{
int x;
/* 'i' == signed int, maps to PyArg_Parse's 'i' formatter */
@ -261,14 +262,14 @@ i_setitem(arrayobject *ap, int i, PyObject *v)
}
static PyObject *
II_getitem(arrayobject *ap, int i)
II_getitem(arrayobject *ap, Py_ssize_t i)
{
return PyLong_FromUnsignedLong(
(unsigned long) ((unsigned int *)ap->ob_item)[i]);
}
static int
II_setitem(arrayobject *ap, int i, PyObject *v)
II_setitem(arrayobject *ap, Py_ssize_t i, PyObject *v)
{
unsigned long x;
if (PyLong_Check(v)) {
@ -300,13 +301,13 @@ II_setitem(arrayobject *ap, int i, PyObject *v)
}
static PyObject *
l_getitem(arrayobject *ap, int i)
l_getitem(arrayobject *ap, Py_ssize_t i)
{
return PyInt_FromLong(((long *)ap->ob_item)[i]);
}
static int
l_setitem(arrayobject *ap, int i, PyObject *v)
l_setitem(arrayobject *ap, Py_ssize_t i, PyObject *v)
{
long x;
if (!PyArg_Parse(v, "l;array item must be integer", &x))
@ -317,13 +318,13 @@ l_setitem(arrayobject *ap, int i, PyObject *v)
}
static PyObject *
LL_getitem(arrayobject *ap, int i)
LL_getitem(arrayobject *ap, Py_ssize_t i)
{
return PyLong_FromUnsignedLong(((unsigned long *)ap->ob_item)[i]);
}
static int
LL_setitem(arrayobject *ap, int i, PyObject *v)
LL_setitem(arrayobject *ap, Py_ssize_t i, PyObject *v)
{
unsigned long x;
if (PyLong_Check(v)) {
@ -355,13 +356,13 @@ LL_setitem(arrayobject *ap, int i, PyObject *v)
}
static PyObject *
f_getitem(arrayobject *ap, int i)
f_getitem(arrayobject *ap, Py_ssize_t i)
{
return PyFloat_FromDouble((double) ((float *)ap->ob_item)[i]);
}
static int
f_setitem(arrayobject *ap, int i, PyObject *v)
f_setitem(arrayobject *ap, Py_ssize_t i, PyObject *v)
{
float x;
if (!PyArg_Parse(v, "f;array item must be float", &x))
@ -372,13 +373,13 @@ f_setitem(arrayobject *ap, int i, PyObject *v)
}
static PyObject *
d_getitem(arrayobject *ap, int i)
d_getitem(arrayobject *ap, Py_ssize_t i)
{
return PyFloat_FromDouble(((double *)ap->ob_item)[i]);
}
static int
d_setitem(arrayobject *ap, int i, PyObject *v)
d_setitem(arrayobject *ap, Py_ssize_t i, PyObject *v)
{
double x;
if (!PyArg_Parse(v, "d;array item must be float", &x))
@ -412,7 +413,7 @@ Implementations of array object methods.
****************************************************************************/
static PyObject *
newarrayobject(PyTypeObject *type, int size, struct arraydescr *descr)
newarrayobject(PyTypeObject *type, Py_ssize_t size, struct arraydescr *descr)
{
arrayobject *op;
size_t nbytes;
@ -449,7 +450,7 @@ newarrayobject(PyTypeObject *type, int size, struct arraydescr *descr)
}
static PyObject *
getarrayitem(PyObject *op, int i)
getarrayitem(PyObject *op, Py_ssize_t i)
{
register arrayobject *ap;
assert(array_Check(op));
@ -459,10 +460,10 @@ getarrayitem(PyObject *op, int i)
}
static int
ins1(arrayobject *self, int where, PyObject *v)
ins1(arrayobject *self, Py_ssize_t where, PyObject *v)
{
char *items;
int n = self->ob_size;
Py_ssize_t n = self->ob_size;
if (v == NULL) {
PyErr_BadInternalCall();
return -1;
@ -506,7 +507,7 @@ array_richcompare(PyObject *v, PyObject *w, int op)
arrayobject *va, *wa;
PyObject *vi = NULL;
PyObject *wi = NULL;
int i, k;
Py_ssize_t i, k;
PyObject *res;
if (!array_Check(v) || !array_Check(w)) {
@ -548,8 +549,8 @@ array_richcompare(PyObject *v, PyObject *w, int op)
if (k) {
/* No more items to compare -- compare sizes */
int vs = va->ob_size;
int ws = wa->ob_size;
Py_ssize_t vs = va->ob_size;
Py_ssize_t ws = wa->ob_size;
int cmp;
switch (op) {
case Py_LT: cmp = vs < ws; break;
@ -586,14 +587,14 @@ array_richcompare(PyObject *v, PyObject *w, int op)
return res;
}
static int
static Py_ssize_t
array_length(arrayobject *a)
{
return a->ob_size;
}
static PyObject *
array_item(arrayobject *a, int i)
array_item(arrayobject *a, Py_ssize_t i)
{
if (i < 0 || i >= a->ob_size) {
PyErr_SetString(PyExc_IndexError, "array index out of range");
@ -603,7 +604,7 @@ array_item(arrayobject *a, int i)
}
static PyObject *
array_slice(arrayobject *a, int ilow, int ihigh)
array_slice(arrayobject *a, Py_ssize_t ilow, Py_ssize_t ihigh)
{
arrayobject *np;
if (ilow < 0)
@ -638,7 +639,7 @@ PyDoc_STRVAR(copy_doc,
static PyObject *
array_concat(arrayobject *a, PyObject *bb)
{
int size;
Py_ssize_t size;
arrayobject *np;
if (!array_Check(bb)) {
PyErr_Format(PyExc_TypeError,
@ -664,13 +665,13 @@ array_concat(arrayobject *a, PyObject *bb)
}
static PyObject *
array_repeat(arrayobject *a, int n)
array_repeat(arrayobject *a, Py_ssize_t n)
{
int i;
int size;
Py_ssize_t i;
Py_ssize_t size;
arrayobject *np;
char *p;
int nbytes;
Py_ssize_t nbytes;
if (n < 0)
n = 0;
size = a->ob_size * n;
@ -760,7 +761,7 @@ array_ass_slice(arrayobject *a, int ilow, int ihigh, PyObject *v)
}
static int
array_ass_item(arrayobject *a, int i, PyObject *v)
array_ass_item(arrayobject *a, Py_ssize_t i, PyObject *v)
{
if (i < 0 || i >= a->ob_size) {
PyErr_SetString(PyExc_IndexError,
@ -773,7 +774,7 @@ array_ass_item(arrayobject *a, int i, PyObject *v)
}
static int
setarrayitem(PyObject *a, int i, PyObject *v)
setarrayitem(PyObject *a, Py_ssize_t i, PyObject *v)
{
assert(array_Check(a));
return array_ass_item((arrayobject *)a, i, v);
@ -805,7 +806,7 @@ array_iter_extend(arrayobject *self, PyObject *bb)
static int
array_do_extend(arrayobject *self, PyObject *bb)
{
int size;
Py_ssize_t size;
if (!array_Check(bb))
return array_iter_extend(self, bb);
@ -847,10 +848,10 @@ array_inplace_concat(arrayobject *self, PyObject *bb)
}
static PyObject *
array_inplace_repeat(arrayobject *self, int n)
array_inplace_repeat(arrayobject *self, Py_ssize_t n)
{
char *items, *p;
int size, i;
Py_ssize_t size, i;
if (self->ob_size > 0) {
if (n < 0)
@ -883,7 +884,7 @@ array_inplace_repeat(arrayobject *self, int n)
static PyObject *
ins(arrayobject *self, int where, PyObject *v)
ins(arrayobject *self, Py_ssize_t where, PyObject *v)
{
if (ins1(self, where, v) != 0)
return NULL;
@ -894,8 +895,8 @@ ins(arrayobject *self, int where, PyObject *v)
static PyObject *
array_count(arrayobject *self, PyObject *v)
{
int count = 0;
int i;
Py_ssize_t count = 0;
Py_ssize_t i;
for (i = 0; i < self->ob_size; i++) {
PyObject *selfi = getarrayitem((PyObject *)self, i);
@ -906,7 +907,10 @@ array_count(arrayobject *self, PyObject *v)
else if (cmp < 0)
return NULL;
}
if (i < LONG_MAX)
return PyInt_FromLong((long)count);
else
return PyLong_FromLong(count);
}
PyDoc_STRVAR(count_doc,
@ -917,7 +921,7 @@ Return number of occurences of x in the array.");
static PyObject *
array_index(arrayobject *self, PyObject *v)
{
int i;
Py_ssize_t i;
for (i = 0; i < self->ob_size; i++) {
PyObject *selfi = getarrayitem((PyObject *)self, i);
@ -941,7 +945,8 @@ Return index of first occurence of x in the array.");
static int
array_contains(arrayobject *self, PyObject *v)
{
int i, cmp;
Py_ssize_t i;
int cmp;
for (i = 0, cmp = 0 ; cmp == 0 && i < self->ob_size; i++) {
PyObject *selfi = getarrayitem((PyObject *)self, i);
@ -1079,7 +1084,7 @@ static PyObject *
array_byteswap(arrayobject *self, PyObject *unused)
{
char *p;
int i;
Py_ssize_t i;
switch (self->ob_descr->itemsize) {
case 1:
@ -1158,7 +1163,7 @@ PyDoc_STRVAR(array_doc, "Return state information for pickling.");
static PyObject *
array_reverse(arrayobject *self, PyObject *unused)
{
register int itemsize = self->ob_descr->itemsize;
register Py_ssize_t itemsize = self->ob_descr->itemsize;
register char *p, *q;
/* little buffer to hold items while swapping */
char tmp[256]; /* 8 is probably enough -- but why skimp */
@ -1275,8 +1280,8 @@ write.");
static PyObject *
array_fromlist(arrayobject *self, PyObject *list)
{
int n;
int itemsize = self->ob_descr->itemsize;
Py_ssize_t n;
Py_ssize_t itemsize = self->ob_descr->itemsize;
if (!PyList_Check(list)) {
PyErr_SetString(PyExc_TypeError, "arg must be list");
@ -1285,7 +1290,7 @@ array_fromlist(arrayobject *self, PyObject *list)
n = PyList_Size(list);
if (n > 0) {
char *item = self->ob_item;
int i;
Py_ssize_t i;
PyMem_RESIZE(item, char, (self->ob_size + n) * itemsize);
if (item == NULL) {
PyErr_NoMemory();
@ -1321,7 +1326,7 @@ static PyObject *
array_tolist(arrayobject *self, PyObject *unused)
{
PyObject *list = PyList_New(self->ob_size);
int i;
Py_ssize_t i;
if (list == NULL)
return NULL;
@ -1346,7 +1351,7 @@ static PyObject *
array_fromstring(arrayobject *self, PyObject *args)
{
char *str;
int n;
Py_ssize_t n;
int itemsize = self->ob_descr->itemsize;
if (!PyArg_ParseTuple(args, "s#:fromstring", &str, &n))
return NULL;
@ -1400,7 +1405,7 @@ static PyObject *
array_fromunicode(arrayobject *self, PyObject *args)
{
Py_UNICODE *ustr;
int n;
Py_ssize_t n;
if (!PyArg_ParseTuple(args, "u#:fromunicode", &ustr, &n))
return NULL;
@ -1541,7 +1546,7 @@ array_repr(arrayobject *a)
{
char buf[256], typecode;
PyObject *s, *t, *v = NULL;
int len;
Py_ssize_t len;
len = a->ob_size;
typecode = a->ob_descr->typecode;
@ -1586,7 +1591,7 @@ array_subscr(arrayobject* self, PyObject* item)
return array_item(self, i);
}
else if (PySlice_Check(item)) {
int start, stop, step, slicelength, cur, i;
Py_ssize_t start, stop, step, slicelength, cur, i;
PyObject* result;
arrayobject* ar;
int itemsize = self->ob_descr->itemsize;
@ -1640,7 +1645,7 @@ array_ass_subscr(arrayobject* self, PyObject* item, PyObject* value)
return array_ass_item(self, i, value);
}
else if (PySlice_Check(item)) {
int start, stop, step, slicelength;
Py_ssize_t start, stop, step, slicelength;
int itemsize = self->ob_descr->itemsize;
if (PySlice_GetIndicesEx((PySliceObject*)item, self->ob_size,
@ -1654,7 +1659,7 @@ array_ass_subscr(arrayobject* self, PyObject* item, PyObject* value)
if (value == NULL) {
/* delete slice */
int cur, i, extra;
Py_ssize_t cur, i, extra;
if (slicelength <= 0)
return 0;
@ -1686,7 +1691,7 @@ array_ass_subscr(arrayobject* self, PyObject* item, PyObject* value)
}
else {
/* assign slice */
int cur, i;
Py_ssize_t cur, i;
arrayobject* av;
if (!array_Check(value)) {
@ -1700,8 +1705,8 @@ array_ass_subscr(arrayobject* self, PyObject* item, PyObject* value)
if (av->ob_size != slicelength) {
PyErr_Format(PyExc_ValueError,
"attempt to assign array of size %d to extended slice of size %d",
av->ob_size, slicelength);
"attempt to assign array of size %ld to extended slice of size %ld",
/*XXX*/(long)av->ob_size, /*XXX*/(long)slicelength);
return -1;
}
@ -1737,13 +1742,13 @@ array_ass_subscr(arrayobject* self, PyObject* item, PyObject* value)
}
static PyMappingMethods array_as_mapping = {
(inquiry)array_length,
(lenfunc)array_length,
(binaryfunc)array_subscr,
(objobjargproc)array_ass_subscr
};
static int
array_buffer_getreadbuf(arrayobject *self, int index, const void **ptr)
static Py_ssize_t
array_buffer_getreadbuf(arrayobject *self, Py_ssize_t index, const void **ptr)
{
if ( index != 0 ) {
PyErr_SetString(PyExc_SystemError,
@ -1754,8 +1759,8 @@ array_buffer_getreadbuf(arrayobject *self, int index, const void **ptr)
return self->ob_size*self->ob_descr->itemsize;
}
static int
array_buffer_getwritebuf(arrayobject *self, int index, const void **ptr)
static Py_ssize_t
array_buffer_getwritebuf(arrayobject *self, Py_ssize_t index, const void **ptr)
{
if ( index != 0 ) {
PyErr_SetString(PyExc_SystemError,
@ -1766,8 +1771,8 @@ array_buffer_getwritebuf(arrayobject *self, int index, const void **ptr)
return self->ob_size*self->ob_descr->itemsize;
}
static int
array_buffer_getsegcount(arrayobject *self, int *lenp)
static Py_ssize_t
array_buffer_getsegcount(arrayobject *self, Py_ssize_t *lenp)
{
if ( lenp )
*lenp = self->ob_size*self->ob_descr->itemsize;
@ -1775,22 +1780,22 @@ array_buffer_getsegcount(arrayobject *self, int *lenp)
}
static PySequenceMethods array_as_sequence = {
(inquiry)array_length, /*sq_length*/
(lenfunc)array_length, /*sq_length*/
(binaryfunc)array_concat, /*sq_concat*/
(intargfunc)array_repeat, /*sq_repeat*/
(intargfunc)array_item, /*sq_item*/
(intintargfunc)array_slice, /*sq_slice*/
(intobjargproc)array_ass_item, /*sq_ass_item*/
(intintobjargproc)array_ass_slice, /*sq_ass_slice*/
(ssizeargfunc)array_repeat, /*sq_repeat*/
(ssizeargfunc)array_item, /*sq_item*/
(ssizessizeargfunc)array_slice, /*sq_slice*/
(ssizeobjargproc)array_ass_item, /*sq_ass_item*/
(ssizessizeobjargproc)array_ass_slice, /*sq_ass_slice*/
(objobjproc)array_contains, /*sq_contains*/
(binaryfunc)array_inplace_concat, /*sq_inplace_concat*/
(intargfunc)array_inplace_repeat /*sq_inplace_repeat*/
(ssizeargfunc)array_inplace_repeat /*sq_inplace_repeat*/
};
static PyBufferProcs array_as_buffer = {
(getreadbufferproc)array_buffer_getreadbuf,
(getwritebufferproc)array_buffer_getwritebuf,
(getsegcountproc)array_buffer_getsegcount,
(readbufferproc)array_buffer_getreadbuf,
(writebufferproc)array_buffer_getwritebuf,
(segcountproc)array_buffer_getsegcount,
};
static PyObject *
@ -1822,7 +1827,7 @@ array_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
for (descr = descriptors; descr->typecode != '\0'; descr++) {
if (descr->typecode == c) {
PyObject *a;
int len;
Py_ssize_t len;
if (initial == NULL || !(PyList_Check(initial)
|| PyTuple_Check(initial)))
@ -1835,7 +1840,7 @@ array_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
return NULL;
if (len > 0) {
int i;
Py_ssize_t i;
for (i = 0; i < len; i++) {
PyObject *v =
PySequence_GetItem(initial, i);
@ -1864,7 +1869,7 @@ array_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
Py_DECREF(v);
#ifdef Py_USING_UNICODE
} else if (initial != NULL && PyUnicode_Check(initial)) {
int n = PyUnicode_GET_DATA_SIZE(initial);
Py_ssize_t n = PyUnicode_GET_DATA_SIZE(initial);
if (n > 0) {
arrayobject *self = (arrayobject *)a;
char *item = self->ob_item;
@ -2012,9 +2017,9 @@ static PyTypeObject Arraytype = {
typedef struct {
PyObject_HEAD
long index;
Py_ssize_t index;
arrayobject *ao;
PyObject * (*getitem)(struct arrayobject *, int);
PyObject * (*getitem)(struct arrayobject *, Py_ssize_t);
} arrayiterobject;
static PyTypeObject PyArrayIter_Type;

View File

@ -1020,7 +1020,9 @@ audioop_ratecv(PyObject *self, PyObject *args)
cur_i[chan]));
if (PyErr_Occurred())
goto exit;
len = ncp - PyString_AsString(str);
/* We have checked before that the length
* of the string fits into int. */
len = (int)(ncp - PyString_AsString(str));
if (len == 0) {
/*don't want to resize to zero length*/
rv = PyString_FromStringAndSize("", 0);

View File

@ -240,7 +240,7 @@ bsddb_dealloc(bsddbobject *dp)
#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 @@ bsddb_ass_sub(bsddbobject *dp, PyObject *key, PyObject *value)
}
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*/
};

View File

@ -908,7 +908,7 @@ BZ2File_writelines(BZ2FileObject *self, PyObject *seq)
PyObject *v = PyList_GET_ITEM(list, i);
if (!PyString_Check(v)) {
const char *buffer;
int len;
Py_ssize_t len;
if (PyObject_AsCharBuffer(v, &buffer, &len)) {
PyErr_SetString(PyExc_TypeError,
"writelines() "

View File

@ -339,7 +339,7 @@ typedef struct Picklerobject {
int fast; /* Fast mode doesn't save in memo, don't use if circ ref */
int nesting;
int (*write_func)(struct Picklerobject *, const char *, int);
int (*write_func)(struct Picklerobject *, const char *, Py_ssize_t);
char *write_buf;
int buf_size;
PyObject *dispatch_table;
@ -368,8 +368,8 @@ typedef struct Unpicklerobject {
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;
@ -417,7 +417,7 @@ cPickle_ErrFormat(PyObject *ErrType, char *stringformat, char *format, ...)
}
static int
write_file(Picklerobject *self, const char *s, int n)
write_file(Picklerobject *self, const char *s, Py_ssize_t n)
{
size_t nbyteswritten;
@ -425,6 +425,11 @@ write_file(Picklerobject *self, const char *s, int n)
return 0;
}
if (n > INT_MAX) {
/* String too large */
return -1;
}
Py_BEGIN_ALLOW_THREADS
nbyteswritten = fwrite(s, sizeof(char), n, self->fp);
Py_END_ALLOW_THREADS
@ -433,11 +438,11 @@ write_file(Picklerobject *self, const char *s, int n)
return -1;
}
return n;
return (int)n;
}
static int
write_cStringIO(Picklerobject *self, const char *s, int n)
write_cStringIO(Picklerobject *self, const char *s, Py_ssize_t n)
{
if (s == NULL) {
return 0;
@ -447,21 +452,26 @@ write_cStringIO(Picklerobject *self, const char *s, int n)
return -1;
}
return n;
return (int)n;
}
static int
write_none(Picklerobject *self, const char *s, int n)
write_none(Picklerobject *self, const char *s, Py_ssize_t n)
{
if (s == NULL) return 0;
return n;
if (n > INT_MAX) return -1;
return (int)n;
}
static int
write_other(Picklerobject *self, const char *s, int n)
write_other(Picklerobject *self, const char *s, Py_ssize_t _n)
{
PyObject *py_str = 0, *junk = 0;
int n;
if (_n > INT_MAX)
return -1;
n = (int)_n;
if (s == NULL) {
if (!( self->buf_size )) return 0;
py_str = PyString_FromStringAndSize(self->write_buf,
@ -505,8 +515,8 @@ write_other(Picklerobject *self, const char *s, int n)
}
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;
@ -549,7 +559,7 @@ read_file(Unpicklerobject *self, char **s, int n)
}
static int
static Py_ssize_t
readline_file(Unpicklerobject *self, char **s)
{
int i;
@ -588,8 +598,8 @@ readline_file(Unpicklerobject *self, char **s)
}
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;
@ -604,10 +614,10 @@ read_cStringIO(Unpicklerobject *self, char **s, int n)
}
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) {
@ -620,12 +630,12 @@ readline_cStringIO(Unpicklerobject *self, char **s)
}
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) {
@ -642,11 +652,11 @@ read_other(Unpicklerobject *self, char **s, int n)
}
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;
@ -828,7 +838,7 @@ put2(Picklerobject *self, PyObject *ob)
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;
@ -3280,7 +3290,7 @@ load_long(Unpicklerobject *self)
static int
load_counted_long(Unpicklerobject *self, int size)
{
int i;
Py_ssize_t i;
char *nbytes;
unsigned char *pdata;
PyObject *along;
@ -4253,7 +4263,7 @@ load_build(Unpicklerobject *self)
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
@ -5710,7 +5720,7 @@ PyMODINIT_FUNC
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;

View File

@ -47,7 +47,7 @@ PyDoc_STRVAR(cStringIO_module_documentation,
typedef struct {
PyObject_HEAD
char *buf;
int pos, string_size;
Py_ssize_t pos, string_size;
} IOobject;
#define IOOOBJECT(O) ((IOobject*)(O))
@ -57,9 +57,10 @@ typedef struct {
typedef struct { /* Subtype of IOobject */
PyObject_HEAD
char *buf;
int pos, string_size;
Py_ssize_t pos, string_size;
int buf_size, softspace;
Py_ssize_t buf_size;
int softspace;
} Oobject;
/* Declarations for objects of type StringI */
@ -67,7 +68,7 @@ typedef struct { /* Subtype of IOobject */
typedef struct { /* Subtype of IOobject */
PyObject_HEAD
char *buf;
int pos, string_size;
Py_ssize_t pos, string_size;
/* We store a reference to the object here in order to keep
the buffer alive during the lifetime of the Iobject. */
PyObject *pbuf;
@ -154,7 +155,7 @@ PyDoc_STRVAR(IO_read__doc__,
"read([s]) -- Read s characters, or the rest of the string");
static int
IO_cread(PyObject *self, char **output, int n) {
IO_cread(PyObject *self, char **output, Py_ssize_t n) {
int l;
UNLESS (IO__opencheck(IOOOBJECT(self))) return -1;
@ -171,10 +172,10 @@ IO_cread(PyObject *self, char **output, int n) {
static PyObject *
IO_read(IOobject *self, PyObject *args) {
int n = -1;
Py_ssize_t n = -1;
char *output;
UNLESS (PyArg_ParseTuple(args, "|i:read", &n)) return NULL;
UNLESS (PyArg_ParseTuple(args, "|n:read", &n)) return NULL;
if ( (n=IO_cread((PyObject*)self,&output,n)) < 0) return NULL;
@ -186,7 +187,7 @@ PyDoc_STRVAR(IO_readline__doc__, "readline() -- Read one line");
static int
IO_creadline(PyObject *self, char **output) {
char *n, *s;
int l;
Py_ssize_t l;
UNLESS (IO__opencheck(IOOOBJECT(self))) return -1;
@ -197,8 +198,9 @@ IO_creadline(PyObject *self, char **output) {
*output=((IOobject*)self)->buf + ((IOobject*)self)->pos;
l = n - ((IOobject*)self)->buf - ((IOobject*)self)->pos;
((IOobject*)self)->pos += l;
return l;
assert(((IOobject*)self)->pos + l < INT_MAX);
((IOobject*)self)->pos += (int)l;
return (int)l;
}
static PyObject *
@ -285,10 +287,10 @@ PyDoc_STRVAR(IO_truncate__doc__,
static PyObject *
IO_truncate(IOobject *self, PyObject *args) {
int pos = -1;
Py_ssize_t pos = -1;
UNLESS (IO__opencheck(self)) return NULL;
UNLESS (PyArg_ParseTuple(args, "|i:truncate", &pos)) return NULL;
UNLESS (PyArg_ParseTuple(args, "|n:truncate", &pos)) return NULL;
if (pos < 0) pos = self->pos;
if (self->string_size > pos) self->string_size = pos;
@ -324,10 +326,11 @@ PyDoc_STRVAR(O_seek__doc__,
static PyObject *
O_seek(Oobject *self, PyObject *args) {
int position, mode = 0;
Py_ssize_t position;
int mode = 0;
UNLESS (IO__opencheck(IOOOBJECT(self))) return NULL;
UNLESS (PyArg_ParseTuple(args, "i|i:seek", &position, &mode))
UNLESS (PyArg_ParseTuple(args, "n|i:seek", &position, &mode))
return NULL;
if (mode == 2) {
@ -362,8 +365,8 @@ PyDoc_STRVAR(O_write__doc__,
static int
O_cwrite(PyObject *self, const char *c, int l) {
int newl;
O_cwrite(PyObject *self, const char *c, Py_ssize_t l) {
Py_ssize_t newl;
Oobject *oself;
UNLESS (IO__opencheck(IOOOBJECT(self))) return -1;
@ -372,8 +375,10 @@ O_cwrite(PyObject *self, const char *c, int l) {
newl = oself->pos+l;
if (newl >= oself->buf_size) {
oself->buf_size *= 2;
if (oself->buf_size <= newl)
oself->buf_size = newl+1;
if (oself->buf_size <= newl) {
assert(newl + 1 < INT_MAX);
oself->buf_size = (int)(newl+1);
}
UNLESS (oself->buf =
(char*)realloc(oself->buf, oself->buf_size)) {
PyErr_SetString(PyExc_MemoryError,"out of memory");
@ -384,13 +389,14 @@ O_cwrite(PyObject *self, const char *c, int l) {
memcpy(oself->buf+oself->pos,c,l);
oself->pos += l;
assert(oself->pos + l < INT_MAX);
oself->pos += (int)l;
if (oself->string_size < oself->pos) {
oself->string_size = oself->pos;
}
return l;
return (int)l;
}
static PyObject *
@ -432,7 +438,7 @@ O_writelines(Oobject *self, PyObject *args) {
if (it == NULL)
return NULL;
while ((s = PyIter_Next(it)) != NULL) {
int n;
Py_ssize_t n;
char *c;
if (PyString_AsStringAndSize(s, &c, &n) == -1) {
Py_DECREF(it);
@ -564,10 +570,11 @@ I_close(Iobject *self, PyObject *unused) {
static PyObject *
I_seek(Iobject *self, PyObject *args) {
int position, mode = 0;
Py_ssize_t position;
int mode = 0;
UNLESS (IO__opencheck(IOOOBJECT(self))) return NULL;
UNLESS (PyArg_ParseTuple(args, "i|i:seek", &position, &mode))
UNLESS (PyArg_ParseTuple(args, "n|i:seek", &position, &mode))
return NULL;
if (mode == 2) position += self->string_size;
@ -648,7 +655,7 @@ static PyObject *
newIobject(PyObject *s) {
Iobject *self;
char *buf;
int size;
Py_ssize_t size;
if (PyObject_AsReadBuffer(s, (const void **)&buf, &size)) {
PyErr_Format(PyExc_TypeError, "expected read buffer, %.200s found",

View File

@ -214,7 +214,7 @@ multibytecodec_encerror(MultibyteCodec *codec,
if (buf->excobj == NULL) {
buf->excobj = PyUnicodeEncodeError_Create(codec->encoding,
buf->inbuf_top,
(int)(buf->inbuf_end - buf->inbuf_top),
buf->inbuf_end - buf->inbuf_top,
start, end, reason);
if (buf->excobj == NULL)
goto errorexit;

View File

@ -314,7 +314,7 @@ PyDoc_STRVAR(extendleft_doc,
"Extend the left side of the deque with elements from the iterable");
static int
_deque_rotate(dequeobject *deque, int n)
_deque_rotate(dequeobject *deque, Py_ssize_t n)
{
int i, len=deque->len, halflen=(len+1)>>1;
PyObject *item, *rv;
@ -365,7 +365,7 @@ deque_rotate(dequeobject *deque, PyObject *args)
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;
@ -374,7 +374,7 @@ deque_len(dequeobject *deque)
static PyObject *
deque_remove(dequeobject *deque, PyObject *value)
{
int i, n=deque->len;
Py_ssize_t i, n=deque->len;
for (i=0 ; i<n ; i++) {
PyObject *item = deque->leftblock->data[deque->leftindex];
@ -469,7 +469,7 @@ deque_item(dequeobject *deque, int i)
*/
static int
deque_del_item(dequeobject *deque, int i)
deque_del_item(dequeobject *deque, Py_ssize_t i)
{
PyObject *item;
@ -485,7 +485,7 @@ deque_del_item(dequeobject *deque, int i)
}
static int
deque_ass_item(dequeobject *deque, int i, PyObject *v)
deque_ass_item(dequeobject *deque, Py_ssize_t i, PyObject *v)
{
PyObject *old_value;
block *b;
@ -776,12 +776,12 @@ deque_init(dequeobject *deque, PyObject *args, PyObject *kwds)
}
static PySequenceMethods deque_as_sequence = {
(inquiry)deque_len, /* sq_length */
(lenfunc)deque_len, /* sq_length */
0, /* sq_concat */
0, /* sq_repeat */
(intargfunc)deque_item, /* sq_item */
(ssizeargfunc)deque_item, /* sq_item */
0, /* sq_slice */
(intobjargproc)deque_ass_item, /* sq_ass_item */
(ssizeobjargproc)deque_ass_item, /* sq_ass_item */
};
/* deque object ********************************************************/

View File

@ -596,7 +596,7 @@ normalize_datetime(int *year, int *month, int *day,
*/
static PyObject *
time_alloc(PyTypeObject *type, int aware)
time_alloc(PyTypeObject *type, Py_ssize_t aware)
{
PyObject *self;
@ -611,7 +611,7 @@ time_alloc(PyTypeObject *type, int aware)
}
static PyObject *
datetime_alloc(PyTypeObject *type, int aware)
datetime_alloc(PyTypeObject *type, Py_ssize_t aware)
{
PyObject *self;

View File

@ -70,7 +70,7 @@ dbm_dealloc(register dbmobject *dp)
PyObject_Del(dp);
}
static int
static Py_ssize_t
dbm_length(dbmobject *dp)
{
if (dp->di_dbm == NULL) {
@ -162,7 +162,7 @@ dbm_ass_sub(dbmobject *dp, PyObject *v, PyObject *w)
}
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*/
};

View File

@ -1274,7 +1274,7 @@ _PyObject_GC_New(PyTypeObject *tp)
}
PyVarObject *
_PyObject_GC_NewVar(PyTypeObject *tp, int nitems)
_PyObject_GC_NewVar(PyTypeObject *tp, Py_ssize_t nitems)
{
const size_t size = _PyObject_VAR_SIZE(tp, nitems);
PyVarObject *op = (PyVarObject *) _PyObject_GC_Malloc(size);

View File

@ -86,7 +86,7 @@ dbm_dealloc(register dbmobject *dp)
PyObject_Del(dp);
}
static int
static Py_ssize_t
dbm_length(dbmobject *dp)
{
if (dp->di_dbm == NULL) {
@ -178,7 +178,7 @@ dbm_ass_sub(dbmobject *dp, PyObject *v, PyObject *w)
}
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*/
};

View File

@ -583,8 +583,8 @@ static struct PyMethodDef mmap_object_methods[] = {
/* Functions for treating an mmap'ed file as a buffer */
static int
mmap_buffer_getreadbuf(mmap_object *self, int index, const void **ptr)
static Py_ssize_t
mmap_buffer_getreadbuf(mmap_object *self, Py_ssize_t index, const void **ptr)
{
CHECK_VALID(-1);
if ( index != 0 ) {
@ -596,8 +596,8 @@ mmap_buffer_getreadbuf(mmap_object *self, int index, const void **ptr)
return self->size;
}
static int
mmap_buffer_getwritebuf(mmap_object *self, int index, const void **ptr)
static Py_ssize_t
mmap_buffer_getwritebuf(mmap_object *self, Py_ssize_t index, const void **ptr)
{
CHECK_VALID(-1);
if ( index != 0 ) {
@ -611,8 +611,8 @@ mmap_buffer_getwritebuf(mmap_object *self, int index, const void **ptr)
return self->size;
}
static int
mmap_buffer_getsegcount(mmap_object *self, int *lenp)
static Py_ssize_t
mmap_buffer_getsegcount(mmap_object *self, Py_ssize_t *lenp)
{
CHECK_VALID(-1);
if (lenp)
@ -620,8 +620,8 @@ mmap_buffer_getsegcount(mmap_object *self, int *lenp)
return 1;
}
static int
mmap_buffer_getcharbuffer(mmap_object *self, int index, const void **ptr)
static Py_ssize_t
mmap_buffer_getcharbuffer(mmap_object *self, Py_ssize_t index, const void **ptr)
{
if ( index != 0 ) {
PyErr_SetString(PyExc_SystemError,
@ -638,7 +638,7 @@ mmap_object_getattr(mmap_object *self, char *name)
return Py_FindMethod (mmap_object_methods, (PyObject *)self, name);
}
static int
static Py_ssize_t
mmap_length(mmap_object *self)
{
CHECK_VALID(-1);
@ -646,7 +646,7 @@ mmap_length(mmap_object *self)
}
static PyObject *
mmap_item(mmap_object *self, int i)
mmap_item(mmap_object *self, Py_ssize_t i)
{
CHECK_VALID(NULL);
if (i < 0 || (size_t)i >= self->size) {
@ -657,7 +657,7 @@ mmap_item(mmap_object *self, int i)
}
static PyObject *
mmap_slice(mmap_object *self, int ilow, int ihigh)
mmap_slice(mmap_object *self, Py_ssize_t ilow, Py_ssize_t ihigh)
{
CHECK_VALID(NULL);
if (ilow < 0)
@ -684,7 +684,7 @@ mmap_concat(mmap_object *self, PyObject *bb)
}
static PyObject *
mmap_repeat(mmap_object *self, int n)
mmap_repeat(mmap_object *self, Py_ssize_t n)
{
CHECK_VALID(NULL);
PyErr_SetString(PyExc_SystemError,
@ -693,7 +693,7 @@ mmap_repeat(mmap_object *self, int n)
}
static int
mmap_ass_slice(mmap_object *self, int ilow, int ihigh, PyObject *v)
mmap_ass_slice(mmap_object *self, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *v)
{
const char *buf;
@ -732,7 +732,7 @@ mmap_ass_slice(mmap_object *self, int ilow, int ihigh, PyObject *v)
}
static int
mmap_ass_item(mmap_object *self, int i, PyObject *v)
mmap_ass_item(mmap_object *self, Py_ssize_t i, PyObject *v)
{
const char *buf;
@ -759,20 +759,20 @@ mmap_ass_item(mmap_object *self, int i, PyObject *v)
}
static PySequenceMethods mmap_as_sequence = {
(inquiry)mmap_length, /*sq_length*/
(lenfunc)mmap_length, /*sq_length*/
(binaryfunc)mmap_concat, /*sq_concat*/
(intargfunc)mmap_repeat, /*sq_repeat*/
(intargfunc)mmap_item, /*sq_item*/
(intintargfunc)mmap_slice, /*sq_slice*/
(intobjargproc)mmap_ass_item, /*sq_ass_item*/
(intintobjargproc)mmap_ass_slice, /*sq_ass_slice*/
(ssizeargfunc)mmap_repeat, /*sq_repeat*/
(ssizeargfunc)mmap_item, /*sq_item*/
(ssizessizeargfunc)mmap_slice, /*sq_slice*/
(ssizeobjargproc)mmap_ass_item, /*sq_ass_item*/
(ssizessizeobjargproc)mmap_ass_slice, /*sq_ass_slice*/
};
static PyBufferProcs mmap_as_buffer = {
(getreadbufferproc)mmap_buffer_getreadbuf,
(getwritebufferproc)mmap_buffer_getwritebuf,
(getsegcountproc)mmap_buffer_getsegcount,
(getcharbufferproc)mmap_buffer_getcharbuffer,
(readbufferproc)mmap_buffer_getreadbuf,
(writebufferproc)mmap_buffer_getwritebuf,
(segcountproc)mmap_buffer_getsegcount,
(charbufferproc)mmap_buffer_getcharbuffer,
};
static PyTypeObject mmap_object_type = {

View File

@ -55,9 +55,9 @@ PyDoc_STRVAR(parser_doc_string,
static char parser_version_string[] = "0.5";
typedef PyObject* (*SeqMaker) (int length);
typedef PyObject* (*SeqMaker) (Py_ssize_t length);
typedef int (*SeqInserter) (PyObject* sequence,
int index,
Py_ssize_t index,
PyObject* element);
/* The function below is copyrighted by Stichting Mathematisch Centrum. The
@ -632,8 +632,9 @@ parser_tuple2st(PyST_Object *self, PyObject *args, PyObject *kw)
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 @@ build_node_children(PyObject *tuple, node *root, int *line_num)
return (0);
}
if (ISTERMINAL(type)) {
int len = PyObject_Size(elem);
Py_ssize_t len = PyObject_Size(elem);
PyObject *temp;
if ((len != 2) && (len != 3)) {

View File

@ -1642,7 +1642,7 @@ posix_listdir(PyObject *self, PyObject *args)
/* MAX_PATH characters could mean a bigger encoded string */
char namebuf[MAX_PATH*2+5];
char *bufptr = namebuf;
int len = sizeof(namebuf)/sizeof(namebuf[0]);
Py_ssize_t len = sizeof(namebuf)/sizeof(namebuf[0]);
#ifdef Py_WIN_WIDE_FILENAMES
/* If on wide-character-capable OS see if argument
@ -2340,7 +2340,7 @@ posix_execv(PyObject *self, PyObject *args)
PyObject *argv;
char **argvlist;
int i, argc;
PyObject *(*getitem)(PyObject *, int);
PyObject *(*getitem)(PyObject *, Py_ssize_t);
/* execv has two arguments: (path, argv), where
argv is a list or tuple of strings. */
@ -2409,7 +2409,7 @@ posix_execve(PyObject *self, PyObject *args)
char **envlist;
PyObject *key, *val, *keys=NULL, *vals=NULL;
int i, pos, argc, envc;
PyObject *(*getitem)(PyObject *, int);
PyObject *(*getitem)(PyObject *, Py_ssize_t);
int lastarg = 0;
/* execve has three arguments: (path, argv, env), where
@ -2553,7 +2553,7 @@ posix_spawnv(PyObject *self, PyObject *args)
char **argvlist;
int mode, i, argc;
Py_intptr_t spawnval;
PyObject *(*getitem)(PyObject *, int);
PyObject *(*getitem)(PyObject *, Py_ssize_t);
/* spawnv has three arguments: (mode, path, argv), where
argv is a list or tuple of strings. */
@ -2642,7 +2642,7 @@ posix_spawnve(PyObject *self, PyObject *args)
PyObject *key, *val, *keys=NULL, *vals=NULL, *res=NULL;
int mode, i, pos, argc, envc;
Py_intptr_t spawnval;
PyObject *(*getitem)(PyObject *, int);
PyObject *(*getitem)(PyObject *, Py_ssize_t);
int lastarg = 0;
/* spawnve has four arguments: (mode, path, argv, env), where
@ -2794,7 +2794,7 @@ posix_spawnvp(PyObject *self, PyObject *args)
char **argvlist;
int mode, i, argc;
Py_intptr_t spawnval;
PyObject *(*getitem)(PyObject *, int);
PyObject *(*getitem)(PyObject *, Py_ssize_t);
/* spawnvp has three arguments: (mode, path, argv), where
argv is a list or tuple of strings. */
@ -2875,7 +2875,7 @@ posix_spawnvpe(PyObject *self, PyObject *args)
PyObject *key, *val, *keys=NULL, *vals=NULL, *res=NULL;
int mode, i, pos, argc, envc;
Py_intptr_t spawnval;
PyObject *(*getitem)(PyObject *, int);
PyObject *(*getitem)(PyObject *, Py_ssize_t);
int lastarg = 0;
/* spawnvpe has four arguments: (mode, path, argv, env), where
@ -4310,14 +4310,15 @@ _PyPopenCreateProcess(char *cmdstring,
char *s1,*s2, *s3 = " /c ";
const char *szConsoleSpawn = "w9xpopen.exe";
int i;
int x;
Py_ssize_t x;
if (i = GetEnvironmentVariable("COMSPEC",NULL,0)) {
char *comshell;
s1 = (char *)alloca(i);
if (!(x = GetEnvironmentVariable("COMSPEC", s1, i)))
return x;
/* x < i, so x fits into an integer */
return (int)x;
/* Explicitly check if we are using COMMAND.COM. If we are
* then use the w9xpopen hack.
@ -4520,7 +4521,7 @@ _PyPopen(char *cmdstring, int mode, int n)
switch (mode & (_O_RDONLY | _O_TEXT | _O_BINARY | _O_WRONLY)) {
case _O_WRONLY | _O_TEXT:
/* Case for writing to child Stdin in text mode. */
fd1 = _open_osfhandle((long)hChildStdinWrDup, mode);
fd1 = _open_osfhandle((intptr_t)hChildStdinWrDup, mode);
f1 = _fdopen(fd1, "w");
f = PyFile_FromFile(f1, cmdstring, "w", _PyPclose);
PyFile_SetBufSize(f, 0);
@ -4531,7 +4532,7 @@ _PyPopen(char *cmdstring, int mode, int n)
case _O_RDONLY | _O_TEXT:
/* Case for reading from child Stdout in text mode. */
fd1 = _open_osfhandle((long)hChildStdoutRdDup, mode);
fd1 = _open_osfhandle((intptr_t)hChildStdoutRdDup, mode);
f1 = _fdopen(fd1, "r");
f = PyFile_FromFile(f1, cmdstring, "r", _PyPclose);
PyFile_SetBufSize(f, 0);
@ -4542,7 +4543,7 @@ _PyPopen(char *cmdstring, int mode, int n)
case _O_RDONLY | _O_BINARY:
/* Case for readinig from child Stdout in binary mode. */
fd1 = _open_osfhandle((long)hChildStdoutRdDup, mode);
fd1 = _open_osfhandle((intptr_t)hChildStdoutRdDup, mode);
f1 = _fdopen(fd1, "rb");
f = PyFile_FromFile(f1, cmdstring, "rb", _PyPclose);
PyFile_SetBufSize(f, 0);
@ -4553,7 +4554,7 @@ _PyPopen(char *cmdstring, int mode, int n)
case _O_WRONLY | _O_BINARY:
/* Case for writing to child Stdin in binary mode. */
fd1 = _open_osfhandle((long)hChildStdinWrDup, mode);
fd1 = _open_osfhandle((intptr_t)hChildStdinWrDup, mode);
f1 = _fdopen(fd1, "wb");
f = PyFile_FromFile(f1, cmdstring, "wb", _PyPclose);
PyFile_SetBufSize(f, 0);
@ -4579,9 +4580,9 @@ _PyPopen(char *cmdstring, int mode, int n)
m2 = "wb";
}
fd1 = _open_osfhandle((long)hChildStdinWrDup, mode);
fd1 = _open_osfhandle((intptr_t)hChildStdinWrDup, mode);
f1 = _fdopen(fd1, m2);
fd2 = _open_osfhandle((long)hChildStdoutRdDup, mode);
fd2 = _open_osfhandle((intptr_t)hChildStdoutRdDup, mode);
f2 = _fdopen(fd2, m1);
p1 = PyFile_FromFile(f1, cmdstring, m2, _PyPclose);
PyFile_SetBufSize(p1, 0);
@ -4611,11 +4612,11 @@ _PyPopen(char *cmdstring, int mode, int n)
m2 = "wb";
}
fd1 = _open_osfhandle((long)hChildStdinWrDup, mode);
fd1 = _open_osfhandle((intptr_t)hChildStdinWrDup, mode);
f1 = _fdopen(fd1, m2);
fd2 = _open_osfhandle((long)hChildStdoutRdDup, mode);
fd2 = _open_osfhandle((intptr_t)hChildStdoutRdDup, mode);
f2 = _fdopen(fd2, m1);
fd3 = _open_osfhandle((long)hChildStderrRdDup, mode);
fd3 = _open_osfhandle((intptr_t)hChildStderrRdDup, mode);
f3 = _fdopen(fd3, m1);
p1 = PyFile_FromFile(f1, cmdstring, m2, _PyPclose);
p2 = PyFile_FromFile(f2, cmdstring, m1, _PyPclose);
@ -5117,8 +5118,8 @@ PyDoc_STRVAR(posix_waitpid__doc__,
static PyObject *
posix_waitpid(PyObject *self, PyObject *args)
{
int pid, options;
int status;
intptr_t pid;
int status, options;
if (!PyArg_ParseTuple(args, "ii:waitpid", &pid, &options))
return NULL;

View File

@ -168,7 +168,7 @@ putlong(FILE *outf, Py_UInt32 val)
buf[1] = (unsigned char) (val >> 16);
buf[2] = (unsigned char) (val >> 8);
buf[3] = (unsigned char) (val >> 0);
return fwrite(buf, 4, 1, outf);
return (int)fwrite(buf, 4, 1, outf);
}
static void
@ -200,7 +200,7 @@ writeheader(FILE *outf, IMAGE *image)
putlong(outf, image->min);
putlong(outf, image->max);
putlong(outf, 0);
return fwrite("no name", 8, 1, outf);
return (int)fwrite("no name", 8, 1, outf);
}
static int
@ -567,7 +567,8 @@ longstoimage(PyObject *self, PyObject *args)
Py_Int32 *starttab = NULL, *lengthtab = NULL;
unsigned char *rlebuf = NULL;
unsigned char *lumbuf = NULL;
int rlebuflen, goodwrite;
int rlebuflen;
Py_ssize_t goodwrite;
PyObject *retval = NULL;
if (!PyArg_ParseTuple(args, "s#iiis:longstoimage", &lptr, &len,

View File

@ -340,7 +340,7 @@ static PyTypeObject poll_Type;
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);

View File

@ -543,7 +543,7 @@ hashed.");
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;

View File

@ -170,7 +170,7 @@ strop_joinfields(PyObject *self, PyObject *args)
int i, reslen = 0, slen = 0, sz = 100;
PyObject *res = NULL;
char* p = NULL;
intargfunc getitemfunc;
ssizeargfunc getitemfunc;
WARN;
if (!PyArg_ParseTuple(args, "O|t#:join", &seq, &sep, &seplen))
@ -364,7 +364,7 @@ static PyObject *
do_strip(PyObject *args, int striptype)
{
char *s;
int len, i, j;
Py_ssize_t len, i, j;
if (PyString_AsStringAndSize(args, &s, &len))
@ -443,7 +443,7 @@ static PyObject *
strop_lower(PyObject *self, PyObject *args)
{
char *s, *s_new;
int i, n;
Py_ssize_t i, n;
PyObject *new;
int changed;
@ -482,7 +482,7 @@ static PyObject *
strop_upper(PyObject *self, PyObject *args)
{
char *s, *s_new;
int i, n;
Py_ssize_t i, n;
PyObject *new;
int changed;
@ -522,7 +522,7 @@ static PyObject *
strop_capitalize(PyObject *self, PyObject *args)
{
char *s, *s_new;
int i, n;
Py_ssize_t i, n;
PyObject *new;
int changed;
@ -688,7 +688,7 @@ static PyObject *
strop_swapcase(PyObject *self, PyObject *args)
{
char *s, *s_new;
int i, n;
Py_ssize_t i, n;
PyObject *new;
int changed;

View File

@ -249,6 +249,7 @@ make_filename(char *prefix, char *name, char *path)
*p = SEP;
}
len += strlen(name);
assert(len < INT_MAX);
return (int)len;
}
@ -808,7 +809,8 @@ get_data(char *archive, PyObject *toc_entry)
PyObject *raw_data, *data = NULL, *decompress;
char *buf;
FILE *fp;
int err, bytes_read = 0;
int err;
Py_ssize_t bytes_read = 0;
long l;
char *datapath;
long compress, data_size, file_size, file_offset;
@ -1024,7 +1026,7 @@ get_mtime_of_source(ZipImporter *self, char *path)
{
PyObject *toc_entry;
time_t mtime = 0;
int lastchar = strlen(path) - 1;
Py_ssize_t lastchar = strlen(path) - 1;
char savechar = path[lastchar];
path[lastchar] = '\0'; /* strip 'c' or 'o' from *.py[co] */
toc_entry = PyDict_GetItemString(self->files, path);

View File

@ -56,7 +56,7 @@ PyObject_Type(PyObject *o)
return v;
}
int
Py_ssize_t
PyObject_Size(PyObject *o)
{
PySequenceMethods *m;
@ -74,17 +74,17 @@ PyObject_Size(PyObject *o)
}
#undef PyObject_Length
int
Py_ssize_t
PyObject_Length(PyObject *o)
{
return PyObject_Size(o);
}
#define PyObject_Length PyObject_Size
int
Py_ssize_t
_PyObject_LengthHint(PyObject *o)
{
int rv = PyObject_Size(o);
Py_ssize_t rv = PyObject_Size(o);
if (rv != -1)
return rv;
if (PyErr_ExceptionMatches(PyExc_TypeError) ||
@ -94,7 +94,7 @@ _PyObject_LengthHint(PyObject *o)
PyErr_Fetch(&err_type, &err_value, &err_tb);
ro = PyObject_CallMethod(o, "__length_hint__", NULL);
if (ro != NULL) {
rv = (int)PyInt_AsLong(ro);
rv = PyInt_AsLong(ro);
Py_DECREF(ro);
Py_XDECREF(err_type);
Py_XDECREF(err_value);
@ -218,11 +218,11 @@ PyObject_DelItemString(PyObject *o, char *key)
int PyObject_AsCharBuffer(PyObject *obj,
const char **buffer,
int *buffer_len)
Py_ssize_t *buffer_len)
{
PyBufferProcs *pb;
const char *pp;
int len;
Py_ssize_t len;
if (obj == NULL || buffer == NULL || buffer_len == NULL) {
null_error();
@ -264,11 +264,11 @@ PyObject_CheckReadBuffer(PyObject *obj)
int PyObject_AsReadBuffer(PyObject *obj,
const void **buffer,
int *buffer_len)
Py_ssize_t *buffer_len)
{
PyBufferProcs *pb;
void *pp;
int len;
Py_ssize_t len;
if (obj == NULL || buffer == NULL || buffer_len == NULL) {
null_error();
@ -297,11 +297,11 @@ int PyObject_AsReadBuffer(PyObject *obj,
int PyObject_AsWriteBuffer(PyObject *obj,
void **buffer,
int *buffer_len)
Py_ssize_t *buffer_len)
{
PyBufferProcs *pb;
void*pp;
int len;
Py_ssize_t len;
if (obj == NULL || buffer == NULL || buffer_len == NULL) {
null_error();
@ -645,7 +645,7 @@ PyNumber_Add(PyObject *v, PyObject *w)
}
static PyObject *
sequence_repeat(intargfunc repeatfunc, PyObject *seq, PyObject *n)
sequence_repeat(ssizeargfunc repeatfunc, PyObject *seq, PyObject *n)
{
long count;
if (PyInt_Check(n)) {
@ -839,7 +839,7 @@ PyNumber_InPlaceMultiply(PyObject *v, PyObject *w)
PyObject *result = binary_iop1(v, w, NB_SLOT(nb_inplace_multiply),
NB_SLOT(nb_multiply));
if (result == Py_NotImplemented) {
intargfunc f = NULL;
ssizeargfunc f = NULL;
PySequenceMethods *mv = v->ob_type->tp_as_sequence;
PySequenceMethods *mw = w->ob_type->tp_as_sequence;
Py_DECREF(result);
@ -943,7 +943,7 @@ PyNumber_Absolute(PyObject *o)
/* Add a check for embedded NULL-bytes in the argument. */
static PyObject *
int_from_string(const char *s, int len)
int_from_string(const char *s, Py_ssize_t len)
{
char *end;
PyObject *x;
@ -965,7 +965,7 @@ PyNumber_Int(PyObject *o)
{
PyNumberMethods *m;
const char *buffer;
int buffer_len;
Py_ssize_t buffer_len;
if (o == NULL)
return null_error();
@ -1006,7 +1006,7 @@ PyNumber_Int(PyObject *o)
/* Add a check for embedded NULL-bytes in the argument. */
static PyObject *
long_from_string(const char *s, int len)
long_from_string(const char *s, Py_ssize_t len)
{
char *end;
PyObject *x;
@ -1028,7 +1028,7 @@ PyNumber_Long(PyObject *o)
{
PyNumberMethods *m;
const char *buffer;
int buffer_len;
Py_ssize_t buffer_len;
if (o == NULL)
return null_error();
@ -1103,7 +1103,7 @@ PySequence_Check(PyObject *s)
s->ob_type->tp_as_sequence->sq_item != NULL;
}
int
Py_ssize_t
PySequence_Size(PyObject *s)
{
PySequenceMethods *m;
@ -1122,7 +1122,7 @@ PySequence_Size(PyObject *s)
}
#undef PySequence_Length
int
Py_ssize_t
PySequence_Length(PyObject *s)
{
return PySequence_Size(s);
@ -1154,7 +1154,7 @@ PySequence_Concat(PyObject *s, PyObject *o)
}
PyObject *
PySequence_Repeat(PyObject *o, int count)
PySequence_Repeat(PyObject *o, Py_ssize_t count)
{
PySequenceMethods *m;
@ -1207,7 +1207,7 @@ PySequence_InPlaceConcat(PyObject *s, PyObject *o)
}
PyObject *
PySequence_InPlaceRepeat(PyObject *o, int count)
PySequence_InPlaceRepeat(PyObject *o, Py_ssize_t count)
{
PySequenceMethods *m;
@ -1236,7 +1236,7 @@ PySequence_InPlaceRepeat(PyObject *o, int count)
}
PyObject *
PySequence_GetItem(PyObject *s, int i)
PySequence_GetItem(PyObject *s, Py_ssize_t i)
{
PySequenceMethods *m;
@ -1247,7 +1247,7 @@ PySequence_GetItem(PyObject *s, int i)
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;
@ -1260,7 +1260,7 @@ PySequence_GetItem(PyObject *s, int i)
}
static PyObject *
sliceobj_from_intint(int i, int j)
sliceobj_from_intint(Py_ssize_t i, Py_ssize_t j)
{
PyObject *start, *end, *slice;
start = PyInt_FromLong((long)i);
@ -1278,7 +1278,7 @@ sliceobj_from_intint(int i, int j)
}
PyObject *
PySequence_GetSlice(PyObject *s, int i1, int i2)
PySequence_GetSlice(PyObject *s, Py_ssize_t i1, Py_ssize_t i2)
{
PySequenceMethods *m;
PyMappingMethods *mp;
@ -1289,7 +1289,7 @@ PySequence_GetSlice(PyObject *s, int i1, int i2)
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)
@ -1313,7 +1313,7 @@ PySequence_GetSlice(PyObject *s, int i1, int i2)
}
int
PySequence_SetItem(PyObject *s, int i, PyObject *o)
PySequence_SetItem(PyObject *s, Py_ssize_t i, PyObject *o)
{
PySequenceMethods *m;
@ -1326,7 +1326,7 @@ PySequence_SetItem(PyObject *s, int i, PyObject *o)
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;
@ -1340,7 +1340,7 @@ PySequence_SetItem(PyObject *s, int i, PyObject *o)
}
int
PySequence_DelItem(PyObject *s, int i)
PySequence_DelItem(PyObject *s, Py_ssize_t i)
{
PySequenceMethods *m;
@ -1353,7 +1353,7 @@ PySequence_DelItem(PyObject *s, int i)
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;
@ -1367,7 +1367,7 @@ PySequence_DelItem(PyObject *s, int i)
}
int
PySequence_SetSlice(PyObject *s, int i1, int i2, PyObject *o)
PySequence_SetSlice(PyObject *s, Py_ssize_t i1, Py_ssize_t i2, PyObject *o)
{
PySequenceMethods *m;
PyMappingMethods *mp;
@ -1381,7 +1381,7 @@ PySequence_SetSlice(PyObject *s, int i1, int i2, PyObject *o)
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)
@ -1406,7 +1406,7 @@ PySequence_SetSlice(PyObject *s, int i1, int i2, PyObject *o)
}
int
PySequence_DelSlice(PyObject *s, int i1, int i2)
PySequence_DelSlice(PyObject *s, Py_ssize_t i1, Py_ssize_t i2)
{
PySequenceMethods *m;
@ -1419,7 +1419,7 @@ PySequence_DelSlice(PyObject *s, int i1, int i2)
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)
@ -1438,9 +1438,9 @@ PyObject *
PySequence_Tuple(PyObject *v)
{
PyObject *it; /* iter(v) */
int n; /* guess for result tuple size */
Py_ssize_t n; /* guess for result tuple size */
PyObject *result;
int j;
Py_ssize_t j;
if (v == NULL)
return null_error();
@ -1486,7 +1486,7 @@ PySequence_Tuple(PyObject *v)
break;
}
if (j >= n) {
int oldn = n;
Py_ssize_t oldn = n;
/* The over-allocation strategy can grow a bit faster
than for lists because unlike lists the
over-allocation isn't permanent -- we reclaim
@ -1708,7 +1708,7 @@ PyMapping_Check(PyObject *o)
o->ob_type->tp_as_sequence->sq_slice);
}
int
Py_ssize_t
PyMapping_Size(PyObject *o)
{
PyMappingMethods *m;
@ -1727,7 +1727,7 @@ PyMapping_Size(PyObject *o)
}
#undef PyMapping_Length
int
Py_ssize_t
PyMapping_Length(PyObject *o)
{
return PyMapping_Size(o);
@ -2053,7 +2053,7 @@ static int
abstract_issubclass(PyObject *derived, PyObject *cls)
{
PyObject *bases;
int i, n;
Py_ssize_t i, n;
int r = 0;
@ -2137,7 +2137,7 @@ recursive_isinstance(PyObject *inst, PyObject *cls, int recursion_depth)
}
}
else if (PyTuple_Check(cls)) {
int i, n;
Py_ssize_t i, n;
if (!recursion_depth) {
PyErr_SetString(PyExc_RuntimeError,
@ -2191,8 +2191,8 @@ recursive_issubclass(PyObject *derived, PyObject *cls, int recursion_depth)
return -1;
if (PyTuple_Check(cls)) {
int i;
int n = PyTuple_GET_SIZE(cls);
Py_ssize_t i;
Py_ssize_t n = PyTuple_GET_SIZE(cls);
if (!recursion_depth) {
PyErr_SetString(PyExc_RuntimeError,

View File

@ -8,15 +8,15 @@ typedef struct {
PyObject_HEAD
PyObject *b_base;
void *b_ptr;
int b_size;
int b_offset;
Py_ssize_t b_size;
Py_ssize_t b_offset;
int b_readonly;
long b_hash;
} PyBufferObject;
static int
get_buf(PyBufferObject *self, void **ptr, int *size)
get_buf(PyBufferObject *self, void **ptr, Py_ssize_t *size)
{
if (self->b_base == NULL) {
assert (ptr != NULL);
@ -24,8 +24,8 @@ get_buf(PyBufferObject *self, void **ptr, int *size)
*size = self->b_size;
}
else {
int count, offset;
getreadbufferproc proc;
Py_ssize_t count, offset;
readbufferproc proc;
PyBufferProcs *bp = self->b_base->ob_type->tp_as_buffer;
if ((*bp->bf_getsegcount)(self->b_base, NULL) != 1) {
PyErr_SetString(PyExc_TypeError,
@ -35,7 +35,7 @@ get_buf(PyBufferObject *self, void **ptr, int *size)
if (self->b_readonly)
proc = bp->bf_getreadbuffer;
else
proc = (getreadbufferproc)bp->bf_getwritebuffer;
proc = (readbufferproc)bp->bf_getwritebuffer;
if ((count = (*proc)(self->b_base, 0, ptr)) < 0)
return 0;
/* apply constraints to the start/end */
@ -56,7 +56,7 @@ get_buf(PyBufferObject *self, void **ptr, int *size)
static PyObject *
buffer_from_memory(PyObject *base, int size, int offset, void *ptr,
buffer_from_memory(PyObject *base, Py_ssize_t size, Py_ssize_t offset, void *ptr,
int readonly)
{
PyBufferObject * b;
@ -88,7 +88,7 @@ buffer_from_memory(PyObject *base, int size, int offset, void *ptr,
}
static PyObject *
buffer_from_object(PyObject *base, int size, int offset, int readonly)
buffer_from_object(PyObject *base, Py_ssize_t size, Py_ssize_t offset, int readonly)
{
if (offset < 0) {
PyErr_SetString(PyExc_ValueError,
@ -99,7 +99,7 @@ buffer_from_object(PyObject *base, int size, int offset, int readonly)
/* another buffer, refer to the base object */
PyBufferObject *b = (PyBufferObject *)base;
if (b->b_size != Py_END_OF_BUFFER) {
int base_size = b->b_size - offset;
Py_ssize_t base_size = b->b_size - offset;
if (base_size < 0)
base_size = 0;
if (size == Py_END_OF_BUFFER || size > base_size)
@ -113,7 +113,7 @@ buffer_from_object(PyObject *base, int size, int offset, int readonly)
PyObject *
PyBuffer_FromObject(PyObject *base, int offset, int size)
PyBuffer_FromObject(PyObject *base, Py_ssize_t offset, Py_ssize_t size)
{
PyBufferProcs *pb = base->ob_type->tp_as_buffer;
@ -129,7 +129,7 @@ PyBuffer_FromObject(PyObject *base, int offset, int size)
}
PyObject *
PyBuffer_FromReadWriteObject(PyObject *base, int offset, int size)
PyBuffer_FromReadWriteObject(PyObject *base, Py_ssize_t offset, Py_ssize_t size)
{
PyBufferProcs *pb = base->ob_type->tp_as_buffer;
@ -145,19 +145,19 @@ PyBuffer_FromReadWriteObject(PyObject *base, int offset, int size)
}
PyObject *
PyBuffer_FromMemory(void *ptr, int size)
PyBuffer_FromMemory(void *ptr, Py_ssize_t size)
{
return buffer_from_memory(NULL, size, 0, ptr, 1);
}
PyObject *
PyBuffer_FromReadWriteMemory(void *ptr, int size)
PyBuffer_FromReadWriteMemory(void *ptr, Py_ssize_t size)
{
return buffer_from_memory(NULL, size, 0, ptr, 0);
}
PyObject *
PyBuffer_New(int size)
PyBuffer_New(Py_ssize_t size)
{
PyObject *o;
PyBufferObject * b;
@ -167,6 +167,7 @@ PyBuffer_New(int size)
"size must be zero or positive");
return NULL;
}
/* XXX: check for overflow in multiply */
/* Inline PyObject_New */
o = PyObject_MALLOC(sizeof(*b) + size);
if ( o == NULL )
@ -189,13 +190,13 @@ static PyObject *
buffer_new(PyTypeObject *type, PyObject *args, PyObject *kw)
{
PyObject *ob;
int offset = 0;
int size = Py_END_OF_BUFFER;
Py_ssize_t offset = 0;
Py_ssize_t size = Py_END_OF_BUFFER;
if (!_PyArg_NoKeywords("buffer()", kw))
return NULL;
if (!PyArg_ParseTuple(args, "O|ii:buffer", &ob, &offset, &size))
if (!PyArg_ParseTuple(args, "O|ll:buffer", &ob, &offset, &size))
return NULL;
return PyBuffer_FromObject(ob, offset, size);
}
@ -220,7 +221,8 @@ static int
buffer_compare(PyBufferObject *self, PyBufferObject *other)
{
void *p1, *p2;
int len_self, len_other, min_len, cmp;
Py_ssize_t len_self, len_other, min_len;
int cmp;
if (!get_buf(self, &p1, &len_self))
return -1;
@ -238,17 +240,17 @@ buffer_compare(PyBufferObject *self, PyBufferObject *other)
static PyObject *
buffer_repr(PyBufferObject *self)
{
char *status = self->b_readonly ? "read-only" : "read-write";
const char *status = self->b_readonly ? "read-only" : "read-write";
if ( self->b_base == NULL )
return PyString_FromFormat("<%s buffer ptr %p, size %d at %p>",
return PyString_FromFormat("<%s buffer ptr %p, size %ld at %p>",
status,
self->b_ptr,
self->b_size,
self);
else
return PyString_FromFormat(
"<%s buffer for %p, size %d, offset %d at %p>",
"<%s buffer for %p, size %ld, offset %ld at %p>",
status,
self->b_base,
self->b_size,
@ -260,8 +262,8 @@ static long
buffer_hash(PyBufferObject *self)
{
void *ptr;
int size;
register int len;
Py_ssize_t size;
register Py_ssize_t len;
register unsigned char *p;
register long x;
@ -300,7 +302,7 @@ static PyObject *
buffer_str(PyBufferObject *self)
{
void *ptr;
int size;
Py_ssize_t size;
if (!get_buf(self, &ptr, &size))
return NULL;
return PyString_FromStringAndSize(ptr, size);
@ -308,11 +310,11 @@ buffer_str(PyBufferObject *self)
/* Sequence methods */
static int
static Py_ssize_t
buffer_length(PyBufferObject *self)
{
void *ptr;
int size;
Py_ssize_t size;
if (!get_buf(self, &ptr, &size))
return -1;
return size;
@ -325,7 +327,7 @@ buffer_concat(PyBufferObject *self, PyObject *other)
void *ptr1, *ptr2;
char *p;
PyObject *ob;
int size, count;
Py_ssize_t size, count;
if ( pb == NULL ||
pb->bf_getreadbuffer == NULL ||
@ -369,12 +371,12 @@ buffer_concat(PyBufferObject *self, PyObject *other)
}
static PyObject *
buffer_repeat(PyBufferObject *self, int count)
buffer_repeat(PyBufferObject *self, Py_ssize_t count)
{
PyObject *ob;
register char *p;
void *ptr;
int size;
Py_ssize_t size;
if ( count < 0 )
count = 0;
@ -398,10 +400,10 @@ buffer_repeat(PyBufferObject *self, int count)
}
static PyObject *
buffer_item(PyBufferObject *self, int idx)
buffer_item(PyBufferObject *self, Py_ssize_t idx)
{
void *ptr;
int size;
Py_ssize_t size;
if (!get_buf(self, &ptr, &size))
return NULL;
if ( idx < 0 || idx >= size ) {
@ -412,10 +414,10 @@ buffer_item(PyBufferObject *self, int idx)
}
static PyObject *
buffer_slice(PyBufferObject *self, int left, int right)
buffer_slice(PyBufferObject *self, Py_ssize_t left, Py_ssize_t right)
{
void *ptr;
int size;
Py_ssize_t size;
if (!get_buf(self, &ptr, &size))
return NULL;
if ( left < 0 )
@ -431,12 +433,12 @@ buffer_slice(PyBufferObject *self, int left, int right)
}
static int
buffer_ass_item(PyBufferObject *self, int idx, PyObject *other)
buffer_ass_item(PyBufferObject *self, Py_ssize_t idx, PyObject *other)
{
PyBufferProcs *pb;
void *ptr1, *ptr2;
int size;
int count;
Py_ssize_t size;
Py_ssize_t count;
if ( self->b_readonly ) {
PyErr_SetString(PyExc_TypeError,
@ -482,13 +484,13 @@ buffer_ass_item(PyBufferObject *self, int idx, PyObject *other)
}
static int
buffer_ass_slice(PyBufferObject *self, int left, int right, PyObject *other)
buffer_ass_slice(PyBufferObject *self, Py_ssize_t left, Py_ssize_t right, PyObject *other)
{
PyBufferProcs *pb;
void *ptr1, *ptr2;
int size;
int slice_len;
int count;
Py_ssize_t size;
Py_ssize_t slice_len;
Py_ssize_t count;
if ( self->b_readonly ) {
PyErr_SetString(PyExc_TypeError,
@ -541,10 +543,10 @@ buffer_ass_slice(PyBufferObject *self, int left, int right, PyObject *other)
/* Buffer methods */
static int
buffer_getreadbuf(PyBufferObject *self, int idx, void **pp)
static Py_ssize_t
buffer_getreadbuf(PyBufferObject *self, Py_ssize_t idx, void **pp)
{
int size;
Py_ssize_t size;
if ( idx != 0 ) {
PyErr_SetString(PyExc_SystemError,
"accessing non-existent buffer segment");
@ -555,8 +557,8 @@ buffer_getreadbuf(PyBufferObject *self, int idx, void **pp)
return size;
}
static int
buffer_getwritebuf(PyBufferObject *self, int idx, void **pp)
static Py_ssize_t
buffer_getwritebuf(PyBufferObject *self, Py_ssize_t idx, void **pp)
{
if ( self->b_readonly )
{
@ -566,11 +568,11 @@ buffer_getwritebuf(PyBufferObject *self, int idx, void **pp)
return buffer_getreadbuf(self, idx, pp);
}
static int
buffer_getsegcount(PyBufferObject *self, int *lenp)
static Py_ssize_t
buffer_getsegcount(PyBufferObject *self, Py_ssize_t *lenp)
{
void *ptr;
int size;
Py_ssize_t size;
if (!get_buf(self, &ptr, &size))
return -1;
if (lenp)
@ -578,11 +580,11 @@ buffer_getsegcount(PyBufferObject *self, int *lenp)
return 1;
}
static int
buffer_getcharbuf(PyBufferObject *self, int idx, const char **pp)
static Py_ssize_t
buffer_getcharbuf(PyBufferObject *self, Py_ssize_t idx, const char **pp)
{
void *ptr;
int size;
Py_ssize_t size;
if ( idx != 0 ) {
PyErr_SetString(PyExc_SystemError,
"accessing non-existent buffer segment");
@ -596,20 +598,20 @@ buffer_getcharbuf(PyBufferObject *self, int idx, const char **pp)
static PySequenceMethods buffer_as_sequence = {
(inquiry)buffer_length, /*sq_length*/
(lenfunc)buffer_length, /*sq_length*/
(binaryfunc)buffer_concat, /*sq_concat*/
(intargfunc)buffer_repeat, /*sq_repeat*/
(intargfunc)buffer_item, /*sq_item*/
(intintargfunc)buffer_slice, /*sq_slice*/
(intobjargproc)buffer_ass_item, /*sq_ass_item*/
(intintobjargproc)buffer_ass_slice, /*sq_ass_slice*/
(ssizeargfunc)buffer_repeat, /*sq_repeat*/
(ssizeargfunc)buffer_item, /*sq_item*/
(ssizessizeargfunc)buffer_slice, /*sq_slice*/
(ssizeobjargproc)buffer_ass_item, /*sq_ass_item*/
(ssizessizeobjargproc)buffer_ass_slice, /*sq_ass_slice*/
};
static PyBufferProcs buffer_as_buffer = {
(getreadbufferproc)buffer_getreadbuf,
(getwritebufferproc)buffer_getwritebuf,
(getsegcountproc)buffer_getsegcount,
(getcharbufferproc)buffer_getcharbuf,
(readbufferproc)buffer_getreadbuf,
(writebufferproc)buffer_getwritebuf,
(segcountproc)buffer_getsegcount,
(charbufferproc)buffer_getcharbuf,
};
PyTypeObject PyBuffer_Type = {

View File

@ -68,7 +68,7 @@ PyClass_New(PyObject *bases, PyObject *dict, PyObject *name)
return NULL;
}
else {
int i, n;
Py_ssize_t i, n;
PyObject *base;
if (!PyTuple_Check(bases)) {
PyErr_SetString(PyExc_TypeError,
@ -185,7 +185,7 @@ class_dealloc(PyClassObject *op)
static PyObject *
class_lookup(PyClassObject *cp, PyObject *name, PyClassObject **pclass)
{
int i, n;
Py_ssize_t i, n;
PyObject *value = PyDict_GetItem(cp->cl_dict, name);
if (value != NULL) {
*pclass = cp;
@ -281,7 +281,7 @@ set_dict(PyClassObject *c, PyObject *v)
static char *
set_bases(PyClassObject *c, PyObject *v)
{
int i, n;
Py_ssize_t i, n;
if (v == NULL || !PyTuple_Check(v))
return "__bases__ must be a tuple object";
@ -483,7 +483,7 @@ PyTypeObject PyClass_Type = {
int
PyClass_IsSubclass(PyObject *class, PyObject *base)
{
int i, n;
Py_ssize_t i, n;
PyClassObject *cp;
if (class == base)
return 1;
@ -996,12 +996,12 @@ instance_traverse(PyInstanceObject *o, visitproc visit, void *arg)
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 @@ instance_length(PyInstanceObject *inst)
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,13 +1101,13 @@ instance_ass_subscript(PyInstanceObject *inst, PyObject *key, PyObject *value)
}
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 */
};
static PyObject *
instance_item(PyInstanceObject *inst, int i)
instance_item(PyInstanceObject *inst, Py_ssize_t i)
{
PyObject *func, *arg, *res;
@ -1112,7 +1116,7 @@ instance_item(PyInstanceObject *inst, int i)
func = instance_getattr(inst, getitemstr);
if (func == NULL)
return NULL;
arg = Py_BuildValue("(i)", i);
arg = Py_BuildValue("(n)", i);
if (arg == NULL) {
Py_DECREF(func);
return NULL;
@ -1124,7 +1128,7 @@ instance_item(PyInstanceObject *inst, int i)
}
static PyObject *
sliceobj_from_intint(int i, int j)
sliceobj_from_intint(Py_ssize_t i, Py_ssize_t j)
{
PyObject *start, *end, *res;
@ -1145,7 +1149,7 @@ sliceobj_from_intint(int i, int j)
static PyObject *
instance_slice(PyInstanceObject *inst, int i, int j)
instance_slice(PyInstanceObject *inst, Py_ssize_t i, Py_ssize_t j)
{
PyObject *func, *arg, *res;
static PyObject *getslicestr;
@ -1179,7 +1183,7 @@ instance_slice(PyInstanceObject *inst, int i, int j)
}
static int
instance_ass_item(PyInstanceObject *inst, int i, PyObject *item)
instance_ass_item(PyInstanceObject *inst, Py_ssize_t i, PyObject *item)
{
PyObject *func, *arg, *res;
@ -1213,7 +1217,7 @@ instance_ass_item(PyInstanceObject *inst, int i, PyObject *item)
}
static int
instance_ass_slice(PyInstanceObject *inst, int i, int j, PyObject *value)
instance_ass_slice(PyInstanceObject *inst, Py_ssize_t i, Py_ssize_t j, PyObject *value)
{
PyObject *func, *arg, *res;
static PyObject *setslicestr, *delslicestr;
@ -1322,13 +1326,13 @@ instance_contains(PyInstanceObject *inst, PyObject *member)
static PySequenceMethods
instance_as_sequence = {
(inquiry)instance_length, /* sq_length */
(lenfunc)instance_length, /* sq_length */
0, /* sq_concat */
0, /* sq_repeat */
(intargfunc)instance_item, /* sq_item */
(intintargfunc)instance_slice, /* sq_slice */
(intobjargproc)instance_ass_item, /* sq_ass_item */
(intintobjargproc)instance_ass_slice, /* sq_ass_slice */
(ssizeargfunc)instance_item, /* sq_item */
(ssizessizeargfunc)instance_slice, /* sq_slice */
(ssizeobjargproc)instance_ass_item, /* sq_ass_item */
(ssizessizeobjargproc)instance_ass_slice,/* sq_ass_slice */
(objobjproc)instance_contains, /* sq_contains */
};
@ -2430,7 +2434,7 @@ instancemethod_call(PyObject *func, PyObject *arg, PyObject *kw)
Py_INCREF(arg);
}
else {
int argcount = PyTuple_Size(arg);
Py_ssize_t argcount = PyTuple_Size(arg);
PyObject *newarg = PyTuple_New(argcount + 1);
int i;
if (newarg == NULL)

View File

@ -28,7 +28,7 @@ all_name_chars(unsigned char *s)
static void
intern_strings(PyObject *tuple)
{
int i;
Py_ssize_t i;
for (i = PyTuple_GET_SIZE(tuple); --i >= 0; ) {
PyObject *v = PyTuple_GET_ITEM(tuple, i);
@ -48,7 +48,7 @@ PyCode_New(int argcount, int nlocals, int stacksize, int flags,
PyObject *lnotab)
{
PyCodeObject *co;
int i;
Py_ssize_t i;
/* Check argument types */
if (argcount < 0 || nlocals < 0 ||
code == NULL ||
@ -135,7 +135,7 @@ validate_and_copy_tuple(PyObject *tup)
{
PyObject *newtuple;
PyObject *item;
int i, len;
Py_ssize_t i, len;
len = PyTuple_GET_SIZE(tup);
newtuple = PyTuple_New(len);

View File

@ -680,7 +680,7 @@ complex_subtype_from_string(PyTypeObject *type, PyObject *v)
#ifdef Py_USING_UNICODE
char s_buffer[256];
#endif
int len;
Py_ssize_t len;
if (PyString_Check(v)) {
s = PyString_AS_STRING(v);
@ -699,7 +699,7 @@ complex_subtype_from_string(PyTypeObject *type, PyObject *v)
NULL))
return NULL;
s = s_buffer;
len = (int)strlen(s);
len = strlen(s);
}
#endif
else if (PyObject_AsCharBuffer(v, &s, &len)) {

View File

@ -209,7 +209,7 @@ getset_set(PyGetSetDescrObject *descr, PyObject *obj, PyObject *value)
static PyObject *
methoddescr_call(PyMethodDescrObject *descr, PyObject *args, PyObject *kwds)
{
int argc;
Py_ssize_t argc;
PyObject *self, *func, *result;
/* Make sure that the first argument is acceptable as 'self' */
@ -267,7 +267,7 @@ classmethoddescr_call(PyMethodDescrObject *descr, PyObject *args,
static PyObject *
wrapperdescr_call(PyWrapperDescrObject *descr, PyObject *args, PyObject *kwds)
{
int argc;
Py_ssize_t argc;
PyObject *self, *func, *result;
/* Make sure that the first argument is acceptable as 'self' */
@ -669,7 +669,7 @@ typedef struct {
PyObject *dict;
} proxyobject;
static int
static Py_ssize_t
proxy_len(proxyobject *pp)
{
return PyObject_Size(pp->dict);
@ -682,7 +682,7 @@ proxy_getitem(proxyobject *pp, PyObject *key)
}
static PyMappingMethods proxy_as_mapping = {
(inquiry)proxy_len, /* mp_length */
(lenfunc)proxy_len, /* mp_length */
(binaryfunc)proxy_getitem, /* mp_subscript */
0, /* mp_ass_subscript */
};

View File

@ -217,8 +217,8 @@ reported by this function, and outstanding exceptions are maintained.
static dictentry *
lookdict(dictobject *mp, PyObject *key, register long hash)
{
register int i;
register unsigned int perturb;
register Py_ssize_t i;
register size_t perturb;
register dictentry *freeslot;
register unsigned int mask = mp->ma_mask;
dictentry *ep0 = mp->ma_table;
@ -328,8 +328,8 @@ Done:
static dictentry *
lookdict_string(dictobject *mp, PyObject *key, register long hash)
{
register int i;
register unsigned int perturb;
register Py_ssize_t i;
register size_t perturb;
register dictentry *freeslot;
register unsigned int mask = mp->ma_mask;
dictentry *ep0 = mp->ma_table;
@ -690,9 +690,10 @@ PyDict_Clear(PyObject *op)
* 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 Py_ssize_t i;
register int mask;
register dictentry *ep;
if (!PyDict_Check(op))
@ -786,7 +787,7 @@ dict_print(register dictobject *mp, register FILE *fp, register int flags)
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;
@ -862,7 +863,7 @@ Done:
return result;
}
static int
static Py_ssize_t
dict_length(dictobject *mp)
{
return mp->ma_used;
@ -898,7 +899,7 @@ dict_ass_sub(dictobject *mp, PyObject *v, PyObject *w)
}
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*/
};
@ -1123,7 +1124,7 @@ PyDict_MergeFromSeq2(PyObject *d, PyObject *seq2, int override)
for (i = 0; ; ++i) {
PyObject *key, *value;
int n;
Py_ssize_t n;
fast = NULL;
item = PyIter_Next(it);
@ -1147,7 +1148,7 @@ PyDict_MergeFromSeq2(PyObject *d, PyObject *seq2, int override)
if (n != 2) {
PyErr_Format(PyExc_ValueError,
"dictionary update sequence element #%d "
"has length %d; 2 is required",
"has length %ld; 2 is required",
i, n);
goto Fail;
}
@ -1300,7 +1301,7 @@ PyDict_Copy(PyObject *o)
return NULL;
}
int
Py_ssize_t
PyDict_Size(PyObject *mp)
{
if (mp == NULL || !PyDict_Check(mp)) {
@ -1708,7 +1709,8 @@ dict_popitem(dictobject *mp)
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;
@ -2057,7 +2059,7 @@ dictiter_dealloc(dictiterobject *di)
static PyObject *
dictiter_len(dictiterobject *di)
{
int len = 0;
long len = 0;
if (di->di_dict != NULL && di->di_used == di->di_dict->ma_used)
len = di->len;
return PyInt_FromLong(len);

View File

@ -241,7 +241,7 @@ PyDoc_STRVAR(reversed_doc,
static PyObject *
reversed_len(reversedobject *ro)
{
int position, seqsize;
Py_ssize_t position, seqsize;
if (ro->seq == NULL)
return PyInt_FromLong(0);

View File

@ -1,5 +1,6 @@
/* File object implementation */
#define PY_SSIZE_T_CLEAN
#include "Python.h"
#include "structmember.h"
@ -869,8 +870,8 @@ static PyObject *
file_readinto(PyFileObject *f, PyObject *args)
{
char *ptr;
int ntodo;
size_t ndone, nnow;
Py_ssize_t ntodo;
Py_ssize_t ndone, nnow;
if (f->f_fp == NULL)
return err_closed();
@ -988,7 +989,8 @@ getline_via_fgets(FILE *fp)
pvend = buf + total_v_size;
nfree = pvend - pvfree;
memset(pvfree, '\n', nfree);
p = fgets(pvfree, nfree, fp);
assert(nfree < INT_MAX); /* Should be atmost MAXBUFSIZE */
p = fgets(pvfree, (int)nfree, fp);
Py_END_ALLOW_THREADS
if (p == NULL) {
@ -1062,7 +1064,8 @@ getline_via_fgets(FILE *fp)
pvend = BUF(v) + total_v_size;
nfree = pvend - pvfree;
memset(pvfree, '\n', nfree);
p = fgets(pvfree, nfree, fp);
assert(nfree < INT_MAX);
p = fgets(pvfree, (int)nfree, fp);
Py_END_ALLOW_THREADS
if (p == NULL) {
@ -1271,7 +1274,7 @@ PyFile_GetLine(PyObject *f, int n)
if (n < 0 && result != NULL && PyString_Check(result)) {
char *s = PyString_AS_STRING(result);
int len = PyString_GET_SIZE(result);
Py_ssize_t len = PyString_GET_SIZE(result);
if (len == 0) {
Py_DECREF(result);
result = NULL;
@ -1292,7 +1295,7 @@ PyFile_GetLine(PyObject *f, int n)
#ifdef Py_USING_UNICODE
if (n < 0 && result != NULL && PyUnicode_Check(result)) {
Py_UNICODE *s = PyUnicode_AS_UNICODE(result);
int len = PyUnicode_GET_SIZE(result);
Py_ssize_t len = PyUnicode_GET_SIZE(result);
if (len == 0) {
Py_DECREF(result);
result = NULL;
@ -1468,7 +1471,7 @@ static PyObject *
file_write(PyFileObject *f, PyObject *args)
{
char *s;
int n, n2;
Py_ssize_t n, n2;
if (f->f_fp == NULL)
return err_closed();
if (!PyArg_ParseTuple(args, f->f_binary ? "s#" : "t#", &s, &n))
@ -1494,7 +1497,8 @@ file_writelines(PyFileObject *f, PyObject *seq)
PyObject *list, *line;
PyObject *it; /* iter(seq) */
PyObject *result;
int i, j, index, len, nwritten, islist;
int index, islist;
Py_ssize_t i, j, nwritten, len;
assert(seq != NULL);
if (f->f_fp == NULL)
@ -1552,7 +1556,6 @@ file_writelines(PyFileObject *f, PyObject *seq)
PyObject *v = PyList_GET_ITEM(list, i);
if (!PyString_Check(v)) {
const char *buffer;
int len;
if (((f->f_binary &&
PyObject_AsReadBuffer(v,
(const void**)&buffer,
@ -1789,7 +1792,7 @@ drop_readahead(PyFileObject *f)
static int
readahead(PyFileObject *f, int bufsize)
{
int chunksize;
Py_ssize_t chunksize;
if (f->f_buf != NULL) {
if( (f->f_bufend - f->f_bufptr) >= 1)
@ -1829,7 +1832,7 @@ readahead_get_line_skip(PyFileObject *f, int skip, int bufsize)
PyStringObject* s;
char *bufptr;
char *buf;
int len;
Py_ssize_t len;
if (f->f_buf == NULL)
if (readahead(f, bufsize) < 0)
@ -1855,8 +1858,9 @@ readahead_get_line_skip(PyFileObject *f, int skip, int bufsize)
bufptr = f->f_bufptr;
buf = f->f_buf;
f->f_buf = NULL; /* Force new readahead buffer */
assert(skip+len < INT_MAX);
s = readahead_get_line_skip(
f, skip+len, bufsize + (bufsize>>2) );
f, (int)(skip+len), bufsize + (bufsize>>2) );
if (s == NULL) {
PyMem_Free(buf);
return NULL;
@ -2061,7 +2065,7 @@ PyTypeObject PyFile_Type = {
int
PyFile_SoftSpace(PyObject *f, int newflag)
{
int oldflag = 0;
long oldflag = 0;
if (f == NULL) {
/* Do nothing */
}
@ -2077,6 +2081,7 @@ PyFile_SoftSpace(PyObject *f, int newflag)
else {
if (PyInt_Check(v))
oldflag = PyInt_AsLong(v);
assert(oldflag < INT_MAX);
Py_DECREF(v);
}
v = PyInt_FromLong((long)newflag);
@ -2088,7 +2093,7 @@ PyFile_SoftSpace(PyObject *f, int newflag)
Py_DECREF(v);
}
}
return oldflag;
return (int)oldflag;
}
/* Interfaces to write objects/strings to file-like objects */

View File

@ -87,7 +87,7 @@ PyFloat_FromString(PyObject *v, char **pend)
#ifdef Py_USING_UNICODE
char s_buffer[256]; /* for objects convertible to a char buffer */
#endif
int len;
Py_ssize_t len;
if (pend)
*pend = NULL;
@ -108,7 +108,7 @@ PyFloat_FromString(PyObject *v, char **pend)
NULL))
return NULL;
s = s_buffer;
len = (int)strlen(s);
len = strlen(s);
}
#endif
else if (PyObject_AsCharBuffer(v, &s, &len)) {

View File

@ -71,9 +71,9 @@ frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno)
int new_lasti = 0; /* The new value of f_lasti */
int new_iblock = 0; /* The new value of f_iblock */
char *code = NULL; /* The bytecode for the frame... */
int code_len = 0; /* ...and its length */
Py_ssize_t code_len = 0; /* ...and its length */
char *lnotab = NULL; /* Iterating over co_lnotab */
int lnotab_len = 0; /* (ditto) */
Py_ssize_t lnotab_len = 0; /* (ditto) */
int offset = 0; /* (ditto) */
int line = 0; /* (ditto) */
int addr = 0; /* (ditto) */
@ -540,7 +540,7 @@ PyFrame_New(PyThreadState *tstate, PyCodeObject *code, PyObject *globals,
PyFrameObject *back = tstate->frame;
PyFrameObject *f;
PyObject *builtins;
int extras, ncells, nfrees, i;
Py_ssize_t extras, ncells, nfrees, i;
#ifdef Py_DEBUG
if (code == NULL || globals == NULL || !PyDict_Check(globals) ||
@ -678,10 +678,10 @@ PyFrame_BlockPop(PyFrameObject *f)
/* Convert between "fast" version of locals and dictionary version */
static void
map_to_dict(PyObject *map, int nmap, PyObject *dict, PyObject **values,
int deref)
map_to_dict(PyObject *map, Py_ssize_t nmap, PyObject *dict, PyObject **values,
Py_ssize_t deref)
{
int j;
Py_ssize_t j;
for (j = nmap; --j >= 0; ) {
PyObject *key = PyTuple_GET_ITEM(map, j);
PyObject *value = values[j];
@ -699,10 +699,10 @@ map_to_dict(PyObject *map, int nmap, PyObject *dict, PyObject **values,
}
static void
dict_to_map(PyObject *map, int nmap, PyObject *dict, PyObject **values,
int deref, int clear)
dict_to_map(PyObject *map, Py_ssize_t nmap, PyObject *dict, PyObject **values,
Py_ssize_t deref, int clear)
{
int j;
Py_ssize_t j;
for (j = nmap; --j >= 0; ) {
PyObject *key = PyTuple_GET_ITEM(map, j);
PyObject *value = PyObject_GetItem(dict, key);
@ -733,7 +733,7 @@ PyFrame_FastToLocals(PyFrameObject *f)
PyObject *locals, *map;
PyObject **fast;
PyObject *error_type, *error_value, *error_traceback;
int j;
Py_ssize_t j;
if (f == NULL)
return;
locals = f->f_locals;
@ -776,7 +776,7 @@ PyFrame_LocalsToFast(PyFrameObject *f, int clear)
PyObject *locals, *map;
PyObject **fast;
PyObject *error_type, *error_value, *error_traceback;
int j;
Py_ssize_t j;
if (f == NULL)
return;
locals = f->f_locals;

View File

@ -232,7 +232,7 @@ static int
func_set_code(PyFunctionObject *op, PyObject *value)
{
PyObject *tmp;
int nfree, nclosure;
Py_ssize_t nfree, nclosure;
if (restricted())
return -1;
@ -248,8 +248,8 @@ func_set_code(PyFunctionObject *op, PyObject *value)
PyTuple_GET_SIZE(op->func_closure));
if (nclosure != nfree) {
PyErr_Format(PyExc_ValueError,
"%s() requires a code object with %d free vars,"
" not %d",
"%s() requires a code object with %ld free vars,"
" not %ld",
PyString_AsString(op->func_name),
nclosure, nfree);
return -1;
@ -363,7 +363,7 @@ func_new(PyTypeObject* type, PyObject* args, PyObject* kw)
PyObject *defaults = Py_None;
PyObject *closure = Py_None;
PyFunctionObject *newfunc;
int nfree, nclosure;
Py_ssize_t nfree, nclosure;
static const char *kwlist[] = {"code", "globals", "name",
"argdefs", "closure", 0};
@ -401,11 +401,11 @@ func_new(PyTypeObject* type, PyObject* args, PyObject* kw)
nclosure = closure == Py_None ? 0 : PyTuple_GET_SIZE(closure);
if (nfree != nclosure)
return PyErr_Format(PyExc_ValueError,
"%s requires closure of length %d, not %d",
"%s requires closure of length %ld, not %ld",
PyString_AS_STRING(code->co_name),
nfree, nclosure);
if (nclosure) {
int i;
Py_ssize_t i;
for (i = 0; i < nclosure; i++) {
PyObject *o = PyTuple_GET_ITEM(closure, i);
if (!PyCell_Check(o)) {
@ -516,7 +516,7 @@ function_call(PyObject *func, PyObject *arg, PyObject *kw)
PyObject *result;
PyObject *argdefs;
PyObject **d, **k;
int nk, nd;
Py_ssize_t nk, nd;
argdefs = PyFunction_GET_DEFAULTS(func);
if (argdefs != NULL && PyTuple_Check(argdefs)) {
@ -529,7 +529,7 @@ function_call(PyObject *func, PyObject *arg, PyObject *kw)
}
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) {

View File

@ -108,6 +108,22 @@ PyInt_FromLong(long ival)
return (PyObject *) v;
}
PyObject *
PyInt_FromSize_t(size_t ival)
{
if (ival <= LONG_MAX)
return PyInt_FromLong((long)ival);
return _PyLong_FromSize_t(ival);
}
PyObject *
PyInt_FromSsize_t(Py_ssize_t ival)
{
if (ival >= LONG_MIN && ival <= LONG_MAX)
return PyInt_FromLong((long)ival);
return _PyLong_FromSsize_t(ival);
}
static void
int_dealloc(PyIntObject *v)
{
@ -169,6 +185,59 @@ PyInt_AsLong(register PyObject *op)
return val;
}
Py_ssize_t
PyInt_AsSsize_t(register PyObject *op)
{
PyNumberMethods *nb;
PyIntObject *io;
Py_ssize_t val;
if (op && !PyInt_CheckExact(op) && PyLong_Check(op))
return _PyLong_AsSsize_t(op);
#if SIZEOF_SIZE_T==SIZEOF_LONG
return PyInt_AsLong(op);
#else
if (op && PyInt_Check(op))
return PyInt_AS_LONG((PyIntObject*) op);
if (op == NULL || (nb = op->ob_type->tp_as_number) == NULL ||
(nb->nb_int == NULL && nb->nb_long == 0)) {
PyErr_SetString(PyExc_TypeError, "an integer is required");
return -1;
}
if (nb->nb_long != 0) {
io = (PyIntObject*) (*nb->nb_long) (op);
} else {
io = (PyIntObject*) (*nb->nb_int) (op);
}
if (io == NULL)
return -1;
if (!PyInt_Check(io)) {
if (PyLong_Check(io)) {
/* got a long? => retry int conversion */
val = _PyLong_AsSsize_t((PyObject *)io);
Py_DECREF(io);
if ((val == -1) && PyErr_Occurred())
return -1;
return val;
}
else
{
Py_DECREF(io);
PyErr_SetString(PyExc_TypeError,
"nb_int should return int object");
return -1;
}
}
val = PyInt_AS_LONG(io);
Py_DECREF(io);
return val;
#endif
}
unsigned long
PyInt_AsUnsignedLongMask(register PyObject *op)
{
@ -302,7 +371,7 @@ PyInt_FromString(char *s, char **pend, int base)
#ifdef Py_USING_UNICODE
PyObject *
PyInt_FromUnicode(Py_UNICODE *s, int length, int base)
PyInt_FromUnicode(Py_UNICODE *s, Py_ssize_t length, int base)
{
PyObject *result;
char *buffer = PyMem_MALLOC(length+1);

View File

@ -74,7 +74,7 @@ iter_iternext(PyObject *iterator)
static PyObject *
iter_len(seqiterobject *it)
{
int seqsize, len;
Py_ssize_t seqsize, len;
if (it->it_seq) {
seqsize = PySequence_Size(it->it_seq);

View File

@ -22,11 +22,11 @@
* than ob_size on entry.
*/
static int
list_resize(PyListObject *self, int newsize)
list_resize(PyListObject *self, Py_ssize_t newsize)
{
PyObject **items;
size_t new_allocated;
int allocated = self->allocated;
Py_ssize_t allocated = self->allocated;
/* Bypass realloc() when a previous overallocation is large enough
to accommodate the newsize. If the newsize falls lower than half
@ -82,7 +82,7 @@ PyList_Fini(void)
}
PyObject *
PyList_New(int size)
PyList_New(Py_ssize_t size)
{
PyListObject *op;
size_t nbytes;
@ -118,7 +118,7 @@ PyList_New(int size)
return (PyObject *) op;
}
int
Py_ssize_t
PyList_Size(PyObject *op)
{
if (!PyList_Check(op)) {
@ -132,7 +132,7 @@ PyList_Size(PyObject *op)
static PyObject *indexerr = NULL;
PyObject *
PyList_GetItem(PyObject *op, int i)
PyList_GetItem(PyObject *op, Py_ssize_t i)
{
if (!PyList_Check(op)) {
PyErr_BadInternalCall();
@ -149,7 +149,7 @@ PyList_GetItem(PyObject *op, int i)
}
int
PyList_SetItem(register PyObject *op, register int i,
PyList_SetItem(register PyObject *op, register Py_ssize_t i,
register PyObject *newitem)
{
register PyObject *olditem;
@ -173,9 +173,9 @@ PyList_SetItem(register PyObject *op, register int i,
}
static int
ins1(PyListObject *self, int where, PyObject *v)
ins1(PyListObject *self, Py_ssize_t where, PyObject *v)
{
int i, n = self->ob_size;
Py_ssize_t i, n = self->ob_size;
PyObject **items;
if (v == NULL) {
PyErr_BadInternalCall();
@ -206,7 +206,7 @@ ins1(PyListObject *self, int where, PyObject *v)
}
int
PyList_Insert(PyObject *op, int where, PyObject *newitem)
PyList_Insert(PyObject *op, Py_ssize_t where, PyObject *newitem)
{
if (!PyList_Check(op)) {
PyErr_BadInternalCall();
@ -218,7 +218,7 @@ PyList_Insert(PyObject *op, int where, PyObject *newitem)
static int
app1(PyListObject *self, PyObject *v)
{
int n = PyList_GET_SIZE(self);
Py_ssize_t n = PyList_GET_SIZE(self);
assert (v != NULL);
if (n == INT_MAX) {
@ -249,7 +249,7 @@ PyList_Append(PyObject *op, PyObject *newitem)
static void
list_dealloc(PyListObject *op)
{
int i;
Py_ssize_t i;
PyObject_GC_UnTrack(op);
Py_TRASHCAN_SAFE_BEGIN(op)
if (op->ob_item != NULL) {
@ -273,12 +273,13 @@ list_dealloc(PyListObject *op)
static int
list_print(PyListObject *op, FILE *fp, int flags)
{
int i;
int rc;
Py_ssize_t i;
i = Py_ReprEnter((PyObject*)op);
if (i != 0) {
if (i < 0)
return i;
rc = Py_ReprEnter((PyObject*)op);
if (rc != 0) {
if (rc < 0)
return rc;
fprintf(fp, "[...]");
return 0;
}
@ -299,7 +300,7 @@ list_print(PyListObject *op, FILE *fp, int flags)
static PyObject *
list_repr(PyListObject *v)
{
int i;
Py_ssize_t i;
PyObject *s, *temp;
PyObject *pieces = NULL, *result = NULL;
@ -363,7 +364,7 @@ Done:
return result;
}
static int
static Py_ssize_t
list_length(PyListObject *a)
{
return a->ob_size;
@ -372,7 +373,8 @@ list_length(PyListObject *a)
static int
list_contains(PyListObject *a, PyObject *el)
{
int i, cmp;
Py_ssize_t i;
int cmp;
for (i = 0, cmp = 0 ; cmp == 0 && i < a->ob_size; ++i)
cmp = PyObject_RichCompareBool(el, PyList_GET_ITEM(a, i),
@ -381,7 +383,7 @@ list_contains(PyListObject *a, PyObject *el)
}
static PyObject *
list_item(PyListObject *a, int i)
list_item(PyListObject *a, Py_ssize_t i)
{
if (i < 0 || i >= a->ob_size) {
if (indexerr == NULL)
@ -395,11 +397,11 @@ list_item(PyListObject *a, int i)
}
static PyObject *
list_slice(PyListObject *a, int ilow, int ihigh)
list_slice(PyListObject *a, Py_ssize_t ilow, Py_ssize_t ihigh)
{
PyListObject *np;
PyObject **src, **dest;
int i, len;
Py_ssize_t i, len;
if (ilow < 0)
ilow = 0;
else if (ilow > a->ob_size)
@ -424,7 +426,7 @@ list_slice(PyListObject *a, int ilow, int ihigh)
}
PyObject *
PyList_GetSlice(PyObject *a, int ilow, int ihigh)
PyList_GetSlice(PyObject *a, Py_ssize_t ilow, Py_ssize_t ihigh)
{
if (!PyList_Check(a)) {
PyErr_BadInternalCall();
@ -436,8 +438,8 @@ PyList_GetSlice(PyObject *a, int ilow, int ihigh)
static PyObject *
list_concat(PyListObject *a, PyObject *bb)
{
int size;
int i;
Py_ssize_t size;
Py_ssize_t i;
PyObject **src, **dest;
PyListObject *np;
if (!PyList_Check(bb)) {
@ -473,10 +475,10 @@ list_concat(PyListObject *a, PyObject *bb)
}
static PyObject *
list_repeat(PyListObject *a, int n)
list_repeat(PyListObject *a, Py_ssize_t n)
{
int i, j;
int size;
Py_ssize_t i, j;
Py_ssize_t size;
PyListObject *np;
PyObject **p, **items;
PyObject *elem;
@ -515,7 +517,7 @@ list_repeat(PyListObject *a, int n)
static int
list_clear(PyListObject *a)
{
int i;
Py_ssize_t i;
PyObject **item = a->ob_item;
if (item != NULL) {
/* Because XDECREF can recursively invoke operations on
@ -542,7 +544,7 @@ list_clear(PyListObject *a)
* guaranteed the call cannot fail.
*/
static int
list_ass_slice(PyListObject *a, int ilow, int ihigh, PyObject *v)
list_ass_slice(PyListObject *a, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *v)
{
/* Because [X]DECREF can recursively invoke list operations on
this list, we must postpone all [X]DECREF activity until
@ -555,10 +557,10 @@ list_ass_slice(PyListObject *a, int ilow, int ihigh, PyObject *v)
PyObject **item;
PyObject **vitem = NULL;
PyObject *v_as_SF = NULL; /* PySequence_Fast(v) */
int n; /* # of elements in replacement list */
int norig; /* # of elements in list getting replaced */
int d; /* Change in size */
int k;
Py_ssize_t n; /* # of elements in replacement list */
Py_ssize_t norig; /* # of elements in list getting replaced */
Py_ssize_t d; /* Change in size */
Py_ssize_t k;
size_t s;
int result = -1; /* guilty until proved innocent */
#define b ((PyListObject *)v)
@ -640,7 +642,7 @@ list_ass_slice(PyListObject *a, int ilow, int ihigh, PyObject *v)
}
int
PyList_SetSlice(PyObject *a, int ilow, int ihigh, PyObject *v)
PyList_SetSlice(PyObject *a, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *v)
{
if (!PyList_Check(a)) {
PyErr_BadInternalCall();
@ -650,10 +652,10 @@ PyList_SetSlice(PyObject *a, int ilow, int ihigh, PyObject *v)
}
static PyObject *
list_inplace_repeat(PyListObject *self, int n)
list_inplace_repeat(PyListObject *self, Py_ssize_t n)
{
PyObject **items;
int size, i, j, p;
Py_ssize_t size, i, j, p;
size = PyList_GET_SIZE(self);
@ -685,7 +687,7 @@ list_inplace_repeat(PyListObject *self, int n)
}
static int
list_ass_item(PyListObject *a, int i, PyObject *v)
list_ass_item(PyListObject *a, Py_ssize_t i, PyObject *v)
{
PyObject *old_value;
if (i < 0 || i >= a->ob_size) {
@ -705,9 +707,9 @@ list_ass_item(PyListObject *a, int i, PyObject *v)
static PyObject *
listinsert(PyListObject *self, PyObject *args)
{
int i;
Py_ssize_t i;
PyObject *v;
if (!PyArg_ParseTuple(args, "iO:insert", &i, &v))
if (!PyArg_ParseTuple(args, "nO:insert", &i, &v))
return NULL;
if (ins1(self, i, v) == 0)
Py_RETURN_NONE;
@ -726,10 +728,10 @@ static PyObject *
listextend(PyListObject *self, PyObject *b)
{
PyObject *it; /* iter(v) */
int m; /* size of self */
int n; /* guess for size of b */
int mn; /* m + n */
int i;
Py_ssize_t m; /* size of self */
Py_ssize_t n; /* guess for size of b */
Py_ssize_t mn; /* m + n */
Py_ssize_t i;
PyObject *(*iternext)(PyObject *);
/* Special cases:
@ -858,7 +860,7 @@ list_inplace_concat(PyListObject *self, PyObject *other)
static PyObject *
listpop(PyListObject *self, PyObject *args)
{
int i = -1;
Py_ssize_t i = -1;
PyObject *v, *arg = NULL;
int status;
@ -866,8 +868,8 @@ listpop(PyListObject *self, PyObject *args)
return NULL;
if (arg != NULL) {
if (PyInt_Check(arg))
i = (int)(PyInt_AS_LONG((PyIntObject*) arg));
else if (!PyArg_ParseTuple(args, "|i:pop", &i))
i = PyInt_AS_LONG((PyIntObject*) arg);
else if (!PyArg_ParseTuple(args, "|n:pop", &i))
return NULL;
}
if (self->ob_size == 0) {
@ -929,7 +931,7 @@ islt(PyObject *x, PyObject *y, PyObject *compare)
{
PyObject *res;
PyObject *args;
int i;
Py_ssize_t i;
assert(compare != NULL);
/* Call the user's comparison function and translate the 3-way
@ -988,7 +990,7 @@ static int
binarysort(PyObject **lo, PyObject **hi, PyObject **start, PyObject *compare)
/* compare -- comparison function object, or NULL for default */
{
register int k;
register Py_ssize_t k;
register PyObject **l, **p, **r;
register PyObject *pivot;
@ -1050,11 +1052,11 @@ elements to get out of order).
Returns -1 in case of error.
*/
static int
static Py_ssize_t
count_run(PyObject **lo, PyObject **hi, PyObject *compare, int *descending)
{
int k;
int n;
Py_ssize_t k;
Py_ssize_t n;
assert(lo < hi);
*descending = 0;
@ -1105,12 +1107,12 @@ key, and the last n-k should follow key.
Returns -1 on error. See listsort.txt for info on the method.
*/
static int
gallop_left(PyObject *key, PyObject **a, int n, int hint, PyObject *compare)
static Py_ssize_t
gallop_left(PyObject *key, PyObject **a, Py_ssize_t n, Py_ssize_t hint, PyObject *compare)
{
int ofs;
int lastofs;
int k;
Py_ssize_t ofs;
Py_ssize_t lastofs;
Py_ssize_t k;
assert(key && a && n > 0 && hint >= 0 && hint < n);
@ -1121,7 +1123,7 @@ gallop_left(PyObject *key, PyObject **a, int n, int hint, PyObject *compare)
/* a[hint] < key -- gallop right, until
* a[hint + lastofs] < key <= a[hint + ofs]
*/
const int maxofs = n - hint; /* &a[n-1] is highest */
const Py_ssize_t maxofs = n - hint; /* &a[n-1] is highest */
while (ofs < maxofs) {
IFLT(a[ofs], key) {
lastofs = ofs;
@ -1142,7 +1144,7 @@ gallop_left(PyObject *key, PyObject **a, int n, int hint, PyObject *compare)
/* key <= a[hint] -- gallop left, until
* a[hint - ofs] < key <= a[hint - lastofs]
*/
const int maxofs = hint + 1; /* &a[0] is lowest */
const Py_ssize_t maxofs = hint + 1; /* &a[0] is lowest */
while (ofs < maxofs) {
IFLT(*(a-ofs), key)
break;
@ -1168,7 +1170,7 @@ gallop_left(PyObject *key, PyObject **a, int n, int hint, PyObject *compare)
*/
++lastofs;
while (lastofs < ofs) {
int m = lastofs + ((ofs - lastofs) >> 1);
Py_ssize_t m = lastofs + ((ofs - lastofs) >> 1);
IFLT(a[m], key)
lastofs = m+1; /* a[m] < key */
@ -1196,12 +1198,12 @@ The code duplication is massive, but this is enough different given that
we're sticking to "<" comparisons that it's much harder to follow if
written as one routine with yet another "left or right?" flag.
*/
static int
gallop_right(PyObject *key, PyObject **a, int n, int hint, PyObject *compare)
static Py_ssize_t
gallop_right(PyObject *key, PyObject **a, Py_ssize_t n, Py_ssize_t hint, PyObject *compare)
{
int ofs;
int lastofs;
int k;
Py_ssize_t ofs;
Py_ssize_t lastofs;
Py_ssize_t k;
assert(key && a && n > 0 && hint >= 0 && hint < n);
@ -1212,7 +1214,7 @@ gallop_right(PyObject *key, PyObject **a, int n, int hint, PyObject *compare)
/* key < a[hint] -- gallop left, until
* a[hint - ofs] <= key < a[hint - lastofs]
*/
const int maxofs = hint + 1; /* &a[0] is lowest */
const Py_ssize_t maxofs = hint + 1; /* &a[0] is lowest */
while (ofs < maxofs) {
IFLT(key, *(a-ofs)) {
lastofs = ofs;
@ -1234,7 +1236,7 @@ gallop_right(PyObject *key, PyObject **a, int n, int hint, PyObject *compare)
/* a[hint] <= key -- gallop right, until
* a[hint + lastofs] <= key < a[hint + ofs]
*/
const int maxofs = n - hint; /* &a[n-1] is highest */
const Py_ssize_t maxofs = n - hint; /* &a[n-1] is highest */
while (ofs < maxofs) {
IFLT(key, a[ofs])
break;
@ -1259,7 +1261,7 @@ gallop_right(PyObject *key, PyObject **a, int n, int hint, PyObject *compare)
*/
++lastofs;
while (lastofs < ofs) {
int m = lastofs + ((ofs - lastofs) >> 1);
Py_ssize_t m = lastofs + ((ofs - lastofs) >> 1);
IFLT(key, a[m])
ofs = m; /* key < a[m] */
@ -1294,7 +1296,7 @@ fail:
*/
struct s_slice {
PyObject **base;
int len;
Py_ssize_t len;
};
typedef struct s_MergeState {
@ -1305,13 +1307,13 @@ typedef struct s_MergeState {
* to MIN_GALLOP. merge_lo and merge_hi tend to nudge it higher for
* random data, and lower for highly structured data.
*/
int min_gallop;
Py_ssize_t min_gallop;
/* 'a' is temp storage to help with merges. It contains room for
* alloced entries.
*/
PyObject **a; /* may point to temparray below */
int alloced;
Py_ssize_t alloced;
/* A stack of n pending runs yet to be merged. Run #i starts at
* address base[i] and extends for len[i] elements. It's always
@ -1359,7 +1361,7 @@ merge_freemem(MergeState *ms)
* Returns 0 on success and -1 if the memory can't be gotten.
*/
static int
merge_getmem(MergeState *ms, int need)
merge_getmem(MergeState *ms, Py_ssize_t need)
{
assert(ms != NULL);
if (need <= ms->alloced)
@ -1386,14 +1388,15 @@ merge_getmem(MergeState *ms, int need)
* merge, and should have na <= nb. See listsort.txt for more info.
* Return 0 if successful, -1 if error.
*/
static int
merge_lo(MergeState *ms, PyObject **pa, int na, PyObject **pb, int nb)
static Py_ssize_t
merge_lo(MergeState *ms, PyObject **pa, Py_ssize_t na,
PyObject **pb, Py_ssize_t nb)
{
int k;
Py_ssize_t k;
PyObject *compare;
PyObject **dest;
int result = -1; /* guilty until proved innocent */
int min_gallop = ms->min_gallop;
Py_ssize_t min_gallop = ms->min_gallop;
assert(ms && pa && pb && na > 0 && nb > 0 && pa + na == pb);
if (MERGE_GETMEM(ms, na) < 0)
@ -1411,8 +1414,8 @@ merge_lo(MergeState *ms, PyObject **pa, int na, PyObject **pb, int nb)
compare = ms->compare;
for (;;) {
int acount = 0; /* # of times A won in a row */
int bcount = 0; /* # of times B won in a row */
Py_ssize_t acount = 0; /* # of times A won in a row */
Py_ssize_t bcount = 0; /* # of times B won in a row */
/* Do the straightforward thing until (if ever) one run
* appears to win consistently.
@ -1517,16 +1520,16 @@ CopyB:
* merge, and should have na >= nb. See listsort.txt for more info.
* Return 0 if successful, -1 if error.
*/
static int
merge_hi(MergeState *ms, PyObject **pa, int na, PyObject **pb, int nb)
static Py_ssize_t
merge_hi(MergeState *ms, PyObject **pa, Py_ssize_t na, PyObject **pb, Py_ssize_t nb)
{
int k;
Py_ssize_t k;
PyObject *compare;
PyObject **dest;
int result = -1; /* guilty until proved innocent */
PyObject **basea;
PyObject **baseb;
int min_gallop = ms->min_gallop;
Py_ssize_t min_gallop = ms->min_gallop;
assert(ms && pa && pb && na > 0 && nb > 0 && pa + na == pb);
if (MERGE_GETMEM(ms, nb) < 0)
@ -1547,8 +1550,8 @@ merge_hi(MergeState *ms, PyObject **pa, int na, PyObject **pb, int nb)
compare = ms->compare;
for (;;) {
int acount = 0; /* # of times A won in a row */
int bcount = 0; /* # of times B won in a row */
Py_ssize_t acount = 0; /* # of times A won in a row */
Py_ssize_t bcount = 0; /* # of times B won in a row */
/* Do the straightforward thing until (if ever) one run
* appears to win consistently.
@ -1654,12 +1657,12 @@ CopyA:
/* Merge the two runs at stack indices i and i+1.
* Returns 0 on success, -1 on error.
*/
static int
merge_at(MergeState *ms, int i)
static Py_ssize_t
merge_at(MergeState *ms, Py_ssize_t i)
{
PyObject **pa, **pb;
int na, nb;
int k;
Py_ssize_t na, nb;
Py_ssize_t k;
PyObject *compare;
assert(ms != NULL);
@ -1728,7 +1731,7 @@ merge_collapse(MergeState *ms)
assert(ms);
while (ms->n > 1) {
int n = ms->n - 2;
Py_ssize_t n = ms->n - 2;
if (n > 0 && p[n-1].len <= p[n].len + p[n+1].len) {
if (p[n-1].len < p[n+1].len)
--n;
@ -1757,7 +1760,7 @@ merge_force_collapse(MergeState *ms)
assert(ms);
while (ms->n > 1) {
int n = ms->n - 2;
Py_ssize_t n = ms->n - 2;
if (n > 0 && p[n-1].len < p[n+1].len)
--n;
if (merge_at(ms, n) < 0)
@ -1776,10 +1779,10 @@ merge_force_collapse(MergeState *ms)
*
* See listsort.txt for more info.
*/
static int
merge_compute_minrun(int n)
static Py_ssize_t
merge_compute_minrun(Py_ssize_t n)
{
int r = 0; /* becomes 1 if any 1 bits are shifted off */
Py_ssize_t r = 0; /* becomes 1 if any 1 bits are shifted off */
assert(n >= 0);
while (n >= 64) {
@ -1972,16 +1975,16 @@ listsort(PyListObject *self, PyObject *args, PyObject *kwds)
{
MergeState ms;
PyObject **lo, **hi;
int nremaining;
int minrun;
int saved_ob_size, saved_allocated;
Py_ssize_t nremaining;
Py_ssize_t minrun;
Py_ssize_t saved_ob_size, saved_allocated;
PyObject **saved_ob_item;
PyObject **final_ob_item;
PyObject *compare = NULL;
PyObject *result = NULL; /* guilty until proved innocent */
int reverse = 0;
PyObject *keyfunc = NULL;
int i;
Py_ssize_t i;
PyObject *key, *value, *kvpair;
static const char *kwlist[] = {"cmp", "key", "reverse", 0};
@ -2055,7 +2058,7 @@ listsort(PyListObject *self, PyObject *args, PyObject *kwds)
minrun = merge_compute_minrun(nremaining);
do {
int descending;
int n;
Py_ssize_t n;
/* Identify next run. */
n = count_run(lo, hi, compare, &descending);
@ -2065,7 +2068,7 @@ listsort(PyListObject *self, PyObject *args, PyObject *kwds)
reverse_slice(lo, lo + n);
/* If short, extend to min(minrun, nremaining). */
if (n < minrun) {
const int force = nremaining <= minrun ?
const Py_ssize_t force = nremaining <= minrun ?
nremaining : minrun;
if (binarysort(lo, lo + force, lo + n, compare) < 0)
goto fail;
@ -2177,7 +2180,7 @@ PyList_AsTuple(PyObject *v)
{
PyObject *w;
PyObject **p;
int n;
Py_ssize_t n;
if (v == NULL || !PyList_Check(v)) {
PyErr_BadInternalCall();
return NULL;
@ -2200,7 +2203,7 @@ PyList_AsTuple(PyObject *v)
static PyObject *
listindex(PyListObject *self, PyObject *args)
{
int i, start=0, stop=self->ob_size;
Py_ssize_t i, start=0, stop=self->ob_size;
PyObject *v;
if (!PyArg_ParseTuple(args, "O|O&O&:index", &v,
@ -2220,7 +2223,7 @@ listindex(PyListObject *self, PyObject *args)
for (i = start; i < stop && i < self->ob_size; i++) {
int cmp = PyObject_RichCompareBool(self->ob_item[i], v, Py_EQ);
if (cmp > 0)
return PyInt_FromLong((long)i);
return PyInt_FromSsize_t(i);
else if (cmp < 0)
return NULL;
}
@ -2231,8 +2234,8 @@ listindex(PyListObject *self, PyObject *args)
static PyObject *
listcount(PyListObject *self, PyObject *v)
{
int count = 0;
int i;
Py_ssize_t count = 0;
Py_ssize_t i;
for (i = 0; i < self->ob_size; i++) {
int cmp = PyObject_RichCompareBool(self->ob_item[i], v, Py_EQ);
@ -2241,13 +2244,13 @@ listcount(PyListObject *self, PyObject *v)
else if (cmp < 0)
return NULL;
}
return PyInt_FromLong((long)count);
return PyInt_FromSsize_t(count);
}
static PyObject *
listremove(PyListObject *self, PyObject *v)
{
int i;
Py_ssize_t i;
for (i = 0; i < self->ob_size; i++) {
int cmp = PyObject_RichCompareBool(self->ob_item[i], v, Py_EQ);
@ -2267,13 +2270,13 @@ listremove(PyListObject *self, PyObject *v)
static int
list_traverse(PyListObject *o, visitproc visit, void *arg)
{
int i, err;
Py_ssize_t i;
PyObject *x;
for (i = o->ob_size; --i >= 0; ) {
x = o->ob_item[i];
if (x != NULL) {
err = visit(x, arg);
int err = visit(x, arg);
if (err)
return err;
}
@ -2285,7 +2288,7 @@ static PyObject *
list_richcompare(PyObject *v, PyObject *w, int op)
{
PyListObject *vl, *wl;
int i;
Py_ssize_t i;
if (!PyList_Check(v) || !PyList_Check(w)) {
Py_INCREF(Py_NotImplemented);
@ -2318,8 +2321,8 @@ list_richcompare(PyObject *v, PyObject *w, int op)
if (i >= vl->ob_size || i >= wl->ob_size) {
/* No more items to compare -- compare sizes */
int vs = vl->ob_size;
int ws = wl->ob_size;
Py_ssize_t vs = vl->ob_size;
Py_ssize_t ws = wl->ob_size;
int cmp;
PyObject *res;
switch (op) {
@ -2433,16 +2436,16 @@ static PyMethodDef list_methods[] = {
};
static PySequenceMethods list_as_sequence = {
(inquiry)list_length, /* sq_length */
(lenfunc)list_length, /* sq_length */
(binaryfunc)list_concat, /* sq_concat */
(intargfunc)list_repeat, /* sq_repeat */
(intargfunc)list_item, /* sq_item */
(intintargfunc)list_slice, /* sq_slice */
(intobjargproc)list_ass_item, /* sq_ass_item */
(intintobjargproc)list_ass_slice, /* sq_ass_slice */
(ssizeargfunc)list_repeat, /* sq_repeat */
(ssizeargfunc)list_item, /* sq_item */
(ssizessizeargfunc)list_slice, /* sq_slice */
(ssizeobjargproc)list_ass_item, /* sq_ass_item */
(ssizessizeobjargproc)list_ass_slice, /* sq_ass_slice */
(objobjproc)list_contains, /* sq_contains */
(binaryfunc)list_inplace_concat, /* sq_inplace_concat */
(intargfunc)list_inplace_repeat, /* sq_inplace_repeat */
(ssizeargfunc)list_inplace_repeat, /* sq_inplace_repeat */
};
PyDoc_STRVAR(list_doc,
@ -2452,14 +2455,8 @@ PyDoc_STRVAR(list_doc,
static PyObject *
list_subscript(PyListObject* self, PyObject* item)
{
if (PyInt_Check(item)) {
long i = PyInt_AS_LONG(item);
if (i < 0)
i += PyList_GET_SIZE(self);
return list_item(self, i);
}
else if (PyLong_Check(item)) {
long i = PyLong_AsLong(item);
if (PyInt_Check(item) || PyLong_Check(item)) {
Py_ssize_t i = PyInt_AsSsize_t(item);
if (i == -1 && PyErr_Occurred())
return NULL;
if (i < 0)
@ -2467,7 +2464,7 @@ list_subscript(PyListObject* self, PyObject* item)
return list_item(self, i);
}
else if (PySlice_Check(item)) {
int start, stop, step, slicelength, cur, i;
Py_ssize_t start, stop, step, slicelength, cur, i;
PyObject* result;
PyObject* it;
PyObject **src, **dest;
@ -2521,7 +2518,7 @@ list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value)
return list_ass_item(self, i, value);
}
else if (PySlice_Check(item)) {
int start, stop, step, slicelength;
Py_ssize_t start, stop, step, slicelength;
if (PySlice_GetIndicesEx((PySliceObject*)item, self->ob_size,
&start, &stop, &step, &slicelength) < 0) {
@ -2535,7 +2532,7 @@ list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value)
if (value == NULL) {
/* delete slice */
PyObject **garbage;
int cur, i;
Py_ssize_t cur, i;
if (slicelength <= 0)
return 0;
@ -2554,7 +2551,7 @@ list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value)
for (cur = start, i = 0;
cur < stop;
cur += step, i++) {
int lim = step;
Py_ssize_t lim = step;
garbage[i] = PyList_GET_ITEM(self, cur);
@ -2586,7 +2583,7 @@ list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value)
else {
/* assign slice */
PyObject **garbage, *ins, *seq, **seqitems, **selfitems;
int cur, i;
Py_ssize_t cur, i;
/* protect against a[::-1] = a */
if (self == (PyListObject*)value) {
@ -2601,8 +2598,9 @@ list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value)
}
if (PySequence_Fast_GET_SIZE(seq) != slicelength) {
/* XXX can we use %zd here? */
PyErr_Format(PyExc_ValueError,
"attempt to assign sequence of size %d to extended slice of size %d",
"attempt to assign sequence of size %ld to extended slice of size %ld",
PySequence_Fast_GET_SIZE(seq),
slicelength);
Py_DECREF(seq);
@ -2645,7 +2643,7 @@ list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value)
}
static PyMappingMethods list_as_mapping = {
(inquiry)list_length,
(lenfunc)list_length,
(binaryfunc)list_subscript,
(objobjargproc)list_ass_subscript
};
@ -2767,11 +2765,11 @@ listiter_next(listiterobject *it)
static PyObject *
listiter_len(listiterobject *it)
{
int len;
Py_ssize_t len;
if (it->it_seq) {
len = PyList_GET_SIZE(it->it_seq) - it->it_index;
if (len >= 0)
return PyInt_FromLong((long)len);
return PyInt_FromSsize_t(len);
}
return PyInt_FromLong(0);
}
@ -2880,17 +2878,17 @@ listreviter_next(listreviterobject *it)
return NULL;
}
static int
static Py_ssize_t
listreviter_len(listreviterobject *it)
{
int len = it->it_index + 1;
Py_ssize_t len = it->it_index + 1;
if (it->it_seq == NULL || PyList_GET_SIZE(it->it_seq) < len)
return 0;
return len;
}
static PySequenceMethods listreviter_as_sequence = {
(inquiry)listreviter_len, /* sq_length */
(lenfunc)listreviter_len, /* sq_length */
0, /* sq_concat */
};

View File

@ -50,8 +50,8 @@ static PyObject *long_format(PyObject *aa, int base, int addL);
static PyLongObject *
long_normalize(register PyLongObject *v)
{
int j = ABS(v->ob_size);
register int i = j;
Py_ssize_t j = ABS(v->ob_size);
Py_ssize_t i = j;
while (i > 0 && v->ob_digit[i-1] == 0)
--i;
@ -64,8 +64,13 @@ long_normalize(register PyLongObject *v)
Return NULL and set exception if we run out of memory. */
PyLongObject *
_PyLong_New(int size)
_PyLong_New(Py_ssize_t size)
{
if (size > INT_MAX) {
/* XXX: Fix this check when ob_size becomes ssize_t */
PyErr_NoMemory();
return NULL;
}
return PyObject_NEW_VAR(PyLongObject, &PyLong_Type, size);
}
@ -73,7 +78,7 @@ PyObject *
_PyLong_Copy(PyLongObject *src)
{
PyLongObject *result;
int i;
Py_ssize_t i;
assert(src != NULL);
i = src->ob_size;
@ -198,7 +203,8 @@ PyLong_AsLong(PyObject *vv)
/* This version by Tim Peters */
register PyLongObject *v;
unsigned long x, prev;
int i, sign;
Py_ssize_t i;
int sign;
if (vv == NULL || !PyLong_Check(vv)) {
if (vv != NULL && PyInt_Check(vv))
@ -235,6 +241,50 @@ PyLong_AsLong(PyObject *vv)
return -1;
}
/* Get a Py_ssize_t from a long int object.
Returns -1 and sets an error condition if overflow occurs. */
Py_ssize_t
_PyLong_AsSsize_t(PyObject *vv)
{
register PyLongObject *v;
size_t x, prev;
Py_ssize_t i;
int sign;
if (vv == NULL || !PyLong_Check(vv)) {
PyErr_BadInternalCall();
return -1;
}
v = (PyLongObject *)vv;
i = v->ob_size;
sign = 1;
x = 0;
if (i < 0) {
sign = -1;
i = -(i);
}
while (--i >= 0) {
prev = x;
x = (x << SHIFT) + v->ob_digit[i];
if ((x >> SHIFT) != prev)
goto overflow;
}
/* Haven't lost any bits, but if the sign bit is set we're in
* trouble *unless* this is the min negative number. So,
* trouble iff sign bit set && (positive || some bit set other
* than the sign bit).
*/
if ((Py_ssize_t)x < 0 && (sign > 0 || (x << 1) != 0))
goto overflow;
return (Py_ssize_t)x * sign;
overflow:
PyErr_SetString(PyExc_OverflowError,
"long int too large to convert to int");
return -1;
}
/* Get a C unsigned long int from a long int object.
Returns -1 and sets an error condition if overflow occurs. */
@ -243,7 +293,7 @@ PyLong_AsUnsignedLong(PyObject *vv)
{
register PyLongObject *v;
unsigned long x, prev;
int i;
Py_ssize_t i;
if (vv == NULL || !PyLong_Check(vv)) {
if (vv != NULL && PyInt_Check(vv)) {
@ -286,7 +336,8 @@ PyLong_AsUnsignedLongMask(PyObject *vv)
{
register PyLongObject *v;
unsigned long x;
int i, sign;
Py_ssize_t i;
int sign;
if (vv == NULL || !PyLong_Check(vv)) {
if (vv != NULL && PyInt_Check(vv))
@ -324,7 +375,7 @@ _PyLong_NumBits(PyObject *vv)
{
PyLongObject *v = (PyLongObject *)vv;
size_t result = 0;
int ndigits;
Py_ssize_t ndigits;
assert(v != NULL);
assert(PyLong_Check(v));
@ -334,7 +385,7 @@ _PyLong_NumBits(PyObject *vv)
digit msd = v->ob_digit[ndigits - 1];
result = (ndigits - 1) * SHIFT;
if (result / SHIFT != (size_t)ndigits - 1)
if (result / SHIFT != ndigits - 1)
goto Overflow;
do {
++result;
@ -464,7 +515,7 @@ _PyLong_AsByteArray(PyLongObject* v,
int little_endian, int is_signed)
{
int i; /* index into v->ob_digit */
int ndigits; /* |v->ob_size| */
Py_ssize_t ndigits; /* |v->ob_size| */
twodigits accum; /* sliding register */
unsigned int accumbits; /* # bits in accum */
int do_twos_comp; /* store 2's-comp? is_signed and v < 0 */
@ -612,7 +663,8 @@ _PyLong_AsScaledDouble(PyObject *vv, int *exponent)
PyLongObject *v;
double x;
const double multiplier = (double)(1L << SHIFT);
int i, sign;
Py_ssize_t i;
int sign;
int nbitsneeded;
if (vv == NULL || !PyLong_Check(vv)) {
@ -772,6 +824,30 @@ PyLong_FromUnsignedLongLong(unsigned PY_LONG_LONG ival)
SIZEOF_LONG_LONG, IS_LITTLE_ENDIAN, 0);
}
/* Create a new long int object from a C Py_ssize_t. */
PyObject *
_PyLong_FromSsize_t(Py_ssize_t ival)
{
Py_ssize_t bytes = ival;
int one = 1;
return _PyLong_FromByteArray(
(unsigned char *)&bytes,
SIZEOF_SIZE_T, IS_LITTLE_ENDIAN, 0);
}
/* Create a new long int object from a C size_t. */
PyObject *
_PyLong_FromSize_t(size_t ival)
{
size_t bytes = ival;
int one = 1;
return _PyLong_FromByteArray(
(unsigned char *)&bytes,
SIZEOF_SIZE_T, IS_LITTLE_ENDIAN, 0);
}
/* Get a C PY_LONG_LONG int from a long int object.
Return -1 and set an error if overflow occurs. */
@ -859,7 +935,8 @@ PyLong_AsUnsignedLongLongMask(PyObject *vv)
{
register PyLongObject *v;
unsigned PY_LONG_LONG x;
int i, sign;
Py_ssize_t i;
int sign;
if (vv == NULL || !PyLong_Check(vv)) {
PyErr_BadInternalCall();
@ -920,7 +997,7 @@ convert_binop(PyObject *v, PyObject *w, PyLongObject **a, PyLongObject **b) {
* x[m-1], and the remaining carry (0 or 1) is returned.
*/
static digit
v_iadd(digit *x, int m, digit *y, int n)
v_iadd(digit *x, Py_ssize_t m, digit *y, Py_ssize_t n)
{
int i;
digit carry = 0;
@ -946,7 +1023,7 @@ v_iadd(digit *x, int m, digit *y, int n)
* far as x[m-1], and the remaining borrow (0 or 1) is returned.
*/
static digit
v_isub(digit *x, int m, digit *y, int n)
v_isub(digit *x, Py_ssize_t m, digit *y, Py_ssize_t n)
{
int i;
digit borrow = 0;
@ -980,10 +1057,10 @@ mul1(PyLongObject *a, wdigit n)
static PyLongObject *
muladd1(PyLongObject *a, wdigit n, wdigit extra)
{
int size_a = ABS(a->ob_size);
Py_ssize_t size_a = ABS(a->ob_size);
PyLongObject *z = _PyLong_New(size_a+1);
twodigits carry = extra;
int i;
Py_ssize_t i;
if (z == NULL)
return NULL;
@ -1003,7 +1080,7 @@ muladd1(PyLongObject *a, wdigit n, wdigit extra)
immutable. */
static digit
inplace_divrem1(digit *pout, digit *pin, int size, digit n)
inplace_divrem1(digit *pout, digit *pin, Py_ssize_t size, digit n)
{
twodigits rem = 0;
@ -1026,7 +1103,7 @@ inplace_divrem1(digit *pout, digit *pin, int size, digit n)
static PyLongObject *
divrem1(PyLongObject *a, digit n, digit *prem)
{
const int size = ABS(a->ob_size);
const Py_ssize_t size = ABS(a->ob_size);
PyLongObject *z;
assert(n > 0 && n <= MASK);
@ -1046,8 +1123,8 @@ long_format(PyObject *aa, int base, int addL)
{
register PyLongObject *a = (PyLongObject *)aa;
PyStringObject *str;
int i;
const int size_a = ABS(a->ob_size);
Py_ssize_t i;
const Py_ssize_t size_a = ABS(a->ob_size);
char *p;
int bits;
char sign = '\0';
@ -1107,7 +1184,7 @@ long_format(PyObject *aa, int base, int addL)
/* Not 0, and base not a power of 2. Divide repeatedly by
base, but for speed use the highest power of base that
fits in a digit. */
int size = size_a;
Py_ssize_t size = size_a;
digit *pin = a->ob_digit;
PyLongObject *scratch;
/* powbasw <- largest power of base that fits in a digit. */
@ -1200,7 +1277,7 @@ long_from_binary_base(char **str, int base)
char *p = *str;
char *start = p;
int bits_per_char;
int n;
Py_ssize_t n;
PyLongObject *z;
twodigits accum;
int bits_in_accum;
@ -1261,7 +1338,7 @@ long_from_binary_base(char **str, int base)
bits_in_accum += bits_per_char;
if (bits_in_accum >= SHIFT) {
*pdigit++ = (digit)(accum & MASK);
assert(pdigit - z->ob_digit <= n);
assert(pdigit - z->ob_digit <= (int)n);
accum >>= SHIFT;
bits_in_accum -= SHIFT;
assert(bits_in_accum < SHIFT);
@ -1270,7 +1347,7 @@ long_from_binary_base(char **str, int base)
if (bits_in_accum) {
assert(bits_in_accum <= SHIFT);
*pdigit++ = (digit)accum;
assert(pdigit - z->ob_digit <= n);
assert(pdigit - z->ob_digit <= (int)n);
}
while (pdigit - z->ob_digit < n)
*pdigit++ = 0;
@ -1356,7 +1433,7 @@ PyLong_FromString(char *str, char **pend, int base)
#ifdef Py_USING_UNICODE
PyObject *
PyLong_FromUnicode(Py_UNICODE *u, int length, int base)
PyLong_FromUnicode(Py_UNICODE *u, Py_ssize_t length, int base)
{
PyObject *result;
char *buffer = PyMem_MALLOC(length+1);
@ -1387,7 +1464,7 @@ static int
long_divrem(PyLongObject *a, PyLongObject *b,
PyLongObject **pdiv, PyLongObject **prem)
{
int size_a = ABS(a->ob_size), size_b = ABS(b->ob_size);
Py_ssize_t size_a = ABS(a->ob_size), size_b = ABS(b->ob_size);
PyLongObject *z;
if (size_b == 0) {
@ -1433,12 +1510,12 @@ long_divrem(PyLongObject *a, PyLongObject *b,
static PyLongObject *
x_divrem(PyLongObject *v1, PyLongObject *w1, PyLongObject **prem)
{
int size_v = ABS(v1->ob_size), size_w = ABS(w1->ob_size);
Py_ssize_t size_v = ABS(v1->ob_size), size_w = ABS(w1->ob_size);
digit d = (digit) ((twodigits)BASE / (w1->ob_digit[size_w-1] + 1));
PyLongObject *v = mul1(v1, d);
PyLongObject *w = mul1(w1, d);
PyLongObject *a;
int j, k;
Py_ssize_t j, k;
if (v == NULL || w == NULL) {
Py_XDECREF(v);
@ -1550,7 +1627,7 @@ long_str(PyObject *v)
static int
long_compare(PyLongObject *a, PyLongObject *b)
{
int sign;
Py_ssize_t sign;
if (a->ob_size != b->ob_size) {
if (ABS(a->ob_size) == 0 && ABS(b->ob_size) == 0)
@ -1559,7 +1636,7 @@ long_compare(PyLongObject *a, PyLongObject *b)
sign = a->ob_size - b->ob_size;
}
else {
int i = ABS(a->ob_size);
Py_ssize_t i = ABS(a->ob_size);
while (--i >= 0 && a->ob_digit[i] == b->ob_digit[i])
;
if (i < 0)
@ -1577,7 +1654,8 @@ static long
long_hash(PyLongObject *v)
{
long x;
int i, sign;
Py_ssize_t i;
int sign;
/* This is designed so that Python ints and longs with the
same value hash to the same value, otherwise comparisons
@ -1608,7 +1686,7 @@ long_hash(PyLongObject *v)
static PyLongObject *
x_add(PyLongObject *a, PyLongObject *b)
{
int size_a = ABS(a->ob_size), size_b = ABS(b->ob_size);
Py_ssize_t size_a = ABS(a->ob_size), size_b = ABS(b->ob_size);
PyLongObject *z;
int i;
digit carry = 0;
@ -1616,7 +1694,7 @@ x_add(PyLongObject *a, PyLongObject *b)
/* Ensure a is the larger of the two: */
if (size_a < size_b) {
{ PyLongObject *temp = a; a = b; b = temp; }
{ int size_temp = size_a;
{ Py_ssize_t size_temp = size_a;
size_a = size_b;
size_b = size_temp; }
}
@ -1642,9 +1720,9 @@ x_add(PyLongObject *a, PyLongObject *b)
static PyLongObject *
x_sub(PyLongObject *a, PyLongObject *b)
{
int size_a = ABS(a->ob_size), size_b = ABS(b->ob_size);
Py_ssize_t size_a = ABS(a->ob_size), size_b = ABS(b->ob_size);
PyLongObject *z;
int i;
Py_ssize_t i;
int sign = 1;
digit borrow = 0;
@ -1652,7 +1730,7 @@ x_sub(PyLongObject *a, PyLongObject *b)
if (size_a < size_b) {
sign = -1;
{ PyLongObject *temp = a; a = b; b = temp; }
{ int size_temp = size_a;
{ Py_ssize_t size_temp = size_a;
size_a = size_b;
size_b = size_temp; }
}
@ -1752,9 +1830,9 @@ static PyLongObject *
x_mul(PyLongObject *a, PyLongObject *b)
{
PyLongObject *z;
int size_a = ABS(a->ob_size);
int size_b = ABS(b->ob_size);
int i;
Py_ssize_t size_a = ABS(a->ob_size);
Py_ssize_t size_b = ABS(b->ob_size);
Py_ssize_t i;
z = _PyLong_New(size_a + size_b);
if (z == NULL)
@ -1840,11 +1918,11 @@ x_mul(PyLongObject *a, PyLongObject *b)
Returns 0 on success, -1 on failure.
*/
static int
kmul_split(PyLongObject *n, int size, PyLongObject **high, PyLongObject **low)
kmul_split(PyLongObject *n, Py_ssize_t size, PyLongObject **high, PyLongObject **low)
{
PyLongObject *hi, *lo;
int size_lo, size_hi;
const int size_n = ABS(n->ob_size);
Py_ssize_t size_lo, size_hi;
const Py_ssize_t size_n = ABS(n->ob_size);
size_lo = MIN(size_n, size);
size_hi = size_n - size_lo;
@ -1873,16 +1951,16 @@ static PyLongObject *k_lopsided_mul(PyLongObject *a, PyLongObject *b);
static PyLongObject *
k_mul(PyLongObject *a, PyLongObject *b)
{
int asize = ABS(a->ob_size);
int bsize = ABS(b->ob_size);
Py_ssize_t asize = ABS(a->ob_size);
Py_ssize_t bsize = ABS(b->ob_size);
PyLongObject *ah = NULL;
PyLongObject *al = NULL;
PyLongObject *bh = NULL;
PyLongObject *bl = NULL;
PyLongObject *ret = NULL;
PyLongObject *t1, *t2, *t3;
int shift; /* the number of digits we split off */
int i;
Py_ssize_t shift; /* the number of digits we split off */
Py_ssize_t i;
/* (ah*X+al)(bh*X+bl) = ah*bh*X*X + (ah*bl + al*bh)*X + al*bl
* Let k = (ah+al)*(bh+bl) = ah*bl + al*bh + ah*bh + al*bl
@ -2094,9 +2172,9 @@ ah*bh and al*bl too.
static PyLongObject *
k_lopsided_mul(PyLongObject *a, PyLongObject *b)
{
const int asize = ABS(a->ob_size);
int bsize = ABS(b->ob_size);
int nbdone; /* # of b digits already multiplied */
const Py_ssize_t asize = ABS(a->ob_size);
Py_ssize_t bsize = ABS(b->ob_size);
Py_ssize_t nbdone; /* # of b digits already multiplied */
PyLongObject *ret;
PyLongObject *bslice = NULL;
@ -2117,7 +2195,7 @@ k_lopsided_mul(PyLongObject *a, PyLongObject *b)
nbdone = 0;
while (bsize > 0) {
PyLongObject *product;
const int nbtouse = MIN(bsize, asize);
const Py_ssize_t nbtouse = MIN(bsize, asize);
/* Multiply the next slice of b by a. */
memcpy(bslice->ob_digit, b->ob_digit + nbdone,
@ -2353,7 +2431,7 @@ long_pow(PyObject *v, PyObject *w, PyObject *x)
int negativeOutput = 0; /* if x<0 return negative output */
PyLongObject *z = NULL; /* accumulated result */
int i, j, k; /* counters */
Py_ssize_t i, j, k; /* counters */
PyLongObject *temp = NULL;
/* 5-ary values. If the exponent is large enough, table is
@ -2597,7 +2675,7 @@ long_rshift(PyLongObject *v, PyLongObject *w)
PyLongObject *a, *b;
PyLongObject *z = NULL;
long shiftby;
int newsize, wordshift, loshift, hishift, i, j;
Py_ssize_t newsize, wordshift, loshift, hishift, i, j;
digit lomask, himask;
CONVERT_BINOP((PyObject *)v, (PyObject *)w, &a, &b);
@ -2664,7 +2742,7 @@ long_lshift(PyObject *v, PyObject *w)
PyLongObject *a, *b;
PyLongObject *z = NULL;
long shiftby;
int oldsize, newsize, wordshift, remshift, i, j;
Py_ssize_t oldsize, newsize, wordshift, remshift, i, j;
twodigits accum;
CONVERT_BINOP(v, w, &a, &b);
@ -2723,7 +2801,7 @@ long_bitwise(PyLongObject *a,
{
digit maska, maskb; /* 0 or MASK */
int negz;
int size_a, size_b, size_z;
Py_ssize_t size_a, size_b, size_z;
PyLongObject *z;
int i;
digit diga, digb;
@ -2965,7 +3043,7 @@ static PyObject *
long_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
PyLongObject *tmp, *new;
int i, n;
Py_ssize_t i, n;
assert(PyType_IsSubtype(type, &PyLong_Type));
tmp = (PyLongObject *)long_new(&PyLong_Type, args, kwds);

View File

@ -65,7 +65,7 @@ PyCFunction_Call(PyObject *func, PyObject *arg, PyObject *kw)
PyCFunctionObject* f = (PyCFunctionObject*)func;
PyCFunction meth = PyCFunction_GET_FUNCTION(func);
PyObject *self = PyCFunction_GET_SELF(func);
int size;
long size;
switch (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST)) {
case METH_VARARGS:
@ -81,7 +81,7 @@ PyCFunction_Call(PyObject *func, PyObject *arg, PyObject *kw)
if (size == 0)
return (*meth)(self, NULL);
PyErr_Format(PyExc_TypeError,
"%.200s() takes no arguments (%d given)",
"%.200s() takes no arguments (%ld given)",
f->m_ml->ml_name, size);
return NULL;
}
@ -92,7 +92,7 @@ PyCFunction_Call(PyObject *func, PyObject *arg, PyObject *kw)
if (size == 1)
return (*meth)(self, PyTuple_GET_ITEM(arg, 0));
PyErr_Format(PyExc_TypeError,
"%.200s() takes exactly one argument (%d given)",
"%.200s() takes exactly one argument (%ld given)",
f->m_ml->ml_name, size);
return NULL;
}

View File

@ -104,7 +104,7 @@ _PyModule_Clear(PyObject *m)
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;

View File

@ -170,7 +170,7 @@ PyObject_Init(PyObject *op, PyTypeObject *tp)
}
PyVarObject *
PyObject_InitVar(PyVarObject *op, PyTypeObject *tp, int size)
PyObject_InitVar(PyVarObject *op, PyTypeObject *tp, Py_ssize_t size)
{
if (op == NULL)
return (PyVarObject *) PyErr_NoMemory();
@ -192,7 +192,7 @@ _PyObject_New(PyTypeObject *tp)
}
PyVarObject *
_PyObject_NewVar(PyTypeObject *tp, int nitems)
_PyObject_NewVar(PyTypeObject *tp, Py_ssize_t nitems)
{
PyVarObject *op;
const size_t size = _PyObject_VAR_SIZE(tp, nitems);
@ -1175,7 +1175,7 @@ _PyObject_GetDictPtr(PyObject *obj)
if (dictoffset == 0)
return NULL;
if (dictoffset < 0) {
int tsize;
Py_ssize_t tsize;
size_t size;
tsize = ((PyVarObject *)obj)->ob_size;
@ -1237,7 +1237,7 @@ PyObject_GenericGetAttr(PyObject *obj, PyObject *name)
/* Inline _PyType_Lookup */
{
int i, n;
Py_ssize_t i, n;
PyObject *mro, *base, *dict;
/* Look in tp_dict of types in MRO */
@ -1278,7 +1278,7 @@ PyObject_GenericGetAttr(PyObject *obj, PyObject *name)
if (dictoffset != 0) {
PyObject *dict;
if (dictoffset < 0) {
int tsize;
Py_ssize_t tsize;
size_t size;
tsize = ((PyVarObject *)obj)->ob_size;
@ -1414,7 +1414,7 @@ PyObject_GenericSetAttr(PyObject *obj, PyObject *name, PyObject *value)
int
PyObject_IsTrue(PyObject *v)
{
int res;
Py_ssize_t res;
if (v == Py_True)
return 1;
if (v == Py_False)
@ -1432,7 +1432,8 @@ PyObject_IsTrue(PyObject *v)
res = (*v->ob_type->tp_as_sequence->sq_length)(v);
else
return 1;
return (res > 0) ? 1 : res;
/* if it is negative, it should be either -1 or -2 */
return (res > 0) ? 1 : Py_SAFE_DOWNCAST(res, Py_ssize_t, int);
}
/* equivalent of 'not v'
@ -1556,7 +1557,7 @@ merge_class_dict(PyObject* dict, PyObject* aclass)
PyErr_Clear();
else {
/* We have no guarantee that bases is a real tuple */
int i, n;
Py_ssize_t i, n;
n = PySequence_Size(bases); /* This better be right */
if (n < 0)
PyErr_Clear();
@ -1949,7 +1950,7 @@ PyTypeObject *_Py_cobject_hack = &PyCObject_Type;
/* 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) */
@ -1992,7 +1993,7 @@ Py_ReprEnter(PyObject *obj)
{
PyObject *dict;
PyObject *list;
int i;
Py_ssize_t i;
dict = PyThreadState_GetDict();
if (dict == NULL)
@ -2020,7 +2021,7 @@ Py_ReprLeave(PyObject *obj)
{
PyObject *dict;
PyObject *list;
int i;
Py_ssize_t i;
dict = PyThreadState_GetDict();
if (dict == NULL)

View File

@ -541,8 +541,8 @@ error:
/* This is only useful when running memory debuggers such as
* Purify or Valgrind. Uncomment to use.
*
#define Py_USING_MEMORY_DEBUGGER
*/
#define Py_USING_MEMORY_DEBUGGER
#ifdef Py_USING_MEMORY_DEBUGGER
@ -816,7 +816,7 @@ PyObject_Realloc(void *p, size_t nbytes)
{
void *bp;
poolp pool;
uint size;
size_t size;
if (p == NULL)
return PyObject_Malloc(nbytes);
@ -1005,6 +1005,8 @@ _PyObject_DebugMalloc(size_t nbytes)
bumpserialno();
total = nbytes + 16;
#if SIZEOF_SIZE_T < 8
/* XXX do this check only on 32-bit machines */
if (total < nbytes || (total >> 31) > 1) {
/* overflow, or we can't represent it in 4 bytes */
/* Obscure: can't do (total >> 32) != 0 instead, because
@ -1013,12 +1015,13 @@ _PyObject_DebugMalloc(size_t nbytes)
size_t is an unsigned type. */
return NULL;
}
#endif
p = (uchar *)PyObject_Malloc(total);
if (p == NULL)
return NULL;
write4(p, nbytes);
write4(p, (ulong)nbytes);
p[4] = p[5] = p[6] = p[7] = FORBIDDENBYTE;
if (nbytes > 0)
@ -1081,7 +1084,7 @@ _PyObject_DebugRealloc(void *p, size_t nbytes)
if (q == NULL)
return NULL;
write4(q, nbytes);
write4(q, (ulong)nbytes);
assert(q[4] == FORBIDDENBYTE &&
q[5] == FORBIDDENBYTE &&
q[6] == FORBIDDENBYTE &&

View File

@ -91,27 +91,27 @@ generates the numbers in the range on demand. For looping, this is \n\
slightly faster than range() and more memory efficient.");
static PyObject *
range_item(rangeobject *r, int i)
range_item(rangeobject *r, Py_ssize_t i)
{
if (i < 0 || i >= r->len) {
PyErr_SetString(PyExc_IndexError,
"xrange object index out of range");
return NULL;
}
return PyInt_FromLong(r->start + (i % r->len) * r->step);
return PyInt_FromSsize_t(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,10 +137,10 @@ range_repr(rangeobject *r)
}
static PySequenceMethods range_as_sequence = {
(inquiry)range_length, /* sq_length */
(lenfunc)range_length, /* sq_length */
0, /* sq_concat */
0, /* sq_repeat */
(intargfunc)range_item, /* sq_item */
(ssizeargfunc)range_item, /* sq_item */
0, /* sq_slice */
};

View File

@ -51,8 +51,8 @@ NULL if the rich comparison returns an error.
static setentry *
set_lookkey(PySetObject *so, PyObject *key, register long hash)
{
register int i;
register unsigned int perturb;
register Py_ssize_t i;
register size_t perturb;
register setentry *freeslot;
register unsigned int mask = so->mask;
setentry *table = so->table;
@ -129,8 +129,8 @@ set_lookkey(PySetObject *so, PyObject *key, register long hash)
static setentry *
set_lookkey_string(PySetObject *so, PyObject *key, register long hash)
{
register int i;
register unsigned int perturb;
register Py_ssize_t i;
register size_t perturb;
register setentry *freeslot;
register unsigned int mask = so->mask;
setentry *table = so->table;
@ -468,9 +468,10 @@ set_clear_internal(PySetObject *so)
* 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 @@ static int
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 = ", ";
@ -551,7 +552,7 @@ set_repr(PySetObject *so)
return result;
}
static int
static Py_ssize_t
set_len(PyObject *so)
{
return ((PySetObject *)so)->used;
@ -673,7 +674,7 @@ PyDoc_STRVAR(pop_doc, "Remove and return an arbitrary set element.");
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 @@ frozenset_hash(PyObject *self)
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;
@ -752,7 +753,7 @@ setiter_dealloc(setiterobject *si)
static PyObject *
setiter_len(setiterobject *si)
{
int len = 0;
long len = 0;
if (si->si_set != NULL && si->si_used == si->si_set->used)
len = si->len;
return PyInt_FromLong(len);
@ -847,7 +848,7 @@ set_update_internal(PySetObject *so, PyObject *other)
if (PyDict_Check(other)) {
PyObject *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 @@ set_intersection(PySetObject *so, PyObject *other)
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 @@ set_difference_update_internal(PySetObject *so, PyObject *other)
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 @@ set_difference(PySetObject *so, PyObject *other)
{
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 @@ set_symmetric_difference_update(PySetObject *so, PyObject *other)
{
PySetObject *otherset;
PyObject *key;
int pos = 0;
Py_ssize_t pos = 0;
setentry *entry;
if ((PyObject *)so == other)
@ -1442,7 +1443,7 @@ static PyObject *
set_issubset(PySetObject *so, PyObject *other)
{
setentry *entry;
int pos = 0;
Py_ssize_t pos = 0;
if (!PyAnySet_Check(other)) {
PyObject *tmp, *result;
@ -1687,7 +1688,7 @@ set_init(PySetObject *self, PyObject *args, PyObject *kwds)
}
static PySequenceMethods set_as_sequence = {
(inquiry)set_len, /* sq_length */
(lenfunc)set_len, /* sq_length */
0, /* sq_concat */
0, /* sq_repeat */
0, /* sq_item */

View File

@ -80,9 +80,10 @@ PySlice_New(PyObject *start, PyObject *stop, PyObject *step)
}
int
PySlice_GetIndices(PySliceObject *r, int length,
int *start, int *stop, int *step)
PySlice_GetIndices(PySliceObject *r, Py_ssize_t length,
Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step)
{
/* XXX support long ints */
if (r->step == Py_None) {
*step = 1;
} else {
@ -110,12 +111,12 @@ PySlice_GetIndices(PySliceObject *r, int length,
}
int
PySlice_GetIndicesEx(PySliceObject *r, int length,
int *start, int *stop, int *step, int *slicelength)
PySlice_GetIndicesEx(PySliceObject *r, Py_ssize_t length,
Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step, Py_ssize_t *slicelength)
{
/* this is harder to get right than you might think */
int defstart, defstop;
Py_ssize_t defstart, defstop;
if (r->step == Py_None) {
*step = 1;
@ -230,7 +231,7 @@ static PyMemberDef slice_members[] = {
static PyObject*
slice_indices(PySliceObject* self, PyObject* len)
{
int ilen, start, stop, step, slicelength;
Py_ssize_t ilen, start, stop, step, slicelength;
ilen = PyInt_AsLong(len);

View File

@ -49,7 +49,7 @@ static PyObject *interned;
parameter (for PyString_FromString()).
*/
PyObject *
PyString_FromStringAndSize(const char *str, int size)
PyString_FromStringAndSize(const char *str, Py_ssize_t size)
{
register PyStringObject *op;
assert(size >= 0);
@ -154,7 +154,7 @@ PyObject *
PyString_FromFormatV(const char *format, va_list vargs)
{
va_list count;
int n = 0;
Py_ssize_t n = 0;
const char* f;
char *s;
PyObject* string;
@ -235,7 +235,8 @@ PyString_FromFormatV(const char *format, va_list vargs)
for (f = format; *f; f++) {
if (*f == '%') {
const char* p = f++;
int i, longflag = 0;
Py_ssize_t i;
int longflag = 0;
/* parse the width.precision part (we're only
interested in the precision value, if any) */
n = 0;
@ -330,7 +331,7 @@ PyString_FromFormat(const char *format, ...)
PyObject *PyString_Decode(const char *s,
int size,
Py_ssize_t size,
const char *encoding,
const char *errors)
{
@ -410,7 +411,7 @@ PyObject *PyString_AsDecodedString(PyObject *str,
}
PyObject *PyString_Encode(const char *s,
int size,
Py_ssize_t size,
const char *encoding,
const char *errors)
{
@ -519,16 +520,16 @@ string_dealloc(PyObject *op)
specified encoding. */
PyObject *PyString_DecodeEscape(const char *s,
int len,
Py_ssize_t len,
const char *errors,
int unicode,
Py_ssize_t unicode,
const char *recode_encoding)
{
int c;
char *p, *buf;
const char *end;
PyObject *v;
int newlen = recode_encoding ? 4*len:len;
Py_ssize_t newlen = recode_encoding ? 4*len:len;
v = PyString_FromStringAndSize((char *)NULL, newlen);
if (v == NULL)
return NULL;
@ -542,7 +543,7 @@ PyObject *PyString_DecodeEscape(const char *s,
PyObject *u, *w;
char *r;
const char* t;
int rn;
Py_ssize_t rn;
t = s;
/* Decode non-ASCII bytes as UTF-8. */
while (t < end && (*t & 0x80)) t++;
@ -658,18 +659,18 @@ PyObject *PyString_DecodeEscape(const char *s,
}
}
if (p-buf < newlen)
_PyString_Resize(&v, (int)(p - buf));
_PyString_Resize(&v, p - buf);
return v;
failed:
Py_DECREF(v);
return NULL;
}
static int
static Py_ssize_t
string_getsize(register PyObject *op)
{
char *s;
int len;
Py_ssize_t len;
if (PyString_AsStringAndSize(op, &s, &len))
return -1;
return len;
@ -679,13 +680,13 @@ static /*const*/ char *
string_getbuffer(register PyObject *op)
{
char *s;
int len;
Py_ssize_t len;
if (PyString_AsStringAndSize(op, &s, &len))
return NULL;
return s;
}
int
Py_ssize_t
PyString_Size(register PyObject *op)
{
if (!PyString_Check(op))
@ -704,7 +705,7 @@ PyString_AsString(register PyObject *op)
int
PyString_AsStringAndSize(register PyObject *obj,
register char **s,
register int *len)
register Py_ssize_t *len)
{
if (s == NULL) {
PyErr_BadInternalCall();
@ -731,7 +732,7 @@ PyString_AsStringAndSize(register PyObject *obj,
*s = PyString_AS_STRING(obj);
if (len != NULL)
*len = PyString_GET_SIZE(obj);
else if ((int)strlen(*s) != PyString_GET_SIZE(obj)) {
else if (strlen(*s) != PyString_GET_SIZE(obj)) {
PyErr_SetString(PyExc_TypeError,
"expected string without null bytes");
return -1;
@ -744,7 +745,7 @@ PyString_AsStringAndSize(register PyObject *obj,
static int
string_print(PyStringObject *op, FILE *fp, int flags)
{
int i;
Py_ssize_t i;
char c;
int quote;
@ -809,7 +810,7 @@ PyString_Repr(PyObject *obj, int smartquotes)
return NULL;
}
else {
register int i;
register Py_ssize_t i;
register char c;
register char *p;
int quote;
@ -876,7 +877,7 @@ string_str(PyObject *s)
}
}
static int
static Py_ssize_t
string_length(PyStringObject *a)
{
return a->ob_size;
@ -885,7 +886,7 @@ string_length(PyStringObject *a)
static PyObject *
string_concat(register PyStringObject *a, register PyObject *bb)
{
register unsigned int size;
register size_t size;
register PyStringObject *op;
if (!PyString_Check(bb)) {
#ifdef Py_USING_UNICODE
@ -909,6 +910,7 @@ string_concat(register PyStringObject *a, register PyObject *bb)
return (PyObject *)a;
}
size = a->ob_size + b->ob_size;
/* XXX check overflow */
/* Inline PyObject_NewVar */
op = (PyStringObject *)PyObject_MALLOC(sizeof(PyStringObject) + size);
if (op == NULL)
@ -916,19 +918,19 @@ string_concat(register PyStringObject *a, register PyObject *bb)
PyObject_INIT_VAR(op, &PyString_Type, size);
op->ob_shash = -1;
op->ob_sstate = SSTATE_NOT_INTERNED;
memcpy(op->ob_sval, a->ob_sval, (int) a->ob_size);
memcpy(op->ob_sval + a->ob_size, b->ob_sval, (int) b->ob_size);
memcpy(op->ob_sval, a->ob_sval, a->ob_size);
memcpy(op->ob_sval + a->ob_size, b->ob_sval, b->ob_size);
op->ob_sval[size] = '\0';
return (PyObject *) op;
#undef b
}
static PyObject *
string_repeat(register PyStringObject *a, register int n)
string_repeat(register PyStringObject *a, register Py_ssize_t n)
{
register int i;
register int j;
register int size;
register Py_ssize_t i;
register Py_ssize_t j;
register Py_ssize_t size;
register PyStringObject *op;
size_t nbytes;
if (n < 0)
@ -966,8 +968,8 @@ string_repeat(register PyStringObject *a, register int n)
}
i = 0;
if (i < size) {
memcpy(op->ob_sval, a->ob_sval, (int) a->ob_size);
i = (int) a->ob_size;
memcpy(op->ob_sval, a->ob_sval, a->ob_size);
i = a->ob_size;
}
while (i < size) {
j = (i <= size-i) ? i : size-i;
@ -980,7 +982,8 @@ string_repeat(register PyStringObject *a, register int n)
/* String slice a[i:j] consists of characters a[i] ... a[j-1] */
static PyObject *
string_slice(register PyStringObject *a, register int i, register int j)
string_slice(register PyStringObject *a, register Py_ssize_t i,
register Py_ssize_t j)
/* j -- may be negative! */
{
if (i < 0)
@ -996,7 +999,7 @@ string_slice(register PyStringObject *a, register int i, register int j)
}
if (j < i)
j = i;
return PyString_FromStringAndSize(a->ob_sval + i, (int) (j-i));
return PyString_FromStringAndSize(a->ob_sval + i, j-i);
}
static int
@ -1005,7 +1008,7 @@ string_contains(PyObject *a, PyObject *el)
char *s = PyString_AS_STRING(a);
const char *sub = PyString_AS_STRING(el);
char *last;
int len_sub = PyString_GET_SIZE(el);
Py_ssize_t len_sub = PyString_GET_SIZE(el);
int shortsub;
char firstchar, lastchar;
@ -1047,7 +1050,7 @@ string_contains(PyObject *a, PyObject *el)
}
static PyObject *
string_item(PyStringObject *a, register int i)
string_item(PyStringObject *a, register Py_ssize_t i)
{
PyObject *v;
char *pchar;
@ -1072,8 +1075,8 @@ static PyObject*
string_richcompare(PyStringObject *a, PyStringObject *b, int op)
{
int c;
int len_a, len_b;
int min_len;
Py_ssize_t len_a, len_b;
Py_ssize_t min_len;
PyObject *result;
/* Make sure both arguments are strings. */
@ -1145,7 +1148,7 @@ _PyString_Eq(PyObject *o1, PyObject *o2)
static long
string_hash(PyStringObject *a)
{
register int len;
register Py_ssize_t len;
register unsigned char *p;
register long x;
@ -1166,14 +1169,8 @@ string_hash(PyStringObject *a)
static PyObject*
string_subscript(PyStringObject* self, PyObject* item)
{
if (PyInt_Check(item)) {
long i = PyInt_AS_LONG(item);
if (i < 0)
i += PyString_GET_SIZE(self);
return string_item(self,i);
}
else if (PyLong_Check(item)) {
long i = PyLong_AsLong(item);
if (PyInt_Check(item) || PyLong_Check(item)) {
Py_ssize_t i = PyInt_AsSsize_t(item);
if (i == -1 && PyErr_Occurred())
return NULL;
if (i < 0)
@ -1181,7 +1178,7 @@ string_subscript(PyStringObject* self, PyObject* item)
return string_item(self,i);
}
else if (PySlice_Check(item)) {
int start, stop, step, slicelength, cur, i;
Py_ssize_t start, stop, step, slicelength, cur, i;
char* source_buf;
char* result_buf;
PyObject* result;
@ -1219,8 +1216,8 @@ string_subscript(PyStringObject* self, PyObject* item)
}
}
static int
string_buffer_getreadbuf(PyStringObject *self, int index, const void **ptr)
static Py_ssize_t
string_buffer_getreadbuf(PyStringObject *self, Py_ssize_t index, const void **ptr)
{
if ( index != 0 ) {
PyErr_SetString(PyExc_SystemError,
@ -1231,24 +1228,24 @@ string_buffer_getreadbuf(PyStringObject *self, int index, const void **ptr)
return self->ob_size;
}
static int
string_buffer_getwritebuf(PyStringObject *self, int index, const void **ptr)
static Py_ssize_t
string_buffer_getwritebuf(PyStringObject *self, Py_ssize_t index, const void **ptr)
{
PyErr_SetString(PyExc_TypeError,
"Cannot use string as modifiable buffer");
return -1;
}
static int
string_buffer_getsegcount(PyStringObject *self, int *lenp)
static Py_ssize_t
string_buffer_getsegcount(PyStringObject *self, Py_ssize_t *lenp)
{
if ( lenp )
*lenp = self->ob_size;
return 1;
}
static int
string_buffer_getcharbuf(PyStringObject *self, int index, const char **ptr)
static Py_ssize_t
string_buffer_getcharbuf(PyStringObject *self, Py_ssize_t index, const char **ptr)
{
if ( index != 0 ) {
PyErr_SetString(PyExc_SystemError,
@ -1260,27 +1257,27 @@ string_buffer_getcharbuf(PyStringObject *self, int index, const char **ptr)
}
static PySequenceMethods string_as_sequence = {
(inquiry)string_length, /*sq_length*/
(lenfunc)string_length, /*sq_length*/
(binaryfunc)string_concat, /*sq_concat*/
(intargfunc)string_repeat, /*sq_repeat*/
(intargfunc)string_item, /*sq_item*/
(intintargfunc)string_slice, /*sq_slice*/
(ssizeargfunc)string_repeat, /*sq_repeat*/
(ssizeargfunc)string_item, /*sq_item*/
(ssizessizeargfunc)string_slice, /*sq_slice*/
0, /*sq_ass_item*/
0, /*sq_ass_slice*/
(objobjproc)string_contains /*sq_contains*/
};
static PyMappingMethods string_as_mapping = {
(inquiry)string_length,
(lenfunc)string_length,
(binaryfunc)string_subscript,
0,
};
static PyBufferProcs string_as_buffer = {
(getreadbufferproc)string_buffer_getreadbuf,
(getwritebufferproc)string_buffer_getwritebuf,
(getsegcountproc)string_buffer_getsegcount,
(getcharbufferproc)string_buffer_getcharbuf,
(readbufferproc)string_buffer_getreadbuf,
(writebufferproc)string_buffer_getwritebuf,
(segcountproc)string_buffer_getsegcount,
(charbufferproc)string_buffer_getcharbuf,
};
@ -1319,9 +1316,9 @@ static const char *stripformat[] = {"|O:lstrip", "|O:rstrip", "|O:strip"};
Py_DECREF(str);
static PyObject *
split_whitespace(const char *s, int len, int maxsplit)
split_whitespace(const char *s, Py_ssize_t len, int maxsplit)
{
int i, j;
Py_ssize_t i, j;
PyObject *str;
PyObject *list = PyList_New(0);
@ -1353,9 +1350,9 @@ split_whitespace(const char *s, int len, int maxsplit)
}
static PyObject *
split_char(const char *s, int len, char ch, int maxcount)
split_char(const char *s, Py_ssize_t len, char ch, int maxcount)
{
register int i, j;
register Py_ssize_t i, j;
PyObject *str;
PyObject *list = PyList_New(0);
@ -1392,7 +1389,8 @@ whitespace string is a separator.");
static PyObject *
string_split(PyStringObject *self, PyObject *args)
{
int len = PyString_GET_SIZE(self), n, i, j, err;
Py_ssize_t len = PyString_GET_SIZE(self), n, i, j;
int err;
int maxsplit = -1;
const char *s = PyString_AS_STRING(self), *sub;
PyObject *list, *item, *subobj = Py_None;
@ -1430,7 +1428,7 @@ string_split(PyStringObject *self, PyObject *args)
if (s[i] == sub[0] && memcmp(s+i, sub, n) == 0) {
if (maxsplit-- <= 0)
break;
item = PyString_FromStringAndSize(s+j, (int)(i-j));
item = PyString_FromStringAndSize(s+j, i-j);
if (item == NULL)
goto fail;
err = PyList_Append(list, item);
@ -1442,7 +1440,7 @@ string_split(PyStringObject *self, PyObject *args)
else
i++;
}
item = PyString_FromStringAndSize(s+j, (int)(len-j));
item = PyString_FromStringAndSize(s+j, len-j);
if (item == NULL)
goto fail;
err = PyList_Append(list, item);
@ -1458,9 +1456,9 @@ string_split(PyStringObject *self, PyObject *args)
}
static PyObject *
rsplit_whitespace(const char *s, int len, int maxsplit)
rsplit_whitespace(const char *s, Py_ssize_t len, int maxsplit)
{
int i, j;
Py_ssize_t i, j;
PyObject *str;
PyObject *list = PyList_New(0);
@ -1492,9 +1490,9 @@ rsplit_whitespace(const char *s, int len, int maxsplit)
}
static PyObject *
rsplit_char(const char *s, int len, char ch, int maxcount)
rsplit_char(const char *s, Py_ssize_t len, char ch, int maxcount)
{
register int i, j;
register Py_ssize_t i, j;
PyObject *str;
PyObject *list = PyList_New(0);
@ -1532,7 +1530,8 @@ is a separator.");
static PyObject *
string_rsplit(PyStringObject *self, PyObject *args)
{
int len = PyString_GET_SIZE(self), n, i, j, err;
Py_ssize_t len = PyString_GET_SIZE(self), n, i, j;
int err;
int maxsplit = -1;
const char *s = PyString_AS_STRING(self), *sub;
PyObject *list, *item, *subobj = Py_None;
@ -1571,7 +1570,7 @@ string_rsplit(PyStringObject *self, PyObject *args)
if (s[i] == sub[0] && memcmp(s+i, sub, n) == 0) {
if (maxsplit-- <= 0)
break;
item = PyString_FromStringAndSize(s+i+n, (int)(j-i-n));
item = PyString_FromStringAndSize(s+i+n, j-i-n);
if (item == NULL)
goto fail;
err = PyList_Insert(list, 0, item);
@ -1610,12 +1609,12 @@ static PyObject *
string_join(PyStringObject *self, PyObject *orig)
{
char *sep = PyString_AS_STRING(self);
const int seplen = PyString_GET_SIZE(self);
const Py_ssize_t seplen = PyString_GET_SIZE(self);
PyObject *res = NULL;
char *p;
int seqlen = 0;
Py_ssize_t seqlen = 0;
size_t sz = 0;
int i;
Py_ssize_t i;
PyObject *seq, *item;
seq = PySequence_Fast(orig, "");
@ -1663,7 +1662,7 @@ string_join(PyStringObject *self, PyObject *orig)
PyErr_Format(PyExc_TypeError,
"sequence item %i: expected string,"
" %.80s found",
i, item->ob_type->tp_name);
/*XXX*/(int)i, item->ob_type->tp_name);
Py_DECREF(seq);
return NULL;
}
@ -1679,7 +1678,7 @@ string_join(PyStringObject *self, PyObject *orig)
}
/* Allocate result space. */
res = PyString_FromStringAndSize((char*)NULL, (int)sz);
res = PyString_FromStringAndSize((char*)NULL, sz);
if (res == NULL) {
Py_DECREF(seq);
return NULL;
@ -1712,7 +1711,7 @@ _PyString_Join(PyObject *sep, PyObject *x)
}
static void
string_adjust_indices(int *start, int *end, int len)
string_adjust_indices(Py_ssize_t *start, Py_ssize_t *end, Py_ssize_t len)
{
if (*end > len)
*end = len;
@ -1726,14 +1725,15 @@ string_adjust_indices(int *start, int *end, int len)
*start = 0;
}
static long
static Py_ssize_t
string_find_internal(PyStringObject *self, PyObject *args, int dir)
{
const char *s = PyString_AS_STRING(self), *sub;
int len = PyString_GET_SIZE(self);
int n, i = 0, last = INT_MAX;
Py_ssize_t len = PyString_GET_SIZE(self);
Py_ssize_t n, i = 0, last = INT_MAX;
PyObject *subobj;
/* XXX ssize_t i */
if (!PyArg_ParseTuple(args, "O|O&O&:find/rfind/index/rindex",
&subobj, _PyEval_SliceIndex, &i, _PyEval_SliceIndex, &last))
return -2;
@ -1759,13 +1759,13 @@ string_find_internal(PyStringObject *self, PyObject *args, int dir)
return (long)i;
}
else {
int j;
Py_ssize_t j;
if (n == 0 && i <= last)
return (long)last;
return last;
for (j = last-n; j >= i; --j)
if (s[j] == sub[0] && memcmp(&s[j], sub, n) == 0)
return (long)j;
return j;
}
return -1;
@ -1784,10 +1784,10 @@ Return -1 on failure.");
static PyObject *
string_find(PyStringObject *self, PyObject *args)
{
long result = string_find_internal(self, args, +1);
Py_ssize_t result = string_find_internal(self, args, +1);
if (result == -2)
return NULL;
return PyInt_FromLong(result);
return PyInt_FromSsize_t(result);
}
@ -1799,7 +1799,7 @@ Like S.find() but raise ValueError when the substring is not found.");
static PyObject *
string_index(PyStringObject *self, PyObject *args)
{
long result = string_find_internal(self, args, +1);
Py_ssize_t result = string_find_internal(self, args, +1);
if (result == -2)
return NULL;
if (result == -1) {
@ -1807,7 +1807,7 @@ string_index(PyStringObject *self, PyObject *args)
"substring not found");
return NULL;
}
return PyInt_FromLong(result);
return PyInt_FromSsize_t(result);
}
@ -1823,10 +1823,10 @@ Return -1 on failure.");
static PyObject *
string_rfind(PyStringObject *self, PyObject *args)
{
long result = string_find_internal(self, args, -1);
Py_ssize_t result = string_find_internal(self, args, -1);
if (result == -2)
return NULL;
return PyInt_FromLong(result);
return PyInt_FromSsize_t(result);
}
@ -1838,7 +1838,7 @@ Like S.rfind() but raise ValueError when the substring is not found.");
static PyObject *
string_rindex(PyStringObject *self, PyObject *args)
{
long result = string_find_internal(self, args, -1);
Py_ssize_t result = string_find_internal(self, args, -1);
if (result == -2)
return NULL;
if (result == -1) {
@ -1846,7 +1846,7 @@ string_rindex(PyStringObject *self, PyObject *args)
"substring not found");
return NULL;
}
return PyInt_FromLong(result);
return PyInt_FromSsize_t(result);
}
@ -1854,10 +1854,10 @@ static PyObject *
do_xstrip(PyStringObject *self, int striptype, PyObject *sepobj)
{
char *s = PyString_AS_STRING(self);
int len = PyString_GET_SIZE(self);
Py_ssize_t len = PyString_GET_SIZE(self);
char *sep = PyString_AS_STRING(sepobj);
int seplen = PyString_GET_SIZE(sepobj);
int i, j;
Py_ssize_t seplen = PyString_GET_SIZE(sepobj);
Py_ssize_t i, j;
i = 0;
if (striptype != RIGHTSTRIP) {
@ -1887,7 +1887,7 @@ static PyObject *
do_strip(PyStringObject *self, int striptype)
{
char *s = PyString_AS_STRING(self);
int len = PyString_GET_SIZE(self), i, j;
Py_ssize_t len = PyString_GET_SIZE(self), i, j;
i = 0;
if (striptype != RIGHTSTRIP) {
@ -2014,7 +2014,7 @@ static PyObject *
string_lower(PyStringObject *self)
{
char *s = PyString_AS_STRING(self), *s_new;
int i, n = PyString_GET_SIZE(self);
Py_ssize_t i, n = PyString_GET_SIZE(self);
PyObject *new;
new = PyString_FromStringAndSize(NULL, n);
@ -2042,7 +2042,7 @@ static PyObject *
string_upper(PyStringObject *self)
{
char *s = PyString_AS_STRING(self), *s_new;
int i, n = PyString_GET_SIZE(self);
Py_ssize_t i, n = PyString_GET_SIZE(self);
PyObject *new;
new = PyString_FromStringAndSize(NULL, n);
@ -2071,7 +2071,7 @@ static PyObject*
string_title(PyStringObject *self)
{
char *s = PyString_AS_STRING(self), *s_new;
int i, n = PyString_GET_SIZE(self);
Py_ssize_t i, n = PyString_GET_SIZE(self);
int previous_is_cased = 0;
PyObject *new;
@ -2106,7 +2106,7 @@ static PyObject *
string_capitalize(PyStringObject *self)
{
char *s = PyString_AS_STRING(self), *s_new;
int i, n = PyString_GET_SIZE(self);
Py_ssize_t i, n = PyString_GET_SIZE(self);
PyObject *new;
new = PyString_FromStringAndSize(NULL, n);
@ -2144,9 +2144,9 @@ static PyObject *
string_count(PyStringObject *self, PyObject *args)
{
const char *s = PyString_AS_STRING(self), *sub, *t;
int len = PyString_GET_SIZE(self), n;
int i = 0, last = INT_MAX;
int m, r;
Py_ssize_t len = PyString_GET_SIZE(self), n;
Py_ssize_t i = 0, last = INT_MAX;
Py_ssize_t m, r;
PyObject *subobj;
if (!PyArg_ParseTuple(args, "O|O&O&:count", &subobj,
@ -2159,7 +2159,7 @@ string_count(PyStringObject *self, PyObject *args)
}
#ifdef Py_USING_UNICODE
else if (PyUnicode_Check(subobj)) {
int count;
Py_ssize_t count;
count = PyUnicode_Count((PyObject *)self, subobj, i, last);
if (count == -1)
return NULL;
@ -2174,7 +2174,7 @@ string_count(PyStringObject *self, PyObject *args)
m = last + 1 - n;
if (n == 0)
return PyInt_FromLong((long) (m-i));
return PyInt_FromSsize_t(m-i);
r = 0;
while (i < m) {
@ -2191,7 +2191,7 @@ string_count(PyStringObject *self, PyObject *args)
break;
i = t - s;
}
return PyInt_FromLong((long) r);
return PyInt_FromSsize_t(r);
}
PyDoc_STRVAR(swapcase__doc__,
@ -2204,7 +2204,7 @@ static PyObject *
string_swapcase(PyStringObject *self)
{
char *s = PyString_AS_STRING(self), *s_new;
int i, n = PyString_GET_SIZE(self);
Py_ssize_t i, n = PyString_GET_SIZE(self);
PyObject *new;
new = PyString_FromStringAndSize(NULL, n);
@ -2240,10 +2240,10 @@ string_translate(PyStringObject *self, PyObject *args)
{
register char *input, *output;
register const char *table;
register int i, c, changed = 0;
register Py_ssize_t i, c, changed = 0;
PyObject *input_obj = (PyObject*)self;
const char *table1, *output_start, *del_table=NULL;
int inlen, tablen, dellen = 0;
Py_ssize_t inlen, tablen, dellen = 0;
PyObject *result;
int trans_table[256];
PyObject *tableobj, *delobj = NULL;
@ -2357,10 +2357,10 @@ string_translate(PyStringObject *self, PyObject *args)
found, or -1 if not found. If len of PAT is greater than length of
MEM, the function returns -1.
*/
static int
mymemfind(const char *mem, int len, const char *pat, int pat_len)
static Py_ssize_t
mymemfind(const char *mem, Py_ssize_t len, const char *pat, Py_ssize_t pat_len)
{
register int ii;
register Py_ssize_t ii;
/* pattern can not occur in the last pat_len-1 chars */
len -= pat_len;
@ -2380,11 +2380,11 @@ mymemfind(const char *mem, int len, const char *pat, int pat_len)
meaning mem=1111 and pat==11 returns 2.
mem=11111 and pat==11 also return 2.
*/
static int
mymemcnt(const char *mem, int len, const char *pat, int pat_len)
static Py_ssize_t
mymemcnt(const char *mem, Py_ssize_t len, const char *pat, Py_ssize_t pat_len)
{
register int offset = 0;
int nfound = 0;
register Py_ssize_t offset = 0;
Py_ssize_t nfound = 0;
while (len >= 0) {
offset = mymemfind(mem, len, pat, pat_len);
@ -2417,15 +2417,15 @@ mymemcnt(const char *mem, int len, const char *pat, int pat_len)
NULL if an error occurred.
*/
static char *
mymemreplace(const char *str, int len, /* input string */
const char *pat, int pat_len, /* pattern string to find */
const char *sub, int sub_len, /* substitution string */
int count, /* number of replacements */
int *out_len)
mymemreplace(const char *str, Py_ssize_t len, /* input string */
const char *pat, Py_ssize_t pat_len, /* pattern string to find */
const char *sub, Py_ssize_t sub_len, /* substitution string */
Py_ssize_t count, /* number of replacements */
Py_ssize_t *out_len)
{
char *out_s;
char *new_s;
int nfound, offset, new_len;
Py_ssize_t nfound, offset, new_len;
if (len == 0 || (pat_len == 0 && sub_len == 0) || pat_len > len)
goto return_same;
@ -2508,8 +2508,8 @@ string_replace(PyStringObject *self, PyObject *args)
{
const char *str = PyString_AS_STRING(self), *sub, *repl;
char *new_s;
const int len = PyString_GET_SIZE(self);
int sub_len, repl_len, out_len;
const Py_ssize_t len = PyString_GET_SIZE(self);
Py_ssize_t sub_len, repl_len, out_len;
int count = -1;
PyObject *new;
PyObject *subobj, *replobj;
@ -2578,11 +2578,11 @@ static PyObject *
string_startswith(PyStringObject *self, PyObject *args)
{
const char* str = PyString_AS_STRING(self);
int len = PyString_GET_SIZE(self);
Py_ssize_t len = PyString_GET_SIZE(self);
const char* prefix;
int plen;
int start = 0;
int end = INT_MAX;
Py_ssize_t plen;
Py_ssize_t start = 0;
Py_ssize_t end = INT_MAX;
PyObject *subobj;
if (!PyArg_ParseTuple(args, "O|O&O&:startswith", &subobj,
@ -2594,7 +2594,7 @@ string_startswith(PyStringObject *self, PyObject *args)
}
#ifdef Py_USING_UNICODE
else if (PyUnicode_Check(subobj)) {
int rc;
Py_ssize_t rc;
rc = PyUnicode_Tailmatch((PyObject *)self,
subobj, start, end, -1);
if (rc == -1)
@ -2629,11 +2629,11 @@ static PyObject *
string_endswith(PyStringObject *self, PyObject *args)
{
const char* str = PyString_AS_STRING(self);
int len = PyString_GET_SIZE(self);
Py_ssize_t len = PyString_GET_SIZE(self);
const char* suffix;
int slen;
int start = 0;
int end = INT_MAX;
Py_ssize_t slen;
Py_ssize_t start = 0;
Py_ssize_t end = INT_MAX;
PyObject *subobj;
if (!PyArg_ParseTuple(args, "O|O&O&:endswith", &subobj,
@ -2645,7 +2645,7 @@ string_endswith(PyStringObject *self, PyObject *args)
}
#ifdef Py_USING_UNICODE
else if (PyUnicode_Check(subobj)) {
int rc;
Py_ssize_t rc;
rc = PyUnicode_Tailmatch((PyObject *)self,
subobj, start, end, +1);
if (rc == -1)
@ -2756,7 +2756,7 @@ string_expandtabs(PyStringObject *self, PyObject *args)
{
const char *e, *p;
char *q;
int i, j;
Py_ssize_t i, j;
PyObject *u;
int tabsize = 8;
@ -2807,7 +2807,7 @@ string_expandtabs(PyStringObject *self, PyObject *args)
}
static PyObject *
pad(PyStringObject *self, int left, int right, char fill)
pad(PyStringObject *self, Py_ssize_t left, Py_ssize_t right, char fill)
{
PyObject *u;
@ -2894,11 +2894,11 @@ PyDoc_STRVAR(center__doc__,
static PyObject *
string_center(PyStringObject *self, PyObject *args)
{
int marg, left;
int width;
Py_ssize_t marg, left;
long width;
char fillchar = ' ';
if (!PyArg_ParseTuple(args, "i|c:center", &width, &fillchar))
if (!PyArg_ParseTuple(args, "l|c:center", &width, &fillchar))
return NULL;
if (PyString_GET_SIZE(self) >= width && PyString_CheckExact(self)) {
@ -2921,12 +2921,12 @@ PyDoc_STRVAR(zfill__doc__,
static PyObject *
string_zfill(PyStringObject *self, PyObject *args)
{
int fill;
long fill;
PyObject *s;
char *p;
int width;
if (!PyArg_ParseTuple(args, "i:zfill", &width))
if (!PyArg_ParseTuple(args, "l:zfill", &width))
return NULL;
if (PyString_GET_SIZE(self) >= width) {
@ -3209,9 +3209,9 @@ is given and true.");
static PyObject*
string_splitlines(PyStringObject *self, PyObject *args)
{
register int i;
register int j;
int len;
register Py_ssize_t i;
register Py_ssize_t j;
Py_ssize_t len;
int keepends = 0;
PyObject *list;
PyObject *str;
@ -3228,7 +3228,7 @@ string_splitlines(PyStringObject *self, PyObject *args)
goto onError;
for (i = j = 0; i < len; ) {
int eol;
Py_ssize_t eol;
/* Find a line and append it */
while (i < len && data[i] != '\n' && data[i] != '\r')
@ -3340,7 +3340,7 @@ static PyObject *
str_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
PyObject *tmp, *pnew;
int n;
Py_ssize_t n;
assert(PyType_IsSubtype(type, &PyString_Type));
tmp = string_new(&PyString_Type, args, kwds);
@ -3521,7 +3521,7 @@ PyString_ConcatAndDel(register PyObject **pv, register PyObject *w)
*/
int
_PyString_Resize(PyObject **pv, int newsize)
_PyString_Resize(PyObject **pv, Py_ssize_t newsize)
{
register PyObject *v;
register PyStringObject *sv;
@ -3625,7 +3625,7 @@ formatfloat(char *buf, size_t buflen, int flags,
(flags&F_ALT) ? "#" : "",
prec, type);
PyOS_ascii_formatd(buf, buflen, fmt, x);
return strlen(buf);
return (int)strlen(buf);
}
/* _PyString_FormatLong emulates the format codes d, u, o, x and X, and
@ -3655,7 +3655,7 @@ _PyString_FormatLong(PyObject *val, int flags, int prec, int type,
{
PyObject *result = NULL;
char *buf;
int i;
Py_ssize_t i;
int sign; /* 1 if '-', else 0 */
int len; /* number of characters */
int numdigits; /* len == numnondigits + numdigits */
@ -3832,7 +3832,7 @@ formatint(char *buf, size_t buflen, int flags,
PyOS_snprintf(buf, buflen, fmt, -x);
else
PyOS_snprintf(buf, buflen, fmt, x);
return strlen(buf);
return (int)strlen(buf);
}
static int
@ -3865,7 +3865,8 @@ PyObject *
PyString_Format(PyObject *format, PyObject *args)
{
char *fmt, *res;
int fmtcnt, rescnt, reslen, arglen, argidx;
int arglen, argidx;
Py_ssize_t reslen, rescnt, fmtcnt;
int args_owned = 0;
PyObject *result, *orig_args;
#ifdef Py_USING_UNICODE
@ -3911,7 +3912,7 @@ PyString_Format(PyObject *format, PyObject *args)
else {
/* Got a format specifier */
int flags = 0;
int width = -1;
Py_ssize_t width = -1;
int prec = -1;
int c = '\0';
int fill;
@ -3930,7 +3931,7 @@ PyString_Format(PyObject *format, PyObject *args)
fmt++;
if (*fmt == '(') {
char *keystart;
int keylen;
Py_ssize_t keylen;
PyObject *key;
int pcount = 1;
@ -4393,7 +4394,7 @@ void _Py_ReleaseInternedStrings(void)
{
PyObject *keys;
PyStringObject *s;
int i, n;
Py_ssize_t i, n;
if (interned == NULL || !PyDict_Check(interned))
return;

View File

@ -40,7 +40,7 @@ PyStructSequence_New(PyTypeObject *type)
static void
structseq_dealloc(PyStructSequence *obj)
{
int i, size;
Py_ssize_t i, size;
size = REAL_SIZE(obj);
for (i = 0; i < size; ++i) {
@ -49,14 +49,14 @@ structseq_dealloc(PyStructSequence *obj)
PyObject_Del(obj);
}
static int
static Py_ssize_t
structseq_length(PyStructSequence *obj)
{
return VISIBLE_SIZE(obj);
}
static PyObject*
structseq_item(PyStructSequence *obj, int i)
structseq_item(PyStructSequence *obj, Py_ssize_t i)
{
if (i < 0 || i >= VISIBLE_SIZE(obj)) {
PyErr_SetString(PyExc_IndexError, "tuple index out of range");
@ -67,10 +67,10 @@ structseq_item(PyStructSequence *obj, int i)
}
static PyObject*
structseq_slice(PyStructSequence *obj, int low, int high)
structseq_slice(PyStructSequence *obj, Py_ssize_t low, Py_ssize_t high)
{
PyTupleObject *np;
int i;
Py_ssize_t i;
if (low < 0)
low = 0;
@ -96,7 +96,7 @@ structseq_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *dict = NULL;
PyObject *ob;
PyStructSequence *res = NULL;
int len, min_len, max_len, i, n_unnamed_fields;
Py_ssize_t len, min_len, max_len, i, n_unnamed_fields;
static const char *kwlist[] = {"sequence", "dict", 0};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|O:structseq",
@ -125,7 +125,7 @@ structseq_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (min_len != max_len) {
if (len < min_len) {
PyErr_Format(PyExc_TypeError,
"%.500s() takes an at least %d-sequence (%d-sequence given)",
"%.500s() takes an at least %ld-sequence (%ld-sequence given)",
type->tp_name, min_len, len);
Py_DECREF(arg);
return NULL;
@ -133,7 +133,7 @@ structseq_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (len > max_len) {
PyErr_Format(PyExc_TypeError,
"%.500s() takes an at most %d-sequence (%d-sequence given)",
"%.500s() takes an at most %ld-sequence (%ld-sequence given)",
type->tp_name, max_len, len);
Py_DECREF(arg);
return NULL;
@ -142,7 +142,7 @@ structseq_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
else {
if (len != min_len) {
PyErr_Format(PyExc_TypeError,
"%.500s() takes a %d-sequence (%d-sequence given)",
"%.500s() takes a %ld-sequence (%ld-sequence given)",
type->tp_name, min_len, len);
Py_DECREF(arg);
return NULL;
@ -200,7 +200,7 @@ structseq_concat(PyStructSequence *obj, PyObject *b)
}
static PyObject *
structseq_repeat(PyStructSequence *obj, int n)
structseq_repeat(PyStructSequence *obj, Py_ssize_t n)
{
PyObject *tup, *result;
tup = make_tuple(obj);
@ -284,11 +284,11 @@ structseq_reduce(PyStructSequence* self)
}
static PySequenceMethods structseq_as_sequence = {
(inquiry)structseq_length,
(lenfunc)structseq_length,
(binaryfunc)structseq_concat, /* sq_concat */
(intargfunc)structseq_repeat, /* sq_repeat */
(intargfunc)structseq_item, /* sq_item */
(intintargfunc)structseq_slice, /* sq_slice */
(ssizeargfunc)structseq_repeat, /* sq_repeat */
(ssizeargfunc)structseq_item, /* sq_item */
(ssizessizeargfunc)structseq_slice, /* sq_slice */
0, /* sq_ass_item */
0, /* sq_ass_slice */
(objobjproc)structseq_contains, /* sq_contains */

View File

@ -24,10 +24,10 @@ int tuple_zero_allocs;
#endif
PyObject *
PyTuple_New(register int size)
PyTuple_New(register Py_ssize_t size)
{
register PyTupleObject *op;
int i;
Py_ssize_t i;
if (size < 0) {
PyErr_BadInternalCall();
return NULL;
@ -57,7 +57,7 @@ PyTuple_New(register int size)
else
#endif
{
int nbytes = size * sizeof(PyObject *);
Py_ssize_t nbytes = size * sizeof(PyObject *);
/* Check for overflow */
if (nbytes / sizeof(PyObject *) != (size_t)size ||
(nbytes += sizeof(PyTupleObject) - sizeof(PyObject *))
@ -82,7 +82,7 @@ PyTuple_New(register int size)
return (PyObject *) op;
}
int
Py_ssize_t
PyTuple_Size(register PyObject *op)
{
if (!PyTuple_Check(op)) {
@ -94,7 +94,7 @@ PyTuple_Size(register PyObject *op)
}
PyObject *
PyTuple_GetItem(register PyObject *op, register int i)
PyTuple_GetItem(register PyObject *op, register Py_ssize_t i)
{
if (!PyTuple_Check(op)) {
PyErr_BadInternalCall();
@ -108,7 +108,7 @@ PyTuple_GetItem(register PyObject *op, register int i)
}
int
PyTuple_SetItem(register PyObject *op, register int i, PyObject *newitem)
PyTuple_SetItem(register PyObject *op, register Py_ssize_t i, PyObject *newitem)
{
register PyObject *olditem;
register PyObject **p;
@ -131,9 +131,9 @@ PyTuple_SetItem(register PyObject *op, register int i, PyObject *newitem)
}
PyObject *
PyTuple_Pack(int n, ...)
PyTuple_Pack(Py_ssize_t n, ...)
{
int i;
Py_ssize_t i;
PyObject *o;
PyObject *result;
PyObject **items;
@ -159,8 +159,8 @@ PyTuple_Pack(int n, ...)
static void
tupledealloc(register PyTupleObject *op)
{
register int i;
register int len = op->ob_size;
register Py_ssize_t i;
register Py_ssize_t len = op->ob_size;
PyObject_GC_UnTrack(op);
Py_TRASHCAN_SAFE_BEGIN(op)
if (len > 0) {
@ -187,7 +187,7 @@ done:
static int
tupleprint(PyTupleObject *op, FILE *fp, int flags)
{
int i;
Py_ssize_t i;
fprintf(fp, "(");
for (i = 0; i < op->ob_size; i++) {
if (i > 0)
@ -204,7 +204,7 @@ tupleprint(PyTupleObject *op, FILE *fp, int flags)
static PyObject *
tuplerepr(PyTupleObject *v)
{
int i, n;
Py_ssize_t i, n;
PyObject *s, *temp;
PyObject *pieces, *result = NULL;
@ -268,7 +268,7 @@ static long
tuplehash(PyTupleObject *v)
{
register long x, y;
register int len = v->ob_size;
register Py_ssize_t len = v->ob_size;
register PyObject **p;
long mult = 1000003L;
x = 0x345678L;
@ -286,7 +286,7 @@ tuplehash(PyTupleObject *v)
return x;
}
static int
static Py_ssize_t
tuplelength(PyTupleObject *a)
{
return a->ob_size;
@ -295,7 +295,8 @@ tuplelength(PyTupleObject *a)
static int
tuplecontains(PyTupleObject *a, PyObject *el)
{
int i, cmp;
Py_ssize_t i;
int cmp;
for (i = 0, cmp = 0 ; cmp == 0 && i < a->ob_size; ++i)
cmp = PyObject_RichCompareBool(el, PyTuple_GET_ITEM(a, i),
@ -304,7 +305,7 @@ tuplecontains(PyTupleObject *a, PyObject *el)
}
static PyObject *
tupleitem(register PyTupleObject *a, register int i)
tupleitem(register PyTupleObject *a, register Py_ssize_t i)
{
if (i < 0 || i >= a->ob_size) {
PyErr_SetString(PyExc_IndexError, "tuple index out of range");
@ -315,12 +316,13 @@ tupleitem(register PyTupleObject *a, register int i)
}
static PyObject *
tupleslice(register PyTupleObject *a, register int ilow, register int ihigh)
tupleslice(register PyTupleObject *a, register Py_ssize_t ilow,
register Py_ssize_t ihigh)
{
register PyTupleObject *np;
PyObject **src, **dest;
register int i;
int len;
register Py_ssize_t i;
Py_ssize_t len;
if (ilow < 0)
ilow = 0;
if (ihigh > a->ob_size)
@ -346,7 +348,7 @@ tupleslice(register PyTupleObject *a, register int ilow, register int ihigh)
}
PyObject *
PyTuple_GetSlice(PyObject *op, int i, int j)
PyTuple_GetSlice(PyObject *op, Py_ssize_t i, Py_ssize_t j)
{
if (op == NULL || !PyTuple_Check(op)) {
PyErr_BadInternalCall();
@ -358,8 +360,8 @@ PyTuple_GetSlice(PyObject *op, int i, int j)
static PyObject *
tupleconcat(register PyTupleObject *a, register PyObject *bb)
{
register int size;
register int i;
register Py_ssize_t size;
register Py_ssize_t i;
PyObject **src, **dest;
PyTupleObject *np;
if (!PyTuple_Check(bb)) {
@ -395,10 +397,10 @@ tupleconcat(register PyTupleObject *a, register PyObject *bb)
}
static PyObject *
tuplerepeat(PyTupleObject *a, int n)
tuplerepeat(PyTupleObject *a, Py_ssize_t n)
{
int i, j;
int size;
Py_ssize_t i, j;
Py_ssize_t size;
PyTupleObject *np;
PyObject **p, **items;
if (n < 0)
@ -434,13 +436,13 @@ tuplerepeat(PyTupleObject *a, int n)
static int
tupletraverse(PyTupleObject *o, visitproc visit, void *arg)
{
int i, err;
Py_ssize_t i;
PyObject *x;
for (i = o->ob_size; --i >= 0; ) {
x = o->ob_item[i];
if (x != NULL) {
err = visit(x, arg);
int err = visit(x, arg);
if (err)
return err;
}
@ -452,8 +454,8 @@ static PyObject *
tuplerichcompare(PyObject *v, PyObject *w, int op)
{
PyTupleObject *vt, *wt;
int i;
int vlen, wlen;
Py_ssize_t i;
Py_ssize_t vlen, wlen;
if (!PyTuple_Check(v) || !PyTuple_Check(w)) {
Py_INCREF(Py_NotImplemented);
@ -545,7 +547,7 @@ static PyObject *
tuple_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
PyObject *tmp, *new, *item;
int i, n;
Py_ssize_t i, n;
assert(PyType_IsSubtype(type, &PyTuple_Type));
tmp = tuple_new(&PyTuple_Type, args, kwds);
@ -571,11 +573,11 @@ PyDoc_STRVAR(tuple_doc,
"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 */
(intargfunc)tuplerepeat, /* sq_repeat */
(intargfunc)tupleitem, /* sq_item */
(intintargfunc)tupleslice, /* sq_slice */
(ssizeargfunc)tuplerepeat, /* sq_repeat */
(ssizeargfunc)tupleitem, /* sq_item */
(ssizessizeargfunc)tupleslice, /* sq_slice */
0, /* sq_ass_item */
0, /* sq_ass_slice */
(objobjproc)tuplecontains, /* sq_contains */
@ -584,14 +586,8 @@ static PySequenceMethods tuple_as_sequence = {
static PyObject*
tuplesubscript(PyTupleObject* self, PyObject* item)
{
if (PyInt_Check(item)) {
long i = PyInt_AS_LONG(item);
if (i < 0)
i += PyTuple_GET_SIZE(self);
return tupleitem(self, i);
}
else if (PyLong_Check(item)) {
long i = PyLong_AsLong(item);
if (PyInt_Check(item) || PyLong_Check(item)) {
Py_ssize_t i = PyInt_AsSsize_t(item);
if (i == -1 && PyErr_Occurred())
return NULL;
if (i < 0)
@ -599,7 +595,7 @@ tuplesubscript(PyTupleObject* self, PyObject* item)
return tupleitem(self, i);
}
else if (PySlice_Check(item)) {
int start, stop, step, slicelength, cur, i;
Py_ssize_t start, stop, step, slicelength, cur, i;
PyObject* result;
PyObject* it;
PyObject **src, **dest;
@ -648,7 +644,7 @@ static PyMethodDef tuple_methods[] = {
};
static PyMappingMethods tuple_as_mapping = {
(inquiry)tuplelength,
(lenfunc)tuplelength,
(binaryfunc)tuplesubscript,
0
};
@ -707,12 +703,12 @@ PyTypeObject PyTuple_Type = {
known to some other part of the code. */
int
_PyTuple_Resize(PyObject **pv, int newsize)
_PyTuple_Resize(PyObject **pv, Py_ssize_t newsize)
{
register PyTupleObject *v;
register PyTupleObject *sv;
int i;
int oldsize;
Py_ssize_t i;
Py_ssize_t oldsize;
v = (PyTupleObject *) *pv;
if (v == NULL || v->ob_type != &PyTuple_Type ||
@ -854,7 +850,7 @@ tupleiter_next(tupleiterobject *it)
static PyObject *
tupleiter_len(tupleiterobject *it)
{
int len = 0;
long len = 0;
if (it->it_seq)
len = PyTuple_GET_SIZE(it->it_seq) - it->it_index;
return PyInt_FromLong(len);

View File

@ -145,7 +145,7 @@ mro_subclasses(PyTypeObject *type, PyObject* temp)
{
PyTypeObject *subclass;
PyObject *ref, *subclasses, *old_mro;
int i, n;
Py_ssize_t i, n;
subclasses = type->tp_subclasses;
if (subclasses == NULL)
@ -184,7 +184,8 @@ mro_subclasses(PyTypeObject *type, PyObject* temp)
static int
type_set_bases(PyTypeObject *type, PyObject *value, void *context)
{
int i, r = 0;
Py_ssize_t i;
int r = 0;
PyObject *ob, *temp;
PyTypeObject *new_base, *old_base;
PyObject *old_bases, *old_mro;
@ -443,7 +444,7 @@ type_call(PyTypeObject *type, PyObject *args, PyObject *kwds)
}
PyObject *
PyType_GenericAlloc(PyTypeObject *type, int nitems)
PyType_GenericAlloc(PyTypeObject *type, Py_ssize_t nitems)
{
PyObject *obj;
const size_t size = _PyObject_VAR_SIZE(type, nitems+1);
@ -483,7 +484,7 @@ PyType_GenericNew(PyTypeObject *type, PyObject *args, PyObject *kwds)
static int
traverse_slots(PyTypeObject *type, PyObject *self, visitproc visit, void *arg)
{
int i, n;
Py_ssize_t i, n;
PyMemberDef *mp;
n = type->ob_size;
@ -548,7 +549,7 @@ subtype_traverse(PyObject *self, visitproc visit, void *arg)
static void
clear_slots(PyTypeObject *type, PyObject *self)
{
int i, n;
Py_ssize_t i, n;
PyMemberDef *mp;
n = type->ob_size;
@ -825,7 +826,7 @@ PyType_IsSubtype(PyTypeObject *a, PyTypeObject *b)
if (mro != NULL) {
/* Deal with multiple inheritance without recursion
by walking the MRO tuple */
int i, n;
Py_ssize_t i, n;
assert(PyTuple_Check(mro));
n = PyTuple_GET_SIZE(mro);
for (i = 0; i < n; i++) {
@ -970,7 +971,7 @@ static int
fill_classic_mro(PyObject *mro, PyObject *cls)
{
PyObject *bases, *base;
int i, n;
Py_ssize_t i, n;
assert(PyList_Check(mro));
assert(PyClass_Check(cls));
@ -1037,7 +1038,7 @@ classic_mro(PyObject *cls)
static int
tail_contains(PyObject *list, int whence, PyObject *o) {
int j, size;
Py_ssize_t j, size;
size = PyList_GET_SIZE(list);
for (j = whence+1; j < size; j++) {
@ -1068,7 +1069,7 @@ class_name(PyObject *cls)
static int
check_duplicates(PyObject *list)
{
int i, j, n;
Py_ssize_t i, j, n;
/* Let's use a quadratic time algorithm,
assuming that the bases lists is short.
*/
@ -1101,7 +1102,7 @@ check_duplicates(PyObject *list)
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();
@ -1136,9 +1137,9 @@ consistent method resolution\norder (MRO) for bases");
static int
pmerge(PyObject *acc, PyObject* to_merge) {
int i, j, to_merge_size;
Py_ssize_t i, j, to_merge_size, empty_cnt;
int *remain;
int ok, empty_cnt;
int ok;
to_merge_size = PyList_GET_SIZE(to_merge);
@ -1206,7 +1207,8 @@ pmerge(PyObject *acc, PyObject* to_merge) {
static PyObject *
mro_implementation(PyTypeObject *type)
{
int i, n, ok;
Py_ssize_t i, n;
int ok;
PyObject *bases, *result;
PyObject *to_merge, *bases_aslist;
@ -1309,7 +1311,7 @@ mro_internal(PyTypeObject *type)
if (tuple == NULL)
return -1;
if (checkit) {
int i, len;
Py_ssize_t i, len;
PyObject *cls;
PyTypeObject *solid;
@ -1350,7 +1352,7 @@ mro_internal(PyTypeObject *type)
static PyTypeObject *
best_base(PyObject *bases)
{
int i, n;
Py_ssize_t i, n;
PyTypeObject *base, *winner, *candidate, *base_i;
PyObject *base_proto;
@ -1532,7 +1534,7 @@ static int
valid_identifier(PyObject *s)
{
unsigned char *p;
int i, n;
Py_ssize_t i, n;
if (!PyString_Check(s)) {
PyErr_SetString(PyExc_TypeError,
@ -1564,7 +1566,7 @@ _unicode_to_string(PyObject *slots, int nslots)
PyObject *tmp = slots;
PyObject *o, *o1;
int i;
intintargfunc copy = slots->ob_type->tp_as_sequence->sq_slice;
ssizessizeargfunc copy = slots->ob_type->tp_as_sequence->sq_slice;
for (i = 0; i < nslots; i++) {
if (PyUnicode_Check(o = PyTuple_GET_ITEM(tmp, i))) {
if (tmp == slots) {
@ -1596,7 +1598,7 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
PyTypeObject *type, *base, *tmptype, *winner;
PyHeapTypeObject *et;
PyMemberDef *mp;
int i, nbases, nslots, slotoffset, add_dict, add_weak;
Py_ssize_t i, nbases, nslots, slotoffset, add_dict, add_weak;
int j, may_add_dict, may_add_weak;
assert(args != NULL && PyTuple_Check(args));
@ -1604,8 +1606,8 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
/* Special case: type(x) should return x->ob_type */
{
const int nargs = PyTuple_GET_SIZE(args);
const int nkwds = kwds == NULL ? 0 : PyDict_Size(kwds);
const Py_ssize_t nargs = PyTuple_GET_SIZE(args);
const Py_ssize_t nkwds = kwds == NULL ? 0 : PyDict_Size(kwds);
if (PyType_CheckExact(metatype) && nargs == 1 && nkwds == 0) {
PyObject *x = PyTuple_GET_ITEM(args, 0);
@ -1999,7 +2001,7 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
PyObject *
_PyType_Lookup(PyTypeObject *type, PyObject *name)
{
int i, n;
Py_ssize_t i, n;
PyObject *mro, *res, *base, *dict;
/* Look in tp_dict of types in MRO */
@ -2154,7 +2156,7 @@ static PyObject *
type_subclasses(PyTypeObject *type, PyObject *args_ignored)
{
PyObject *list, *raw, *ref;
int i, n;
Py_ssize_t i, n;
list = PyList_New(0);
if (list == NULL)
@ -2587,7 +2589,7 @@ reduce_2(PyObject *obj)
PyObject *getstate = NULL, *state = NULL, *names = NULL;
PyObject *slots = NULL, *listitems = NULL, *dictitems = NULL;
PyObject *copy_reg = NULL, *newobj = NULL, *res = NULL;
int i, n;
Py_ssize_t i, n;
cls = PyObject_GetAttrString(obj, "__class__");
if (cls == NULL)
@ -3155,7 +3157,7 @@ PyType_Ready(PyTypeObject *type)
{
PyObject *dict, *bases;
PyTypeObject *base;
int i, n;
Py_ssize_t i, n;
if (type->tp_flags & Py_TPFLAGS_READY) {
assert(type->tp_dict != NULL);
@ -3340,7 +3342,7 @@ add_subclass(PyTypeObject *base, PyTypeObject *type)
static void
remove_subclass(PyTypeObject *base, PyTypeObject *type)
{
int i;
Py_ssize_t i;
PyObject *list, *ref;
list = base->tp_subclasses;
@ -3370,9 +3372,10 @@ check_num_args(PyObject *ob, int n)
}
if (n == PyTuple_GET_SIZE(ob))
return 1;
/* XXX %zd? */
PyErr_Format(
PyExc_TypeError,
"expected %d arguments, got %d", n, PyTuple_GET_SIZE(ob));
"expected %d arguments, got %d", n, (int)PyTuple_GET_SIZE(ob));
return 0;
}
@ -3385,10 +3388,10 @@ check_num_args(PyObject *ob, int n)
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;
@ -3525,28 +3528,28 @@ wrap_unaryfunc(PyObject *self, PyObject *args, void *wrapped)
}
static PyObject *
wrap_intargfunc(PyObject *self, PyObject *args, void *wrapped)
wrap_ssizeargfunc(PyObject *self, PyObject *args, void *wrapped)
{
intargfunc func = (intargfunc)wrapped;
int i;
ssizeargfunc func = (ssizeargfunc)wrapped;
Py_ssize_t i;
if (!PyArg_ParseTuple(args, "i", &i))
if (!PyArg_ParseTuple(args, "n", &i))
return NULL;
return (*func)(self, i);
}
static int
static Py_ssize_t
getindex(PyObject *self, PyObject *arg)
{
int i;
Py_ssize_t i;
i = PyInt_AsLong(arg);
i = PyInt_AsSsize_t(arg);
if (i == -1 && PyErr_Occurred())
return -1;
if (i < 0) {
PySequenceMethods *sq = self->ob_type->tp_as_sequence;
if (sq && sq->sq_length) {
int n = (*sq->sq_length)(self);
Py_ssize_t n = (*sq->sq_length)(self);
if (n < 0)
return -1;
i += n;
@ -3558,9 +3561,9 @@ getindex(PyObject *self, PyObject *arg)
static PyObject *
wrap_sq_item(PyObject *self, PyObject *args, void *wrapped)
{
intargfunc func = (intargfunc)wrapped;
ssizeargfunc func = (ssizeargfunc)wrapped;
PyObject *arg;
int i;
Py_ssize_t i;
if (PyTuple_GET_SIZE(args) == 1) {
arg = PyTuple_GET_ITEM(args, 0);
@ -3575,12 +3578,12 @@ wrap_sq_item(PyObject *self, PyObject *args, void *wrapped)
}
static PyObject *
wrap_intintargfunc(PyObject *self, PyObject *args, void *wrapped)
wrap_ssizessizeargfunc(PyObject *self, PyObject *args, void *wrapped)
{
intintargfunc func = (intintargfunc)wrapped;
int i, j;
ssizessizeargfunc func = (ssizessizeargfunc)wrapped;
Py_ssize_t i, j;
if (!PyArg_ParseTuple(args, "ii", &i, &j))
if (!PyArg_ParseTuple(args, "nn", &i, &j))
return NULL;
return (*func)(self, i, j);
}
@ -3588,8 +3591,9 @@ wrap_intintargfunc(PyObject *self, PyObject *args, void *wrapped)
static PyObject *
wrap_sq_setitem(PyObject *self, PyObject *args, void *wrapped)
{
intobjargproc func = (intobjargproc)wrapped;
int i, res;
ssizeobjargproc func = (ssizeobjargproc)wrapped;
Py_ssize_t i;
int res;
PyObject *arg, *value;
if (!PyArg_UnpackTuple(args, "", 2, 2, &arg, &value))
@ -3607,8 +3611,9 @@ wrap_sq_setitem(PyObject *self, PyObject *args, void *wrapped)
static PyObject *
wrap_sq_delitem(PyObject *self, PyObject *args, void *wrapped)
{
intobjargproc func = (intobjargproc)wrapped;
int i, res;
ssizeobjargproc func = (ssizeobjargproc)wrapped;
Py_ssize_t i;
int res;
PyObject *arg;
if (!check_num_args(args, 1))
@ -3625,13 +3630,14 @@ wrap_sq_delitem(PyObject *self, PyObject *args, void *wrapped)
}
static PyObject *
wrap_intintobjargproc(PyObject *self, PyObject *args, void *wrapped)
wrap_ssizessizeobjargproc(PyObject *self, PyObject *args, void *wrapped)
{
intintobjargproc func = (intintobjargproc)wrapped;
int i, j, res;
ssizessizeobjargproc func = (ssizessizeobjargproc)wrapped;
Py_ssize_t i, j;
int res;
PyObject *value;
if (!PyArg_ParseTuple(args, "iiO", &i, &j, &value))
if (!PyArg_ParseTuple(args, "nnO", &i, &j, &value))
return NULL;
res = (*func)(self, i, j, value);
if (res == -1 && PyErr_Occurred())
@ -3643,10 +3649,11 @@ wrap_intintobjargproc(PyObject *self, PyObject *args, void *wrapped)
static PyObject *
wrap_delslice(PyObject *self, PyObject *args, void *wrapped)
{
intintobjargproc func = (intintobjargproc)wrapped;
int i, j, res;
ssizessizeobjargproc func = (ssizessizeobjargproc)wrapped;
Py_ssize_t i, j;
int res;
if (!PyArg_ParseTuple(args, "ii", &i, &j))
if (!PyArg_ParseTuple(args, "nn", &i, &j))
return NULL;
res = (*func)(self, i, j, NULL);
if (res == -1 && PyErr_Occurred())
@ -4099,23 +4106,23 @@ FUNCNAME(PyObject *self, ARG1TYPE arg1, ARG2TYPE arg2) \
"(" 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");
@ -4133,7 +4140,7 @@ slot_sq_length(PyObject *self)
/* Super-optimized version of slot_sq_item.
Other slots could do the same... */
static PyObject *
slot_sq_item(PyObject *self, int i)
slot_sq_item(PyObject *self, Py_ssize_t i)
{
static PyObject *getitem_str;
PyObject *func, *args = NULL, *ival = NULL, *retval = NULL;
@ -4175,10 +4182,10 @@ slot_sq_item(PyObject *self, int i)
return NULL;
}
SLOT2(slot_sq_slice, "__getslice__", int, int, "ii")
SLOT2(slot_sq_slice, "__getslice__", Py_ssize_t, Py_ssize_t, "nn")
static int
slot_sq_ass_item(PyObject *self, int index, PyObject *value)
slot_sq_ass_item(PyObject *self, Py_ssize_t index, PyObject *value)
{
PyObject *res;
static PyObject *delitem_str, *setitem_str;
@ -4196,7 +4203,7 @@ slot_sq_ass_item(PyObject *self, int index, PyObject *value)
}
static int
slot_sq_ass_slice(PyObject *self, int i, int j, PyObject *value)
slot_sq_ass_slice(PyObject *self, Py_ssize_t i, Py_ssize_t j, PyObject *value)
{
PyObject *res;
static PyObject *delslice_str, *setslice_str;
@ -4428,7 +4435,7 @@ half_compare(PyObject *self, PyObject *other)
{
PyObject *func, *args, *res;
static PyObject *cmp_str;
int c;
Py_ssize_t c;
func = lookup_method(self, "__cmp__", &cmp_str);
if (func == NULL) {
@ -4806,7 +4813,7 @@ slot_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject *new_str;
PyObject *func;
PyObject *newargs, *x;
int i, n;
Py_ssize_t i, n;
if (new_str == NULL) {
new_str = PyString_InternFromString("__new__");
@ -4953,7 +4960,7 @@ typedef struct wrapperbase slotdef;
"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
@ -4962,13 +4969,13 @@ static slotdef slotdefs[] = {
test_descr.notimplemented() */
SQSLOT("__add__", sq_concat, NULL, wrap_binaryfunc,
"x.__add__(y) <==> x+y"),
SQSLOT("__mul__", sq_repeat, NULL, wrap_intargfunc,
SQSLOT("__mul__", sq_repeat, NULL, wrap_ssizeargfunc,
"x.__mul__(n) <==> x*n"),
SQSLOT("__rmul__", sq_repeat, NULL, wrap_intargfunc,
SQSLOT("__rmul__", sq_repeat, NULL, wrap_ssizeargfunc,
"x.__rmul__(n) <==> n*x"),
SQSLOT("__getitem__", sq_item, slot_sq_item, wrap_sq_item,
"x.__getitem__(y) <==> x[y]"),
SQSLOT("__getslice__", sq_slice, slot_sq_slice, wrap_intintargfunc,
SQSLOT("__getslice__", sq_slice, slot_sq_slice, wrap_ssizessizeargfunc,
"x.__getslice__(i, j) <==> x[i:j]\n\
\n\
Use of negative indices is not supported."),
@ -4977,7 +4984,7 @@ static slotdef slotdefs[] = {
SQSLOT("__delitem__", sq_ass_item, slot_sq_ass_item, wrap_sq_delitem,
"x.__delitem__(y) <==> del x[y]"),
SQSLOT("__setslice__", sq_ass_slice, slot_sq_ass_slice,
wrap_intintobjargproc,
wrap_ssizessizeobjargproc,
"x.__setslice__(i, j, y) <==> x[i:j]=y\n\
\n\
Use of negative indices is not supported."),
@ -4990,9 +4997,9 @@ static slotdef slotdefs[] = {
SQSLOT("__iadd__", sq_inplace_concat, NULL,
wrap_binaryfunc, "x.__iadd__(y) <==> x+=y"),
SQSLOT("__imul__", sq_inplace_repeat, NULL,
wrap_intargfunc, "x.__imul__(y) <==> x*=y"),
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,
@ -5152,9 +5159,10 @@ static slotdef slotdefs[] = {
proper indirection pointer (as_buffer, etc.); it returns NULL if the
indirection pointer is NULL. */
static void **
slotptr(PyTypeObject *type, int offset)
slotptr(PyTypeObject *type, int ioffset)
{
char *ptr;
long offset = ioffset;
/* Note: this depends on the order of the members of PyHeapTypeObject! */
assert(offset >= 0);
@ -5320,7 +5328,9 @@ slotdef_cmp(const void *aa, const void *bb)
if (c != 0)
return c;
else
return a - b;
/* Cannot use a-b, as this gives off_t,
which may lose precision when converted to int. */
return (a > b) ? 1 : (a < b) ? -1 : 0;
}
/* Initialize the slotdefs table by adding interned string objects for the
@ -5417,7 +5427,7 @@ recurse_down_subclasses(PyTypeObject *type, PyObject *name,
{
PyTypeObject *subclass;
PyObject *ref, *subclasses, *dict;
int i, n;
Py_ssize_t i, n;
subclasses = type->tp_subclasses;
if (subclasses == NULL)
@ -5570,7 +5580,7 @@ super_getattro(PyObject *self, PyObject *name)
PyObject *mro, *res, *tmp, *dict;
PyTypeObject *starttype;
descrgetfunc f;
int i, n;
Py_ssize_t i, n;
starttype = su->obj_type;
mro = starttype->tp_mro;

File diff suppressed because it is too large Load Diff

View File

@ -520,7 +520,7 @@ proxy_dealloc(PyWeakReference *self)
/* sequence slots */
static PyObject *
proxy_slice(PyWeakReference *proxy, int i, int j)
proxy_slice(PyWeakReference *proxy, Py_ssize_t i, Py_ssize_t j)
{
if (!proxy_checkref(proxy))
return NULL;
@ -528,7 +528,7 @@ proxy_slice(PyWeakReference *proxy, int i, int j)
}
static int
proxy_ass_slice(PyWeakReference *proxy, int i, int j, PyObject *value)
proxy_ass_slice(PyWeakReference *proxy, Py_ssize_t i, Py_ssize_t j, PyObject *value)
{
if (!proxy_checkref(proxy))
return -1;
@ -546,7 +546,7 @@ proxy_contains(PyWeakReference *proxy, PyObject *value)
/* mapping slots */
static int
static Py_ssize_t
proxy_length(PyWeakReference *proxy)
{
if (!proxy_checkref(proxy))
@ -625,18 +625,18 @@ static PyNumberMethods proxy_as_number = {
};
static PySequenceMethods proxy_as_sequence = {
(inquiry)proxy_length, /*sq_length*/
(lenfunc)proxy_length, /*sq_length*/
0, /*sq_concat*/
0, /*sq_repeat*/
0, /*sq_item*/
(intintargfunc)proxy_slice, /*sq_slice*/
(ssizessizeargfunc)proxy_slice, /*sq_slice*/
0, /*sq_ass_item*/
(intintobjargproc)proxy_ass_slice, /*sq_ass_slice*/
(ssizessizeobjargproc)proxy_ass_slice, /*sq_ass_slice*/
(objobjproc)proxy_contains, /* sq_contains */
};
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*/
};
@ -886,7 +886,7 @@ PyObject_ClearWeakRefs(PyObject *object)
}
if (*list != NULL) {
PyWeakReference *current = *list;
int count = _PyWeakref_GetWeakrefCount(current);
Py_ssize_t count = _PyWeakref_GetWeakrefCount(current);
int restore_error = PyErr_Occurred() ? 1 : 0;
PyObject *err_type, *err_value, *err_tb;
@ -904,7 +904,7 @@ PyObject_ClearWeakRefs(PyObject *object)
}
else {
PyObject *tuple = PyTuple_New(count * 2);
int i = 0;
Py_ssize_t i = 0;
for (i = 0; i < count; ++i) {
PyWeakReference *next = current->wr_next;

View File

@ -169,7 +169,8 @@ join(char *buffer, char *stuff)
static int
gotlandmark(char *landmark)
{
int n, ok;
int ok;
Py_ssize_t n;
n = strlen(prefix);
join(prefix, landmark);
@ -302,10 +303,11 @@ getpythonregpath(HKEY keyBase, int skipcore)
dataSize--;
}
if (ppPaths[index]) {
int len = _tcslen(ppPaths[index]);
Py_ssize_t len = _tcslen(ppPaths[index]);
_tcsncpy(szCur, ppPaths[index], len);
szCur += len;
dataSize -= len;
assert(dataSize > len);
dataSize -= (int)len;
}
}
if (skipcore)
@ -632,7 +634,7 @@ calculate_path(void)
char lookBuf[MAXPATHLEN+1];
char *look = buf - 1; /* 'buf' is at the end of the buffer */
while (1) {
int nchars;
Py_ssize_t nchars;
char *lookEnd = look;
/* 'look' will end up one character before the
start of the path in question - even if this

View File

@ -18,7 +18,7 @@ extern const char *PyWin_DLLVersionString;
FILE *PyWin_FindRegisteredModule(const char *moduleName,
struct filedescr **ppFileDesc,
char *pathBuf,
int pathLen)
Py_ssize_t pathLen)
{
char *moduleKey;
const char keyPrefix[] = "Software\\Python\\PythonCore\\";
@ -53,13 +53,14 @@ FILE *PyWin_FindRegisteredModule(const char *moduleName,
"Software\\Python\\PythonCore\\%s\\Modules\\%s%s",
PyWin_DLLVersionString, moduleName, debugString);
modNameSize = pathLen;
assert(pathLen < INT_MAX);
modNameSize = (int)pathLen;
regStat = RegQueryValue(keyBase, moduleKey, pathBuf, &modNameSize);
if (regStat != ERROR_SUCCESS) {
/* No user setting - lookup in machine settings */
keyBase = HKEY_LOCAL_MACHINE;
/* be anal - failure may have reset size param */
modNameSize = pathLen;
modNameSize = (int)pathLen;
regStat = RegQueryValue(keyBase, moduleKey,
pathBuf, &modNameSize);

View File

@ -117,6 +117,14 @@ MS_CORE_DLL.
#endif
#endif /* MS_WIN64 */
/* Define like size_t, omitting the "unsigned" */
#ifdef MS_WIN64
typedef __int64 ssize_t;
#else
typedef _W64 int ssize_t;
#endif
#define HAVE_SSIZE_T 1
#if defined(MS_WIN32) && !defined(MS_WIN64)
#ifdef _M_IX86
#define COMPILER _Py_PASTE_VERSION("32 bit (Intel)")
@ -253,6 +261,7 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */
# define SIZEOF_OFF_T 4
# define SIZEOF_FPOS_T 8
# define SIZEOF_HKEY 8
# define SIZEOF_SIZE_T 8
/* configure.in defines HAVE_LARGEFILE_SUPPORT iff HAVE_LONG_LONG,
sizeof(off_t) > sizeof(long), and sizeof(PY_LONG_LONG) >= sizeof(off_t).
On Win64 the second condition is not true, but if fpos_t replaces off_t
@ -267,6 +276,7 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */
# define SIZEOF_OFF_T 4
# define SIZEOF_FPOS_T 8
# define SIZEOF_HKEY 4
# define SIZEOF_SIZE_T 4
#endif
#ifdef _DEBUG

View File

@ -185,8 +185,9 @@ parsetok(struct tok_state *tok, grammar *g, int start, perrdetail *err_ret,
if (tok->lineno <= 1 && tok->done == E_EOF)
err_ret->error = E_EOF;
err_ret->lineno = tok->lineno;
err_ret->offset = tok->cur - tok->buf;
if (tok->buf != NULL) {
assert(tok->cur - tok->buf < INT_MAX);
err_ret->offset = (int)(tok->cur - tok->buf);
size_t len = tok->inp - tok->buf;
err_ret->text = (char *) PyObject_MALLOC(len + 1);
if (err_ret->text != NULL) {

View File

@ -170,7 +170,7 @@ error_ret(struct tok_state *tok) /* XXX */
}
static char *
new_string(const char *s, int len)
new_string(const char *s, Py_ssize_t len)
{
char* result = PyMem_NEW(char, len + 1);
if (result != NULL) {
@ -206,9 +206,9 @@ get_normal_name(char *s) /* for utf-8 and latin-1 */
/* Return the coding spec in S, or NULL if none is found. */
static char *
get_coding_spec(const char *s, int size)
get_coding_spec(const char *s, Py_ssize_t size)
{
int i;
Py_ssize_t i;
/* Coding spec must be in a comment, and that comment must be
* the only statement on the source code line. */
for (i = 0; i < size - 6; i++) {
@ -253,7 +253,7 @@ get_coding_spec(const char *s, int size)
Return 1 on success, 0 on failure. */
static int
check_coding_spec(const char* line, int size, struct tok_state *tok,
check_coding_spec(const char* line, Py_ssize_t size, struct tok_state *tok,
int set_readline(struct tok_state *, const char *))
{
char * cs;
@ -820,7 +820,7 @@ tok_nextc(register struct tok_state *tok)
}
else {
int done = 0;
int cur = 0;
Py_ssize_t cur = 0;
char *pt;
if (tok->start == NULL) {
if (tok->buf == NULL) {
@ -854,10 +854,10 @@ tok_nextc(register struct tok_state *tok)
tok->lineno++;
/* Read until '\n' or EOF */
while (!done) {
int curstart = tok->start == NULL ? -1 :
Py_ssize_t curstart = tok->start == NULL ? -1 :
tok->start - tok->buf;
int curvalid = tok->inp - tok->buf;
int newsize = curvalid + BUFSIZ;
Py_ssize_t curvalid = tok->inp - tok->buf;
Py_ssize_t newsize = curvalid + BUFSIZ;
char *newbuf = tok->buf;
PyMem_RESIZE(newbuf, char, newsize);
if (newbuf == NULL) {
@ -1390,7 +1390,7 @@ tok_get(register struct tok_state *tok, char **p_start, char **p_end)
letter_quote:
/* String */
if (c == '\'' || c == '"') {
int quote2 = tok->cur - tok->start + 1;
Py_ssize_t quote2 = tok->cur - tok->start + 1;
int quote = c;
int triple = 0;
int tripcount = 0;

View File

@ -405,7 +405,7 @@ builtin_compile(PyObject *self, PyObject *args)
int supplied_flags = 0;
PyCompilerFlags cf;
PyObject *result = NULL, *cmd, *tmp = NULL;
int length;
Py_ssize_t length;
if (!PyArg_ParseTuple(args, "Oss|ii:compile", &cmd, &filename,
&startstr, &supplied_flags, &dont_inherit))
@ -824,7 +824,7 @@ builtin_map(PyObject *self, PyObject *args)
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 @@ In the second form, the callable is called until it returns the sentinel.");
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 @@ static PyObject *
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 @@ static PyObject *
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,

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))

View File

@ -460,7 +460,7 @@ PyObject *PyCodec_StrictErrors(PyObject *exc)
#ifdef Py_USING_UNICODE
PyObject *PyCodec_IgnoreErrors(PyObject *exc)
{
int end;
Py_ssize_t end;
if (PyObject_IsInstance(exc, PyExc_UnicodeEncodeError)) {
if (PyUnicodeEncodeError_GetEnd(exc, &end))
return NULL;
@ -478,16 +478,16 @@ PyObject *PyCodec_IgnoreErrors(PyObject *exc)
return NULL;
}
/* ouch: passing NULL, 0, pos gives None instead of u'' */
return Py_BuildValue("(u#i)", &end, 0, end);
return Py_BuildValue("(u#n)", &end, 0, end);
}
PyObject *PyCodec_ReplaceErrors(PyObject *exc)
{
PyObject *restuple;
int start;
int end;
int i;
Py_ssize_t start;
Py_ssize_t end;
Py_ssize_t i;
if (PyObject_IsInstance(exc, PyExc_UnicodeEncodeError)) {
PyObject *res;
@ -502,7 +502,7 @@ PyObject *PyCodec_ReplaceErrors(PyObject *exc)
for (p = PyUnicode_AS_UNICODE(res), i = start;
i<end; ++p, ++i)
*p = '?';
restuple = Py_BuildValue("(Oi)", res, end);
restuple = Py_BuildValue("(On)", res, end);
Py_DECREF(res);
return restuple;
}
@ -510,7 +510,7 @@ PyObject *PyCodec_ReplaceErrors(PyObject *exc)
Py_UNICODE res = Py_UNICODE_REPLACEMENT_CHARACTER;
if (PyUnicodeDecodeError_GetEnd(exc, &end))
return NULL;
return Py_BuildValue("(u#i)", &res, 1, end);
return Py_BuildValue("(u#n)", &res, 1, end);
}
else if (PyObject_IsInstance(exc, PyExc_UnicodeTranslateError)) {
PyObject *res;
@ -525,7 +525,7 @@ PyObject *PyCodec_ReplaceErrors(PyObject *exc)
for (p = PyUnicode_AS_UNICODE(res), i = start;
i<end; ++p, ++i)
*p = Py_UNICODE_REPLACEMENT_CHARACTER;
restuple = Py_BuildValue("(Oi)", res, end);
restuple = Py_BuildValue("(On)", res, end);
Py_DECREF(res);
return restuple;
}
@ -540,8 +540,8 @@ PyObject *PyCodec_XMLCharRefReplaceErrors(PyObject *exc)
if (PyObject_IsInstance(exc, PyExc_UnicodeEncodeError)) {
PyObject *restuple;
PyObject *object;
int start;
int end;
Py_ssize_t start;
Py_ssize_t end;
PyObject *res;
Py_UNICODE *p;
Py_UNICODE *startp;
@ -631,7 +631,7 @@ PyObject *PyCodec_XMLCharRefReplaceErrors(PyObject *exc)
}
*outp++ = ';';
}
restuple = Py_BuildValue("(Oi)", res, end);
restuple = Py_BuildValue("(On)", res, end);
Py_DECREF(res);
Py_DECREF(object);
return restuple;
@ -652,8 +652,8 @@ PyObject *PyCodec_BackslashReplaceErrors(PyObject *exc)
if (PyObject_IsInstance(exc, PyExc_UnicodeEncodeError)) {
PyObject *restuple;
PyObject *object;
int start;
int end;
Py_ssize_t start;
Py_ssize_t end;
PyObject *res;
Py_UNICODE *p;
Py_UNICODE *startp;
@ -708,7 +708,7 @@ PyObject *PyCodec_BackslashReplaceErrors(PyObject *exc)
*outp++ = hexdigits[c&0xf];
}
restuple = Py_BuildValue("(Oi)", res, end);
restuple = Py_BuildValue("(On)", res, end);
Py_DECREF(res);
Py_DECREF(object);
return restuple;

View File

@ -317,7 +317,7 @@ compiler_free(struct compiler *c)
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 @@ list2dict(PyObject *list)
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 @@ static int
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 @@ static int
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 @@ static int
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 @@ markblocks(unsigned char *code, int len)
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 @@ static void
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 @@ static int
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 @@ static PyObject *
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)

View File

@ -910,27 +910,34 @@ static PyMethodDef KeyError_methods[] = {
#ifdef Py_USING_UNICODE
static
int get_int(PyObject *exc, const char *name, int *value)
int get_int(PyObject *exc, const char *name, Py_ssize_t *value)
{
PyObject *attr = PyObject_GetAttrString(exc, (char *)name);
if (!attr)
return -1;
if (!PyInt_Check(attr)) {
if (PyInt_Check(attr)) {
*value = PyInt_AS_LONG(attr);
} else if (PyLong_Check(attr)) {
*value = (size_t)PyLong_AsLongLong(attr);
if (*value == -1) {
Py_DECREF(attr);
return -1;
}
} else {
PyErr_Format(PyExc_TypeError, "%.200s attribute must be int", name);
Py_DECREF(attr);
return -1;
}
*value = PyInt_AS_LONG(attr);
Py_DECREF(attr);
return 0;
}
static
int set_int(PyObject *exc, const char *name, int value)
int set_ssize_t(PyObject *exc, const char *name, Py_ssize_t value)
{
PyObject *obj = PyInt_FromLong(value);
PyObject *obj = PyInt_FromSsize_t(value);
int result;
if (!obj)
@ -940,7 +947,6 @@ int set_int(PyObject *exc, const char *name, int value)
return result;
}
static
PyObject *get_string(PyObject *exc, const char *name)
{
@ -1011,16 +1017,16 @@ PyObject *PyUnicodeTranslateError_GetObject(PyObject *exc)
return get_unicode(exc, "object");
}
int PyUnicodeEncodeError_GetStart(PyObject *exc, int *start)
int PyUnicodeEncodeError_GetStart(PyObject *exc, Py_ssize_t *start)
{
if (!get_int(exc, "start", start)) {
PyObject *object = PyUnicodeEncodeError_GetObject(exc);
int size;
Py_ssize_t size;
if (!object)
return -1;
size = PyUnicode_GET_SIZE(object);
if (*start<0)
*start = 0;
*start = 0; /*XXX check for values <0*/
if (*start>=size)
*start = size-1;
Py_DECREF(object);
@ -1030,11 +1036,11 @@ int PyUnicodeEncodeError_GetStart(PyObject *exc, int *start)
}
int PyUnicodeDecodeError_GetStart(PyObject *exc, int *start)
int PyUnicodeDecodeError_GetStart(PyObject *exc, Py_ssize_t *start)
{
if (!get_int(exc, "start", start)) {
PyObject *object = PyUnicodeDecodeError_GetObject(exc);
int size;
Py_ssize_t size;
if (!object)
return -1;
size = PyString_GET_SIZE(object);
@ -1049,35 +1055,35 @@ int PyUnicodeDecodeError_GetStart(PyObject *exc, int *start)
}
int PyUnicodeTranslateError_GetStart(PyObject *exc, int *start)
int PyUnicodeTranslateError_GetStart(PyObject *exc, Py_ssize_t *start)
{
return PyUnicodeEncodeError_GetStart(exc, start);
}
int PyUnicodeEncodeError_SetStart(PyObject *exc, int start)
int PyUnicodeEncodeError_SetStart(PyObject *exc, Py_ssize_t start)
{
return set_int(exc, "start", start);
return set_ssize_t(exc, "start", start);
}
int PyUnicodeDecodeError_SetStart(PyObject *exc, int start)
int PyUnicodeDecodeError_SetStart(PyObject *exc, Py_ssize_t start)
{
return set_int(exc, "start", start);
return set_ssize_t(exc, "start", start);
}
int PyUnicodeTranslateError_SetStart(PyObject *exc, int start)
int PyUnicodeTranslateError_SetStart(PyObject *exc, Py_ssize_t start)
{
return set_int(exc, "start", start);
return set_ssize_t(exc, "start", start);
}
int PyUnicodeEncodeError_GetEnd(PyObject *exc, int *end)
int PyUnicodeEncodeError_GetEnd(PyObject *exc, Py_ssize_t *end)
{
if (!get_int(exc, "end", end)) {
PyObject *object = PyUnicodeEncodeError_GetObject(exc);
int size;
Py_ssize_t size;
if (!object)
return -1;
size = PyUnicode_GET_SIZE(object);
@ -1092,11 +1098,11 @@ int PyUnicodeEncodeError_GetEnd(PyObject *exc, int *end)
}
int PyUnicodeDecodeError_GetEnd(PyObject *exc, int *end)
int PyUnicodeDecodeError_GetEnd(PyObject *exc, Py_ssize_t *end)
{
if (!get_int(exc, "end", end)) {
PyObject *object = PyUnicodeDecodeError_GetObject(exc);
int size;
Py_ssize_t size;
if (!object)
return -1;
size = PyString_GET_SIZE(object);
@ -1111,27 +1117,27 @@ int PyUnicodeDecodeError_GetEnd(PyObject *exc, int *end)
}
int PyUnicodeTranslateError_GetEnd(PyObject *exc, int *start)
int PyUnicodeTranslateError_GetEnd(PyObject *exc, Py_ssize_t *start)
{
return PyUnicodeEncodeError_GetEnd(exc, start);
}
int PyUnicodeEncodeError_SetEnd(PyObject *exc, int end)
int PyUnicodeEncodeError_SetEnd(PyObject *exc, Py_ssize_t end)
{
return set_int(exc, "end", end);
return set_ssize_t(exc, "end", end);
}
int PyUnicodeDecodeError_SetEnd(PyObject *exc, int end)
int PyUnicodeDecodeError_SetEnd(PyObject *exc, Py_ssize_t end)
{
return set_int(exc, "end", end);
return set_ssize_t(exc, "end", end);
}
int PyUnicodeTranslateError_SetEnd(PyObject *exc, int end)
int PyUnicodeTranslateError_SetEnd(PyObject *exc, Py_ssize_t end)
{
return set_int(exc, "end", end);
return set_ssize_t(exc, "end", end);
}
@ -1229,8 +1235,8 @@ UnicodeEncodeError__str__(PyObject *self, PyObject *arg)
{
PyObject *encodingObj = NULL;
PyObject *objectObj = NULL;
int start;
int end;
Py_ssize_t start;
Py_ssize_t end;
PyObject *reasonObj = NULL;
char buffer[1000];
PyObject *result = NULL;
@ -1270,11 +1276,12 @@ UnicodeEncodeError__str__(PyObject *self, PyObject *arg)
);
}
else {
/* XXX %zd? */
PyOS_snprintf(buffer, sizeof(buffer),
"'%.400s' codec can't encode characters in position %d-%d: %.400s",
PyString_AS_STRING(encodingObj),
start,
end-1,
(int)start,
(int)(end-1),
PyString_AS_STRING(reasonObj)
);
}
@ -1295,10 +1302,10 @@ static PyMethodDef UnicodeEncodeError_methods[] = {
PyObject * PyUnicodeEncodeError_Create(
const char *encoding, const Py_UNICODE *object, int length,
int start, int end, const char *reason)
const char *encoding, const Py_UNICODE *object, Py_ssize_t length,
Py_ssize_t start, Py_ssize_t end, const char *reason)
{
return PyObject_CallFunction(PyExc_UnicodeEncodeError, "su#iis",
return PyObject_CallFunction(PyExc_UnicodeEncodeError, "su#nns",
encoding, object, length, start, end, reason);
}
@ -1314,8 +1321,8 @@ UnicodeDecodeError__str__(PyObject *self, PyObject *arg)
{
PyObject *encodingObj = NULL;
PyObject *objectObj = NULL;
int start;
int end;
Py_ssize_t start;
Py_ssize_t end;
PyObject *reasonObj = NULL;
char buffer[1000];
PyObject *result = NULL;
@ -1338,20 +1345,22 @@ UnicodeDecodeError__str__(PyObject *self, PyObject *arg)
goto error;
if (end==start+1) {
/* XXX %zd? */
PyOS_snprintf(buffer, sizeof(buffer),
"'%.400s' codec can't decode byte 0x%02x in position %d: %.400s",
PyString_AS_STRING(encodingObj),
((int)PyString_AS_STRING(objectObj)[start])&0xff,
start,
(int)start,
PyString_AS_STRING(reasonObj)
);
}
else {
/* XXX %zd? */
PyOS_snprintf(buffer, sizeof(buffer),
"'%.400s' codec can't decode bytes in position %d-%d: %.400s",
PyString_AS_STRING(encodingObj),
start,
end-1,
(int)start,
(int)(end-1),
PyString_AS_STRING(reasonObj)
);
}
@ -1372,11 +1381,14 @@ static PyMethodDef UnicodeDecodeError_methods[] = {
PyObject * PyUnicodeDecodeError_Create(
const char *encoding, const char *object, int length,
int start, int end, const char *reason)
const char *encoding, const char *object, Py_ssize_t length,
Py_ssize_t start, Py_ssize_t end, const char *reason)
{
assert(length < INT_MAX);
assert(start < INT_MAX);
assert(end < INT_MAX);
return PyObject_CallFunction(PyExc_UnicodeDecodeError, "ss#iis",
encoding, object, length, start, end, reason);
encoding, object, (int)length, (int)start, (int)end, reason);
}
@ -1427,8 +1439,8 @@ static PyObject *
UnicodeTranslateError__str__(PyObject *self, PyObject *arg)
{
PyObject *objectObj = NULL;
int start;
int end;
Py_ssize_t start;
Py_ssize_t end;
PyObject *reasonObj = NULL;
char buffer[1000];
PyObject *result = NULL;
@ -1450,6 +1462,7 @@ UnicodeTranslateError__str__(PyObject *self, PyObject *arg)
if (end==start+1) {
int badchar = (int)PyUnicode_AS_UNICODE(objectObj)[start];
char *format;
/* XXX %zd? */
if (badchar <= 0xff)
format = "can't translate character u'\\x%02x' in position %d: %.400s";
else if (badchar <= 0xffff)
@ -1459,15 +1472,16 @@ UnicodeTranslateError__str__(PyObject *self, PyObject *arg)
PyOS_snprintf(buffer, sizeof(buffer),
format,
badchar,
start,
(int)start,
PyString_AS_STRING(reasonObj)
);
}
else {
/* XXX %zd? */
PyOS_snprintf(buffer, sizeof(buffer),
"can't translate characters in position %d-%d: %.400s",
start,
end-1,
(int)start,
(int)(end-1),
PyString_AS_STRING(reasonObj)
);
}
@ -1487,8 +1501,8 @@ static PyMethodDef UnicodeTranslateError_methods[] = {
PyObject * PyUnicodeTranslateError_Create(
const Py_UNICODE *object, int length,
int start, int end, const char *reason)
const Py_UNICODE *object, Py_ssize_t length,
Py_ssize_t start, Py_ssize_t end, const char *reason)
{
return PyObject_CallFunction(PyExc_UnicodeTranslateError, "u#iis",
object, length, start, end, reason);
@ -1749,7 +1763,7 @@ void
_PyExc_Init(void)
{
char *modulename = "exceptions";
int modnamesz = strlen(modulename);
Py_ssize_t modnamesz = strlen(modulename);
int i;
PyObject *me, *mydict, *bltinmod, *bdict, *doc, *args;

View File

@ -15,21 +15,24 @@ int PyArg_ParseTupleAndKeywords(PyObject *, PyObject *,
int PyArg_VaParseTupleAndKeywords(PyObject *, PyObject *,
const char *, const char **, va_list);
#define FLAG_COMPAT 1
#define FLAG_SIZE_T 2
/* Forward */
static int vgetargs1(PyObject *, const char *, va_list *, int);
static void seterror(int, const char *, int *, const char *, const char *);
static char *convertitem(PyObject *, const char **, va_list *, int *, char *,
size_t, PyObject **);
static char *converttuple(PyObject *, const char **, va_list *,
static char *convertitem(PyObject *, const char **, va_list *, int, int *,
char *, size_t, PyObject **);
static char *converttuple(PyObject *, const char **, va_list *, int,
int *, char *, size_t, int, PyObject **);
static char *convertsimple(PyObject *, const char **, va_list *, char *,
static char *convertsimple(PyObject *, const char **, va_list *, int, char *,
size_t, PyObject **);
static int convertbuffer(PyObject *, void **p, char **);
static Py_ssize_t convertbuffer(PyObject *, void **p, char **);
static int vgetargskeywords(PyObject *, PyObject *,
const char *, const char **, va_list *);
static char *skipitem(const char **, va_list *);
const char *, const char **, va_list *, int);
static char *skipitem(const char **, va_list *, int);
int
PyArg_Parse(PyObject *args, const char *format, ...)
@ -38,7 +41,19 @@ PyArg_Parse(PyObject *args, const char *format, ...)
va_list va;
va_start(va, format);
retval = vgetargs1(args, format, &va, 1);
retval = vgetargs1(args, format, &va, FLAG_COMPAT);
va_end(va);
return retval;
}
int
_PyArg_Parse_SizeT(PyObject *args, char *format, ...)
{
int retval;
va_list va;
va_start(va, format);
retval = vgetargs1(args, format, &va, FLAG_COMPAT|FLAG_SIZE_T);
va_end(va);
return retval;
}
@ -56,6 +71,18 @@ PyArg_ParseTuple(PyObject *args, const char *format, ...)
return retval;
}
int
_PyArg_ParseTuple_SizeT(PyObject *args, char *format, ...)
{
int retval;
va_list va;
va_start(va, format);
retval = vgetargs1(args, format, &va, FLAG_SIZE_T);
va_end(va);
return retval;
}
int
PyArg_VaParse(PyObject *args, const char *format, va_list va)
@ -75,6 +102,24 @@ PyArg_VaParse(PyObject *args, const char *format, va_list va)
return vgetargs1(args, format, &lva, 0);
}
int
_PyArg_VaParse_SizeT(PyObject *args, char *format, va_list va)
{
va_list lva;
#ifdef VA_LIST_IS_ARRAY
memcpy(lva, va, sizeof(va_list));
#else
#ifdef __va_copy
__va_copy(lva, va);
#else
lva = va;
#endif
#endif
return vgetargs1(args, format, &lva, FLAG_SIZE_T);
}
/* Handle cleanup of allocated memory in case of exception */
@ -120,7 +165,7 @@ cleanreturn(int retval, PyObject *freelist)
static int
vgetargs1(PyObject *args, const char *format, va_list *p_va, int compat)
vgetargs1(PyObject *args, const char *format, va_list *p_va, int flags)
{
char msgbuf[256];
int levels[32];
@ -134,8 +179,10 @@ vgetargs1(PyObject *args, const char *format, va_list *p_va, int compat)
int i, len;
char *msg;
PyObject *freelist = NULL;
int compat = flags & FLAG_COMPAT;
assert(compat || (args != (PyObject*)NULL));
flags = flags & ~FLAG_COMPAT;
while (endfmt == 0) {
int c = *format++;
@ -204,8 +251,8 @@ vgetargs1(PyObject *args, const char *format, va_list *p_va, int compat)
PyErr_SetString(PyExc_TypeError, msgbuf);
return 0;
}
msg = convertitem(args, &format, p_va, levels, msgbuf,
sizeof(msgbuf), &freelist);
msg = convertitem(args, &format, p_va, flags, levels,
msgbuf, sizeof(msgbuf), &freelist);
if (msg == NULL)
return cleanreturn(1, freelist);
seterror(levels[0], msg, levels+1, fname, message);
@ -248,7 +295,8 @@ vgetargs1(PyObject *args, const char *format, va_list *p_va, int compat)
if (*format == '|')
format++;
msg = convertitem(PyTuple_GET_ITEM(args, i), &format, p_va,
levels, msgbuf, sizeof(msgbuf), &freelist);
flags, levels, msgbuf,
sizeof(msgbuf), &freelist);
if (msg) {
seterror(i+1, msg, levels, fname, message);
return cleanreturn(0, freelist);
@ -325,8 +373,9 @@ seterror(int iarg, const char *msg, int *levels, const char *fname,
*/
static char *
converttuple(PyObject *arg, const char **p_format, va_list *p_va, int *levels,
char *msgbuf, size_t bufsize, int toplevel, PyObject **freelist)
converttuple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
int *levels, char *msgbuf, size_t bufsize, int toplevel,
PyObject **freelist)
{
int level = 0;
int n = 0;
@ -375,8 +424,8 @@ converttuple(PyObject *arg, const char **p_format, va_list *p_va, int *levels,
char *msg;
PyObject *item;
item = PySequence_GetItem(arg, i);
msg = convertitem(item, &format, p_va, levels+1, msgbuf,
bufsize, freelist);
msg = convertitem(item, &format, p_va, flags, levels+1,
msgbuf, bufsize, freelist);
/* PySequence_GetItem calls tp->sq_item, which INCREFs */
Py_XDECREF(item);
if (msg != NULL) {
@ -393,22 +442,22 @@ converttuple(PyObject *arg, const char **p_format, va_list *p_va, int *levels,
/* Convert a single item. */
static char *
convertitem(PyObject *arg, const char **p_format, va_list *p_va, int *levels,
char *msgbuf, size_t bufsize, PyObject **freelist)
convertitem(PyObject *arg, const char **p_format, va_list *p_va, int flags,
int *levels, char *msgbuf, size_t bufsize, PyObject **freelist)
{
char *msg;
const char *format = *p_format;
if (*format == '(' /* ')' */) {
format++;
msg = converttuple(arg, &format, p_va, levels, msgbuf,
msg = converttuple(arg, &format, p_va, flags, levels, msgbuf,
bufsize, 0, freelist);
if (msg == NULL)
format++;
}
else {
msg = convertsimple(arg, &format, p_va, msgbuf, bufsize,
freelist);
msg = convertsimple(arg, &format, p_va, flags,
msgbuf, bufsize, freelist);
if (msg != NULL)
levels[0] = 0;
}
@ -460,9 +509,16 @@ float_argument_error(PyObject *arg)
*/
static char *
convertsimple(PyObject *arg, const char **p_format, va_list *p_va,
convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
char *msgbuf, size_t bufsize, PyObject **freelist)
{
/* For # codes */
#define FETCH_SIZE int *q=NULL;Py_ssize_t *q2=NULL;\
if (flags & FLAG_SIZE_T) q2=va_arg(*p_va, Py_ssize_t*); \
else q=va_arg(*p_va, int*);
#define STORE_SIZE(s) if (flags & FLAG_SIZE_T) *q2=s; else *q=s;
#define BUFFER_LEN ((flags & FLAG_SIZE_T) ? *q2:*q)
const char *format = *p_format;
char c = *format++;
#ifdef Py_USING_UNICODE
@ -582,6 +638,21 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va,
break;
}
case 'n': /* Py_ssize_t */
#if SIZEOF_SIZE_T != SIZEOF_LONG
{
Py_ssize_t *p = va_arg(*p_va, Py_ssize_t *);
Py_ssize_t ival;
if (float_argument_error(arg))
return converterr("integer<i>", arg, msgbuf, bufsize);
ival = PyInt_AsSsize_t(arg);
if (ival == -1 && PyErr_Occurred())
return converterr("integer<i>", arg, msgbuf, bufsize);
*p = ival;
break;
}
#endif
/* Fall through from 'n' to 'l' if Py_ssize_t is int */
case 'l': {/* long int */
long *p = va_arg(*p_va, long *);
long ival;
@ -679,11 +750,11 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va,
case 's': {/* string */
if (*format == '#') {
void **p = (void **)va_arg(*p_va, char **);
int *q = va_arg(*p_va, int *);
FETCH_SIZE;
if (PyString_Check(arg)) {
*p = PyString_AS_STRING(arg);
*q = PyString_GET_SIZE(arg);
STORE_SIZE(PyString_GET_SIZE(arg));
}
#ifdef Py_USING_UNICODE
else if (PyUnicode_Check(arg)) {
@ -692,15 +763,15 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va,
return converterr(CONV_UNICODE,
arg, msgbuf, bufsize);
*p = PyString_AS_STRING(uarg);
*q = PyString_GET_SIZE(uarg);
STORE_SIZE(PyString_GET_SIZE(uarg));
}
#endif
else { /* any buffer-like object */
char *buf;
int count = convertbuffer(arg, p, &buf);
Py_ssize_t count = convertbuffer(arg, p, &buf);
if (count < 0)
return converterr(buf, arg, msgbuf, bufsize);
*q = count;
STORE_SIZE(count);
}
format++;
} else {
@ -729,15 +800,15 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va,
case 'z': {/* string, may be NULL (None) */
if (*format == '#') { /* any buffer-like object */
void **p = (void **)va_arg(*p_va, char **);
int *q = va_arg(*p_va, int *);
FETCH_SIZE;
if (arg == Py_None) {
*p = 0;
*q = 0;
STORE_SIZE(0);
}
else if (PyString_Check(arg)) {
*p = PyString_AS_STRING(arg);
*q = PyString_GET_SIZE(arg);
STORE_SIZE(PyString_GET_SIZE(arg));
}
#ifdef Py_USING_UNICODE
else if (PyUnicode_Check(arg)) {
@ -746,15 +817,15 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va,
return converterr(CONV_UNICODE,
arg, msgbuf, bufsize);
*p = PyString_AS_STRING(uarg);
*q = PyString_GET_SIZE(uarg);
STORE_SIZE(PyString_GET_SIZE(uarg));
}
#endif
else { /* any buffer-like object */
char *buf;
int count = convertbuffer(arg, p, &buf);
Py_ssize_t count = convertbuffer(arg, p, &buf);
if (count < 0)
return converterr(buf, arg, msgbuf, bufsize);
*q = count;
STORE_SIZE(count);
}
format++;
} else {
@ -777,7 +848,8 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va,
return converterr("string or None",
arg, msgbuf, bufsize);
if (*format == '#') {
int *q = va_arg(*p_va, int *);
FETCH_SIZE;
assert(0); // redundant with if-case
if (arg == Py_None)
*q = 0;
else
@ -883,10 +955,10 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va,
trailing 0-byte
*/
int *buffer_len = va_arg(*p_va, int *);
FETCH_SIZE;
format++;
if (buffer_len == NULL) {
if (q == NULL && q2 == NULL) {
Py_DECREF(s);
return converterr(
"(buffer_len is NULL)",
@ -907,7 +979,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va,
arg, msgbuf, bufsize);
}
} else {
if (size + 1 > *buffer_len) {
if (size + 1 > BUFFER_LEN) {
Py_DECREF(s);
return converterr(
"(buffer overflow)",
@ -917,7 +989,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va,
memcpy(*buffer,
PyString_AS_STRING(s),
size + 1);
*buffer_len = size;
STORE_SIZE(size);
} else {
/* Using a 0-terminated buffer:
@ -961,17 +1033,17 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va,
case 'u': {/* raw unicode buffer (Py_UNICODE *) */
if (*format == '#') { /* any buffer-like object */
void **p = (void **)va_arg(*p_va, char **);
int *q = va_arg(*p_va, int *);
FETCH_SIZE;
if (PyUnicode_Check(arg)) {
*p = PyUnicode_AS_UNICODE(arg);
*q = PyUnicode_GET_SIZE(arg);
STORE_SIZE(PyUnicode_GET_SIZE(arg));
}
else {
char *buf;
int count = convertbuffer(arg, p, &buf);
Py_ssize_t count = convertbuffer(arg, p, &buf);
if (count < 0)
return converterr(buf, arg, msgbuf, bufsize);
*q = count/(sizeof(Py_UNICODE));
STORE_SIZE(count/(sizeof(Py_UNICODE)));
}
format++;
} else {
@ -1061,9 +1133,8 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va,
if ((count = pb->bf_getwritebuffer(arg, 0, p)) < 0)
return converterr("(unspecified)", arg, msgbuf, bufsize);
if (*format == '#') {
int *q = va_arg(*p_va, int *);
*q = count;
FETCH_SIZE;
STORE_SIZE(count);
format++;
}
break;
@ -1094,7 +1165,10 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va,
count = pb->bf_getcharbuffer(arg, 0, p);
if (count < 0)
return converterr("(unspecified)", arg, msgbuf, bufsize);
*va_arg(*p_va, int *) = count;
{
FETCH_SIZE;
STORE_SIZE(count);
}
break;
}
@ -1107,11 +1181,11 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va,
return NULL;
}
static int
static Py_ssize_t
convertbuffer(PyObject *arg, void **p, char **errmsg)
{
PyBufferProcs *pb = arg->ob_type->tp_as_buffer;
int count;
Py_ssize_t count;
if (pb == NULL ||
pb->bf_getreadbuffer == NULL ||
pb->bf_getsegcount == NULL) {
@ -1151,7 +1225,32 @@ PyArg_ParseTupleAndKeywords(PyObject *args,
}
va_start(va, kwlist);
retval = vgetargskeywords(args, keywords, format, kwlist, &va);
retval = vgetargskeywords(args, keywords, format, kwlist, &va, 0);
va_end(va);
return retval;
}
int
_PyArg_ParseTupleAndKeywords_SizeT(PyObject *args,
PyObject *keywords,
const char *format,
const char **kwlist, ...)
{
int retval;
va_list va;
if ((args == NULL || !PyTuple_Check(args)) ||
(keywords != NULL && !PyDict_Check(keywords)) ||
format == NULL ||
kwlist == NULL)
{
PyErr_BadInternalCall();
return 0;
}
va_start(va, kwlist);
retval = vgetargskeywords(args, keywords, format,
kwlist, &va, FLAG_SIZE_T);
va_end(va);
return retval;
}
@ -1185,14 +1284,47 @@ PyArg_VaParseTupleAndKeywords(PyObject *args,
#endif
#endif
retval = vgetargskeywords(args, keywords, format, kwlist, &lva);
retval = vgetargskeywords(args, keywords, format, kwlist, &lva, 0);
return retval;
}
int
_PyArg_VaParseTupleAndKeywords_SizeT(PyObject *args,
PyObject *keywords,
const char *format,
const char **kwlist, va_list va)
{
int retval;
va_list lva;
if ((args == NULL || !PyTuple_Check(args)) ||
(keywords != NULL && !PyDict_Check(keywords)) ||
format == NULL ||
kwlist == NULL)
{
PyErr_BadInternalCall();
return 0;
}
#ifdef VA_LIST_IS_ARRAY
memcpy(lva, va, sizeof(va_list));
#else
#ifdef __va_copy
__va_copy(lva, va);
#else
lva = va;
#endif
#endif
retval = vgetargskeywords(args, keywords, format,
kwlist, &lva, FLAG_SIZE_T);
return retval;
}
static int
vgetargskeywords(PyObject *args, PyObject *keywords, const char *format,
const char **kwlist, va_list *p_va)
const char **kwlist, va_list *p_va, int flags)
{
char msgbuf[512];
int levels[32];
@ -1327,7 +1459,8 @@ vgetargskeywords(PyObject *args, PyObject *keywords, const char *format,
if (*format == '|')
format++;
msg = convertitem(PyTuple_GET_ITEM(args, i), &format, p_va,
levels, msgbuf, sizeof(msgbuf), &freelist);
flags, levels, msgbuf, sizeof(msgbuf),
&freelist);
if (msg) {
seterror(i+1, msg, levels, fname, message);
return cleanreturn(0, freelist);
@ -1347,8 +1480,8 @@ vgetargskeywords(PyObject *args, PyObject *keywords, const char *format,
item = PyDict_GetItemString(keywords, kwlist[i]);
if (item != NULL) {
Py_INCREF(item);
msg = convertitem(item, &format, p_va, levels, msgbuf,
sizeof(msgbuf), &freelist);
msg = convertitem(item, &format, p_va, flags, levels,
msgbuf, sizeof(msgbuf), &freelist);
Py_DECREF(item);
if (msg) {
seterror(i+1, msg, levels, fname, message);
@ -1361,7 +1494,7 @@ vgetargskeywords(PyObject *args, PyObject *keywords, const char *format,
else if (PyErr_Occurred())
return cleanreturn(0, freelist);
else {
msg = skipitem(&format, p_va);
msg = skipitem(&format, p_va, flags);
if (msg) {
seterror(i+1, msg, levels, fname, message);
return cleanreturn(0, freelist);
@ -1372,7 +1505,7 @@ vgetargskeywords(PyObject *args, PyObject *keywords, const char *format,
/* 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;
@ -1403,7 +1536,7 @@ vgetargskeywords(PyObject *args, PyObject *keywords, const char *format,
static char *
skipitem(const char **p_format, va_list *p_va)
skipitem(const char **p_format, va_list *p_va, int flags)
{
const char *format = *p_format;
char c = *format++;
@ -1436,6 +1569,12 @@ skipitem(const char **p_format, va_list *p_va)
break;
}
case 'n': /* Py_ssize_t */
{
(void) va_arg(*p_va, Py_ssize_t *);
break;
}
/* string codes */
case 'e': /* string with encoding */
@ -1458,6 +1597,9 @@ skipitem(const char **p_format, va_list *p_va)
{
(void) va_arg(*p_va, char **);
if (*format == '#') {
if (flags & FLAG_SIZE_T)
(void) va_arg(*p_va, Py_ssize_t *);
else
(void) va_arg(*p_va, int *);
format++;
}

View File

@ -351,7 +351,7 @@ static char* sys_files[] = {
void
PyImport_Cleanup(void)
{
int pos, ndone;
Py_ssize_t pos, ndone;
char *name;
PyObject *key, *value, *dict;
PyInterpreterState *interp = PyThreadState_GET()->interp;
@ -689,7 +689,7 @@ make_compiled_pathname(char *pathname, char *buf, size_t buflen)
Doesn't set an exception. */
static FILE *
check_compiled_module(char *pathname, long mtime, char *cpathname)
check_compiled_module(char *pathname, time_t mtime, char *cpathname)
{
FILE *fp;
long magic;
@ -805,10 +805,11 @@ open_exclusive(char *filename)
|O_BINARY /* necessary for Windows */
#endif
#ifdef __VMS
, 0666, "ctxt=bin", "shr=nil");
, 0666, "ctxt=bin", "shr=nil"
#else
, 0666);
, 0666
#endif
);
if (fd < 0)
return NULL;
return fdopen(fd, "wb");
@ -825,7 +826,7 @@ open_exclusive(char *filename)
remove the file. */
static void
write_compiled_module(PyCodeObject *co, char *cpathname, long mtime)
write_compiled_module(PyCodeObject *co, char *cpathname, time_t mtime)
{
FILE *fp;
@ -850,6 +851,7 @@ write_compiled_module(PyCodeObject *co, char *cpathname, long mtime)
}
/* Now write the true mtime */
fseek(fp, 4L, 0);
assert(mtime < LONG_MAX);
PyMarshal_WriteLongToFile(mtime, fp, Py_MARSHAL_VERSION);
fflush(fp);
fclose(fp);
@ -1061,10 +1063,10 @@ get_path_importer(PyObject *path_importer_cache, PyObject *path_hooks,
#ifdef MS_COREDLL
extern FILE *PyWin_FindRegisteredModule(const char *, struct filedescr **,
char *, int);
char *, Py_ssize_t);
#endif
static int case_ok(char *, int, int, char *);
static int case_ok(char *, Py_ssize_t, Py_ssize_t, char *);
static int find_init_module(char *); /* Forward */
static struct filedescr importhookdescr = {"", "", IMP_HOOK};
@ -1372,7 +1374,7 @@ PyAPI_FUNC(int) _PyImport_IsScript(struct filedescr * fd)
return fd->type == PY_SOURCE || fd->type == PY_COMPILED;
}
/* case_ok(char* buf, int len, int namelen, char* name)
/* case_ok(char* buf, Py_ssize_t len, Py_ssize_t namelen, char* name)
* The arguments here are tricky, best shown by example:
* /a/b/c/d/e/f/g/h/i/j/k/some_long_module_name.py\0
* ^ ^ ^ ^
@ -1420,7 +1422,7 @@ PyAPI_FUNC(int) _PyImport_IsScript(struct filedescr * fd)
#endif
static int
case_ok(char *buf, int len, int namelen, char *name)
case_ok(char *buf, Py_ssize_t len, Py_ssize_t namelen, char *name)
{
/* Pick a platform-specific implementation; the sequence of #if's here should
* match the sequence just above.
@ -1891,12 +1893,12 @@ PyImport_ImportModule(const char *name)
}
/* Forward declarations for helper routines */
static PyObject *get_parent(PyObject *globals, char *buf, int *p_buflen);
static PyObject *get_parent(PyObject *globals, char *buf, Py_ssize_t *p_buflen);
static PyObject *load_next(PyObject *mod, PyObject *altmod,
char **p_name, char *buf, int *p_buflen);
char **p_name, char *buf, Py_ssize_t *p_buflen);
static int mark_miss(char *name);
static int ensure_fromlist(PyObject *mod, PyObject *fromlist,
char *buf, int buflen, int recursive);
char *buf, Py_ssize_t buflen, int recursive);
static PyObject * import_submodule(PyObject *mod, char *name, char *fullname);
/* The Magnum Opus of dotted-name import :-) */
@ -1906,7 +1908,7 @@ import_module_ex(char *name, PyObject *globals, PyObject *locals,
PyObject *fromlist)
{
char buf[MAXPATHLEN+1];
int buflen = 0;
Py_ssize_t buflen = 0;
PyObject *parent, *head, *next, *tail;
parent = get_parent(globals, buf, &buflen);
@ -1976,7 +1978,7 @@ PyImport_ImportModuleEx(char *name, PyObject *globals, PyObject *locals,
corresponding entry is not found in sys.modules, Py_None is returned.
*/
static PyObject *
get_parent(PyObject *globals, char *buf, int *p_buflen)
get_parent(PyObject *globals, char *buf, Py_ssize_t *p_buflen)
{
static PyObject *namestr = NULL;
static PyObject *pathstr = NULL;
@ -2044,7 +2046,7 @@ get_parent(PyObject *globals, char *buf, int *p_buflen)
/* altmod is either None or same as mod */
static PyObject *
load_next(PyObject *mod, PyObject *altmod, char **p_name, char *buf,
int *p_buflen)
Py_ssize_t *p_buflen)
{
char *name = *p_name;
char *dot = strchr(name, '.');
@ -2114,7 +2116,7 @@ mark_miss(char *name)
}
static int
ensure_fromlist(PyObject *mod, PyObject *fromlist, char *buf, int buflen,
ensure_fromlist(PyObject *mod, PyObject *fromlist, char *buf, Py_ssize_t buflen,
int recursive)
{
int i;

View File

@ -363,10 +363,10 @@ int (*PyMacGluePtr_##routinename)(PyObject *, object *); \
\
int routinename(PyObject *pyobj, object *cobj) { \
if (!PyMacGluePtr_##routinename) { \
if (!PyImport_ImportModule(module)) return NULL; \
if (!PyImport_ImportModule(module)) return 0; \
if (!PyMacGluePtr_##routinename) { \
PyErr_SetString(PyExc_ImportError, "Module did not provide routine: " module ": " #routinename); \
return NULL; \
return 0; \
} \
} \
return (*PyMacGluePtr_##routinename)(pyobj, cobj); \

View File

@ -59,7 +59,7 @@ typedef struct {
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 @@ w_long64(long x, WFILE *p)
static void
w_object(PyObject *v, WFILE *p)
{
int i, n;
Py_ssize_t i, n;
p->depth++;
@ -181,7 +181,7 @@ w_object(PyObject *v, WFILE *p)
else {
char buf[256]; /* Plenty to format any double */
PyFloat_AsReprString(buf, (PyFloatObject *)v);
n = strlen(buf);
n = (int)strlen(buf);
w_byte(TYPE_FLOAT, p);
w_byte(n, p);
w_string(buf, n, p);
@ -213,14 +213,14 @@ w_object(PyObject *v, WFILE *p)
PyComplex_RealAsDouble(v));
PyFloat_AsReprString(buf, temp);
Py_DECREF(temp);
n = strlen(buf);
n = (int)strlen(buf);
w_byte(n, p);
w_string(buf, n, p);
temp = (PyFloatObject*)PyFloat_FromDouble(
PyComplex_ImagAsDouble(v));
PyFloat_AsReprString(buf, temp);
Py_DECREF(temp);
n = strlen(buf);
n = (int)strlen(buf);
w_byte(n, p);
w_string(buf, n, p);
}
@ -236,7 +236,7 @@ w_object(PyObject *v, WFILE *p)
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 @@ w_object(PyObject *v, WFILE *p)
}
}
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! */
@ -395,9 +395,10 @@ static int
r_string(char *s, int n, RFILE *p)
{
if (p->fp != NULL)
return fread(s, 1, n, p->fp);
/* The result fits into int because it must be <=n. */
return (int)fread(s, 1, n, p->fp);
if (p->end - p->ptr < n)
n = p->end - p->ptr;
n = (int)(p->end - p->ptr);
memcpy(s, p->ptr, n);
p->ptr += n;
return n;
@ -939,7 +940,10 @@ PyMarshal_ReadLastObjectFromFile(FILE *fp)
pBuf = (char *)PyMem_MALLOC(filesize);
if (pBuf != NULL) {
PyObject* v;
size_t n = fread(pBuf, 1, filesize, fp);
size_t n;
/* filesize must fit into an int, because it
is smaller than REASONABLE_FILE_LIMIT */
n = fread(pBuf, 1, (int)filesize, fp);
v = PyMarshal_ReadObjectFromString(pBuf, n);
if (pBuf != buf)
PyMem_FREE(pBuf);
@ -970,7 +974,7 @@ PyMarshal_ReadObjectFromFile(FILE *fp)
}
PyObject *
PyMarshal_ReadObjectFromString(char *str, int len)
PyMarshal_ReadObjectFromString(char *str, Py_ssize_t len)
{
RFILE rf;
PyObject *result;

View File

@ -313,6 +313,11 @@ do_mkvalue(const char **p_format, va_list *p_va)
return PyInt_FromLong(n);
}
case 'n':
#if SIZEOF_SIZE_T!=SIZEOF_LONG
return PyLong_FromSsize_t(va_arg(*p_va, Py_Ssize_t));
#endif
/* Fall through from 'n' to 'l' if Py_ssize_t is long */
case 'l':
return PyInt_FromLong(va_arg(*p_va, long));
@ -371,7 +376,7 @@ do_mkvalue(const char **p_format, va_list *p_va)
case 'c':
{
char p[1];
p[0] = va_arg(*p_va, int);
p[0] = (char)va_arg(*p_va, int);
return PyString_FromStringAndSize(p, 1);
}

View File

@ -159,7 +159,7 @@ PyOS_ascii_strtod(const char *nptr, char **endptr)
**/
char *
PyOS_ascii_formatd(char *buffer,
int buf_len,
size_t buf_len,
const char *format,
double d)
{

View File

@ -939,7 +939,7 @@ print_error_text(PyObject *f, int offset, const char *text)
nl = strchr(text, '\n');
if (nl == NULL || nl-text >= offset)
break;
offset -= (nl+1-text);
offset -= (int)(nl+1-text);
text = nl+1;
}
while (*text == ' ' || *text == '\t') {

View File

@ -426,7 +426,8 @@ static int
analyze_cells(PyObject *scope, PyObject *free)
{
PyObject *name, *v, *w;
int pos = 0, success = 0;
int success = 0;
Py_ssize_t pos = 0;
w = PyInt_FromLong(CELL);
if (!w)
@ -507,7 +508,7 @@ update_symbols(PyObject *symbols, PyObject *scope,
PyObject *bound, PyObject *free, int class)
{
PyObject *name, *v, *u, *w, *free_value = NULL;
int pos = 0;
Py_ssize_t pos = 0;
while (PyDict_Next(symbols, &pos, &name, &v)) {
long i, flags;
@ -583,7 +584,8 @@ analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free,
{
PyObject *name, *v, *local = NULL, *scope = NULL, *newbound = NULL;
PyObject *newglobal = NULL, *newfree = NULL;
int i, pos = 0, success = 0;
int i, success = 0;
Py_ssize_t pos = 0;
local = PyDict_New();
if (!local)

View File

@ -1279,7 +1279,7 @@ PySys_SetArgv(int argc, char **argv)
if (path != NULL) {
char *argv0 = argv[0];
char *p = NULL;
int n = 0;
Py_ssize_t n = 0;
PyObject *a;
#ifdef HAVE_READLINK
char link[MAXPATHLEN+1];

View File

@ -170,7 +170,7 @@ bootstrap(void *call)
long
PyThread_start_new_thread(void (*func)(void *), void *arg)
{
unsigned long rv;
uintptr_t rv;
callobj obj;
dprintf(("%ld: PyThread_start_new_thread called\n",
@ -186,7 +186,7 @@ PyThread_start_new_thread(void (*func)(void *), void *arg)
return -1;
rv = _beginthread(bootstrap, 0, &obj); /* use default stack size */
if (rv == (unsigned long)-1) {
if (rv == (uintptr_t)-1) {
/* I've seen errno == EAGAIN here, which means "there are
* too many threads".
*/

View File

@ -66,7 +66,7 @@ static void countobjs(PyDrawFObject *pd)
if ((char*)d==end) pd->nobjs=k;
}
static drawfile_object *findobj(PyDrawFObject *pd,int n)
static drawfile_object *findobj(PyDrawFObject *pd,Py_ssize_t n)
{ drawfile_diagram *dd=pd->drawf;
drawfile_object *d=dd->objects;
for(;n>0;n--) d=NEXT(d);
@ -520,14 +520,14 @@ static PyObject *drawf_concat(PyDrawFObject *b,PyDrawFObject *c)
return (PyObject*)p;
}
static PyObject *drawf_repeat(PyDrawFObject *b,int i)
static PyObject *drawf_repeat(PyDrawFObject *b,Py_ssize_t i)
{ PyErr_SetString(PyExc_IndexError,"drawf repetition not implemented");
return NULL;
}
static PyObject *drawf_item(PyDrawFObject *b,int i)
static PyObject *drawf_item(PyDrawFObject *b,Py_ssize_t i)
{ PyDrawFObject *c;
int size;
Py_ssize_t size;
drawfile_diagram *dd;
drawfile_object *d;
if(i<0||i>=b->nobjs)
@ -546,9 +546,9 @@ static PyObject *drawf_item(PyDrawFObject *b,int i)
return (PyObject*)c;
}
static PyObject *drawf_slice(PyDrawFObject *b,int i,int j)
static PyObject *drawf_slice(PyDrawFObject *b,Py_ssize_t i,Py_ssize_t j)
{ PyDrawFObject *c;
int size,n;
Py_ssize_t size,n;
drawfile_diagram *dd;
drawfile_object *d;
if(i<0||j>b->nobjs)
@ -570,7 +570,7 @@ static PyObject *drawf_slice(PyDrawFObject *b,int i,int j)
return (PyObject*)c;
}
static int drawf_ass_item(PyDrawFObject *b,int i,PyObject *v)
static int drawf_ass_item(PyDrawFObject *b,Py_ssize_t i,PyObject *v)
{ PyErr_SetString(PyExc_IndexError,"drawf ass not implemented");
return NULL;
}
@ -587,7 +587,7 @@ static int drawf_ass_item(PyDrawFObject *b,int i,PyObject *v)
}
*/
static int drawf_ass_slice(PyDrawFObject *b,int i,int j,PyObject *v)
static int drawf_ass_slice(PyDrawFObject *b,Py_ssize_t i,Py_ssize_t j,PyObject *v)
{ PyErr_SetString(PyExc_IndexError,"drawf ass_slice not implemented");
return NULL;
}
@ -595,11 +595,11 @@ static int drawf_ass_slice(PyDrawFObject *b,int i,int j,PyObject *v)
static PySequenceMethods drawf_as_sequence=
{ (inquiry)drawf_len,
(binaryfunc)drawf_concat,
(intargfunc)drawf_repeat,
(intargfunc)drawf_item,
(intintargfunc)drawf_slice,
(intobjargproc)drawf_ass_item,
(intintobjargproc)drawf_ass_slice,
(ssizeargfunc)drawf_repeat,
(ssizeargfunc)drawf_item,
(ssizessizeargfunc)drawf_slice,
(ssizeobjargproc)drawf_ass_item,
(ssizessizeobjargproc)drawf_ass_slice,
};
static PyObject *PyDrawF_GetAttr(PyDrawFObject *s,char *name)

View File

@ -215,12 +215,12 @@ static PyObject *block_concat(PyBlockObject *b,PyBlockObject *c)
return NULL;
}
static PyObject *block_repeat(PyBlockObject *b,int i)
static PyObject *block_repeat(PyBlockObject *b,Py_ssize_t i)
{ PyErr_SetString(PyExc_IndexError,"block repetition not implemented");
return NULL;
}
static PyObject *block_item(PyBlockObject *b,int i)
static PyObject *block_item(PyBlockObject *b,Py_ssize_t i)
{ if(i<0||4*i>=b->length)
{ PyErr_SetString(PyExc_IndexError,"block index out of range");
return NULL;
@ -228,8 +228,8 @@ static PyObject *block_item(PyBlockObject *b,int i)
return PyInt_FromLong(((long*)(b->block))[i]);
}
static PyObject *block_slice(PyBlockObject *b,int i,int j)
{ int n,k;
static PyObject *block_slice(PyBlockObject *b,Py_ssize_t i,Py_ssize_t j)
{ Py_ssize_t n,k;
long *p=b->block;
PyObject *result;
if(j>b->length/4) j=b->length/4;
@ -239,11 +239,11 @@ static PyObject *block_slice(PyBlockObject *b,int i,int j)
}
n=j-i;
result=PyList_New(n);
for(k=0;k<n;k++) PyList_SetItem(result,k,PyInt_FromLong(p[i+k]));
for(k=0;k<n;k++) PyList_SetItem(result,k,PyInt_FromSsize_t(p[i+k]));
return result;
}
static int block_ass_item(PyBlockObject *b,int i,PyObject *v)
static int block_ass_item(PyBlockObject *b,Py_ssize_t i,PyObject *v)
{ if(i<0||i>=b->length/4)
{ PyErr_SetString(PyExc_IndexError,"block index out of range");
return -1;
@ -256,8 +256,8 @@ static int block_ass_item(PyBlockObject *b,int i,PyObject *v)
return 0;
}
static int block_ass_slice(PyBlockObject *b,int i,int j,PyObject *v)
{ int n,k;
static int block_ass_slice(PyBlockObject *b,Py_ssize_t i,Py_ssize_t j,PyObject *v)
{ Py_ssize_t n,k;
long *p=b->block;
if(j>b->length/4) j=b->length/4;
if(i<0||i>j)
@ -281,11 +281,11 @@ static int block_ass_slice(PyBlockObject *b,int i,int j,PyObject *v)
static PySequenceMethods block_as_sequence=
{ (inquiry)block_len, /*sq_length*/
(binaryfunc)block_concat, /*sq_concat*/
(intargfunc)block_repeat, /*sq_repeat*/
(intargfunc)block_item, /*sq_item*/
(intintargfunc)block_slice, /*sq_slice*/
(intobjargproc)block_ass_item, /*sq_ass_item*/
(intintobjargproc)block_ass_slice, /*sq_ass_slice*/
(ssizeargfunc)block_repeat, /*sq_repeat*/
(ssizeargfunc)block_item, /*sq_item*/
(ssizessizeargfunc)block_slice, /*sq_slice*/
(ssizeobjargproc)block_ass_item, /*sq_ass_item*/
(ssizessizeobjargproc)block_ass_slice, /*sq_ass_slice*/
};
static PyObject *PyBlock_GetAttr(PyBlockObject *s,char *name)

480
configure vendored
View File

@ -1,5 +1,5 @@
#! /bin/sh
# From configure.in Revision: 42199 .
# From configure.in Revision: 42307 .
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.59 for python 2.5.
#
@ -6197,6 +6197,70 @@ _ACEOF
fi
echo "$as_me:$LINENO: checking for ssize_t" >&5
echo $ECHO_N "checking for ssize_t... $ECHO_C" >&6
if test "${ac_cv_type_ssize_t+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
int
main ()
{
if ((ssize_t *) 0)
return 0;
if (sizeof (ssize_t))
return 0;
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_type_ssize_t=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_type_ssize_t=no
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
fi
echo "$as_me:$LINENO: result: $ac_cv_type_ssize_t" >&5
echo "${ECHO_T}$ac_cv_type_ssize_t" >&6
if test $ac_cv_type_ssize_t = yes; then
cat >>confdefs.h <<\_ACEOF
#define HAVE_SSIZE_T 1
_ACEOF
fi
# Sizes of various common basic types
# ANSI C requires sizeof(char) == 1, so no need to check it
@ -9098,6 +9162,420 @@ cat >>confdefs.h <<_ACEOF
_ACEOF
echo "$as_me:$LINENO: checking for size_t" >&5
echo $ECHO_N "checking for size_t... $ECHO_C" >&6
if test "${ac_cv_type_size_t+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
int
main ()
{
if ((size_t *) 0)
return 0;
if (sizeof (size_t))
return 0;
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_type_size_t=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_type_size_t=no
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
fi
echo "$as_me:$LINENO: result: $ac_cv_type_size_t" >&5
echo "${ECHO_T}$ac_cv_type_size_t" >&6
echo "$as_me:$LINENO: checking size of size_t" >&5
echo $ECHO_N "checking size of size_t... $ECHO_C" >&6
if test "${ac_cv_sizeof_size_t+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
if test "$ac_cv_type_size_t" = yes; then
# The cast to unsigned long works around a bug in the HP C Compiler
# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
# This bug is HP SR number 8606223364.
if test "$cross_compiling" = yes; then
# Depending upon the size, compute the lo and hi bounds.
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
int
main ()
{
static int test_array [1 - 2 * !(((long) (sizeof (size_t))) >= 0)];
test_array [0] = 0
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_lo=0 ac_mid=0
while :; do
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
int
main ()
{
static int test_array [1 - 2 * !(((long) (sizeof (size_t))) <= $ac_mid)];
test_array [0] = 0
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_hi=$ac_mid; break
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_lo=`expr $ac_mid + 1`
if test $ac_lo -le $ac_mid; then
ac_lo= ac_hi=
break
fi
ac_mid=`expr 2 '*' $ac_mid + 1`
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
done
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
int
main ()
{
static int test_array [1 - 2 * !(((long) (sizeof (size_t))) < 0)];
test_array [0] = 0
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_hi=-1 ac_mid=-1
while :; do
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
int
main ()
{
static int test_array [1 - 2 * !(((long) (sizeof (size_t))) >= $ac_mid)];
test_array [0] = 0
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_lo=$ac_mid; break
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_hi=`expr '(' $ac_mid ')' - 1`
if test $ac_mid -le $ac_hi; then
ac_lo= ac_hi=
break
fi
ac_mid=`expr 2 '*' $ac_mid`
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
done
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_lo= ac_hi=
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
# Binary search between lo and hi bounds.
while test "x$ac_lo" != "x$ac_hi"; do
ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo`
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
int
main ()
{
static int test_array [1 - 2 * !(((long) (sizeof (size_t))) <= $ac_mid)];
test_array [0] = 0
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_hi=$ac_mid
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_lo=`expr '(' $ac_mid ')' + 1`
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
done
case $ac_lo in
?*) ac_cv_sizeof_size_t=$ac_lo;;
'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (size_t), 77
See \`config.log' for more details." >&5
echo "$as_me: error: cannot compute sizeof (size_t), 77
See \`config.log' for more details." >&2;}
{ (exit 1); exit 1; }; } ;;
esac
else
if test "$cross_compiling" = yes; then
{ { echo "$as_me:$LINENO: error: cannot run test program while cross compiling
See \`config.log' for more details." >&5
echo "$as_me: error: cannot run test program while cross compiling
See \`config.log' for more details." >&2;}
{ (exit 1); exit 1; }; }
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
long longval () { return (long) (sizeof (size_t)); }
unsigned long ulongval () { return (long) (sizeof (size_t)); }
#include <stdio.h>
#include <stdlib.h>
int
main ()
{
FILE *f = fopen ("conftest.val", "w");
if (! f)
exit (1);
if (((long) (sizeof (size_t))) < 0)
{
long i = longval ();
if (i != ((long) (sizeof (size_t))))
exit (1);
fprintf (f, "%ld\n", i);
}
else
{
unsigned long i = ulongval ();
if (i != ((long) (sizeof (size_t))))
exit (1);
fprintf (f, "%lu\n", i);
}
exit (ferror (f) || fclose (f) != 0);
;
return 0;
}
_ACEOF
rm -f conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && { ac_try='./conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_sizeof_size_t=`cat conftest.val`
else
echo "$as_me: program exited with status $ac_status" >&5
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
( exit $ac_status )
{ { echo "$as_me:$LINENO: error: cannot compute sizeof (size_t), 77
See \`config.log' for more details." >&5
echo "$as_me: error: cannot compute sizeof (size_t), 77
See \`config.log' for more details." >&2;}
{ (exit 1); exit 1; }; }
fi
rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
fi
fi
rm -f conftest.val
else
ac_cv_sizeof_size_t=0
fi
fi
echo "$as_me:$LINENO: result: $ac_cv_sizeof_size_t" >&5
echo "${ECHO_T}$ac_cv_sizeof_size_t" >&6
cat >>confdefs.h <<_ACEOF
#define SIZEOF_SIZE_T $ac_cv_sizeof_size_t
_ACEOF
echo "$as_me:$LINENO: checking for long long support" >&5
echo $ECHO_N "checking for long long support... $ECHO_C" >&6

Some files were not shown because too many files have changed in this diff Show More