summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
Diffstat (limited to 'Objects')
-rw-r--r--Objects/enumobject.c2
-rw-r--r--Objects/genobject.c2
-rw-r--r--Objects/object.c4
-rw-r--r--Objects/stringobject.c16
-rw-r--r--Objects/typeobject.c5
5 files changed, 19 insertions, 10 deletions
diff --git a/Objects/enumobject.c b/Objects/enumobject.c
index 5999ae9..4811239 100644
--- a/Objects/enumobject.c
+++ b/Objects/enumobject.c
@@ -216,7 +216,7 @@ static PyObject *
reversed_next(reversedobject *ro)
{
PyObject *item;
- long index = ro->index;
+ Py_ssize_t index = ro->index;
if (index >= 0) {
item = PySequence_GetItem(ro->seq, index);
diff --git a/Objects/genobject.c b/Objects/genobject.c
index c24c3ce..3f6ef85 100644
--- a/Objects/genobject.c
+++ b/Objects/genobject.c
@@ -177,7 +177,7 @@ gen_del(PyObject *self)
* never happened.
*/
{
- int refcnt = self->ob_refcnt;
+ Py_ssize_t refcnt = self->ob_refcnt;
_Py_NewReference(self);
self->ob_refcnt = refcnt;
}
diff --git a/Objects/object.c b/Objects/object.c
index a69a0ad..866ce06 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -1172,7 +1172,7 @@ PyObject_SetAttr(PyObject *v, PyObject *name, PyObject *value)
PyObject **
_PyObject_GetDictPtr(PyObject *obj)
{
- long dictoffset;
+ Py_ssize_t dictoffset;
PyTypeObject *tp = obj->ob_type;
if (!(tp->tp_flags & Py_TPFLAGS_HAVE_CLASS))
@@ -1212,7 +1212,7 @@ PyObject_GenericGetAttr(PyObject *obj, PyObject *name)
PyObject *descr = NULL;
PyObject *res = NULL;
descrgetfunc f;
- long dictoffset;
+ Py_ssize_t dictoffset;
PyObject **dictptr;
if (!PyString_Check(name)){
diff --git a/Objects/stringobject.c b/Objects/stringobject.c
index 4fe24a3..0030ac7 100644
--- a/Objects/stringobject.c
+++ b/Objects/stringobject.c
@@ -3679,6 +3679,7 @@ _PyString_FormatLong(PyObject *val, int flags, int prec, int type,
Py_ssize_t i;
int sign; /* 1 if '-', else 0 */
int len; /* number of characters */
+ Py_ssize_t llen;
int numdigits; /* len == numnondigits + numdigits */
int numnondigits = 0;
@@ -3707,7 +3708,12 @@ _PyString_FormatLong(PyObject *val, int flags, int prec, int type,
return NULL;
}
buf = PyString_AsString(result);
- len = PyString_Size(result);
+ llen = PyString_Size(result);
+ if (llen > INT_MAX) {
+ PyErr_SetString(PyExc_ValueError, "string too large in _PyString_FormatLong");
+ return NULL;
+ }
+ len = (int)llen;
if (buf[len-1] == 'L') {
--len;
buf[len] = '\0';
@@ -3941,12 +3947,12 @@ PyString_Format(PyObject *format, PyObject *args)
PyObject *temp = NULL;
char *pbuf;
int sign;
- int len;
+ Py_ssize_t len;
char formatbuf[FORMATBUFLEN];
/* For format{float,int,char}() */
#ifdef Py_USING_UNICODE
char *fmt_start = fmt;
- int argidx_start = argidx;
+ Py_ssize_t argidx_start = argidx;
#endif
fmt++;
@@ -4139,8 +4145,10 @@ PyString_Format(PyObject *format, PyObject *args)
if (c == 'i')
c = 'd';
if (PyLong_Check(v)) {
+ int ilen;
temp = _PyString_FormatLong(v, flags,
- prec, c, &pbuf, &len);
+ prec, c, &pbuf, &ilen);
+ len = ilen;
if (!temp)
goto error;
sign = 1;
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 6072c08..9837e38 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -4244,7 +4244,8 @@ slot_sq_contains(PyObject *self, PyObject *value)
}
}
else if (! PyErr_Occurred()) {
- result = _PySequence_IterSearch(self, value,
+ /* Possible results: -1 and 1 */
+ result = (int)_PySequence_IterSearch(self, value,
PY_ITERSEARCH_CONTAINS);
}
return result;
@@ -4880,7 +4881,7 @@ slot_tp_del(PyObject *self)
* never happened.
*/
{
- int refcnt = self->ob_refcnt;
+ Py_ssize_t refcnt = self->ob_refcnt;
_Py_NewReference(self);
self->ob_refcnt = refcnt;
}