mirror of https://github.com/python/cpython
Fix more ssize_t issues.
This commit is contained in:
parent
26fd9607c7
commit
6685128b97
|
@ -169,7 +169,7 @@ codec_decode(PyObject *self, PyObject *args)
|
||||||
|
|
||||||
static
|
static
|
||||||
PyObject *codec_tuple(PyObject *unicode,
|
PyObject *codec_tuple(PyObject *unicode,
|
||||||
int len)
|
Py_ssize_t len)
|
||||||
{
|
{
|
||||||
PyObject *v,*w;
|
PyObject *v,*w;
|
||||||
|
|
||||||
|
@ -181,7 +181,7 @@ PyObject *codec_tuple(PyObject *unicode,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
PyTuple_SET_ITEM(v,0,unicode);
|
PyTuple_SET_ITEM(v,0,unicode);
|
||||||
w = PyInt_FromLong(len);
|
w = PyInt_FromSsize_t(len);
|
||||||
if (w == NULL) {
|
if (w == NULL) {
|
||||||
Py_DECREF(v);
|
Py_DECREF(v);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -213,7 +213,7 @@ escape_encode(PyObject *self,
|
||||||
PyObject *str;
|
PyObject *str;
|
||||||
const char *errors = NULL;
|
const char *errors = NULL;
|
||||||
char *buf;
|
char *buf;
|
||||||
int len;
|
Py_ssize_t len;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "O!|z:escape_encode",
|
if (!PyArg_ParseTuple(args, "O!|z:escape_encode",
|
||||||
&PyString_Type, &str, &errors))
|
&PyString_Type, &str, &errors))
|
||||||
|
|
|
@ -1420,7 +1420,7 @@ write_header(ProfilerObject *self)
|
||||||
char *buffer;
|
char *buffer;
|
||||||
char cwdbuffer[PATH_MAX];
|
char cwdbuffer[PATH_MAX];
|
||||||
PyObject *temp;
|
PyObject *temp;
|
||||||
int i, len;
|
Py_ssize_t i, len;
|
||||||
|
|
||||||
buffer = get_version_string();
|
buffer = get_version_string();
|
||||||
if (buffer == NULL) {
|
if (buffer == NULL) {
|
||||||
|
|
|
@ -320,7 +320,7 @@ class_setattr(PyClassObject *op, PyObject *name, PyObject *v)
|
||||||
}
|
}
|
||||||
sname = PyString_AsString(name);
|
sname = PyString_AsString(name);
|
||||||
if (sname[0] == '_' && sname[1] == '_') {
|
if (sname[0] == '_' && sname[1] == '_') {
|
||||||
int n = PyString_Size(name);
|
Py_ssize_t n = PyString_Size(name);
|
||||||
if (sname[n-1] == '_' && sname[n-2] == '_') {
|
if (sname[n-1] == '_' && sname[n-2] == '_') {
|
||||||
char *err = NULL;
|
char *err = NULL;
|
||||||
if (strcmp(sname, "__dict__") == 0)
|
if (strcmp(sname, "__dict__") == 0)
|
||||||
|
@ -380,7 +380,7 @@ class_str(PyClassObject *op)
|
||||||
PyObject *mod = PyDict_GetItemString(op->cl_dict, "__module__");
|
PyObject *mod = PyDict_GetItemString(op->cl_dict, "__module__");
|
||||||
PyObject *name = op->cl_name;
|
PyObject *name = op->cl_name;
|
||||||
PyObject *res;
|
PyObject *res;
|
||||||
int m, n;
|
Py_ssize_t m, n;
|
||||||
|
|
||||||
if (name == NULL || !PyString_Check(name))
|
if (name == NULL || !PyString_Check(name))
|
||||||
return class_repr(op);
|
return class_repr(op);
|
||||||
|
@ -638,7 +638,7 @@ instance_dealloc(register PyInstanceObject *inst)
|
||||||
PyObject_GC_Del(inst);
|
PyObject_GC_Del(inst);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int refcnt = inst->ob_refcnt;
|
Py_ssize_t refcnt = inst->ob_refcnt;
|
||||||
/* __del__ resurrected it! Make it look like the original
|
/* __del__ resurrected it! Make it look like the original
|
||||||
* Py_DECREF never happened.
|
* Py_DECREF never happened.
|
||||||
*/
|
*/
|
||||||
|
@ -778,7 +778,7 @@ instance_setattr(PyInstanceObject *inst, PyObject *name, PyObject *v)
|
||||||
PyObject *func, *args, *res, *tmp;
|
PyObject *func, *args, *res, *tmp;
|
||||||
char *sname = PyString_AsString(name);
|
char *sname = PyString_AsString(name);
|
||||||
if (sname[0] == '_' && sname[1] == '_') {
|
if (sname[0] == '_' && sname[1] == '_') {
|
||||||
int n = PyString_Size(name);
|
Py_ssize_t n = PyString_Size(name);
|
||||||
if (sname[n-1] == '_' && sname[n-2] == '_') {
|
if (sname[n-1] == '_' && sname[n-2] == '_') {
|
||||||
if (strcmp(sname, "__dict__") == 0) {
|
if (strcmp(sname, "__dict__") == 0) {
|
||||||
if (PyEval_GetRestricted()) {
|
if (PyEval_GetRestricted()) {
|
||||||
|
@ -1263,7 +1263,7 @@ instance_contains(PyInstanceObject *inst, PyObject *member)
|
||||||
*/
|
*/
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
return _PySequence_IterSearch((PyObject *)inst, member,
|
return _PySequence_IterSearch((PyObject *)inst, member,
|
||||||
PY_ITERSEARCH_CONTAINS);
|
PY_ITERSEARCH_CONTAINS) > 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -3034,7 +3034,7 @@ decode_unicode(const char *s, size_t len, int rawmode, const char *encoding)
|
||||||
if (*s & 0x80) { /* XXX inefficient */
|
if (*s & 0x80) { /* XXX inefficient */
|
||||||
PyObject *w;
|
PyObject *w;
|
||||||
char *r;
|
char *r;
|
||||||
int rn, i;
|
Py_ssize_t rn, i;
|
||||||
w = decode_utf8(&s, end, "utf-16-be");
|
w = decode_utf8(&s, end, "utf-16-be");
|
||||||
if (w == NULL) {
|
if (w == NULL) {
|
||||||
Py_DECREF(u);
|
Py_DECREF(u);
|
||||||
|
|
|
@ -1560,7 +1560,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
|
||||||
/* XXX move into writeobject() ? */
|
/* XXX move into writeobject() ? */
|
||||||
if (PyString_Check(v)) {
|
if (PyString_Check(v)) {
|
||||||
char *s = PyString_AS_STRING(v);
|
char *s = PyString_AS_STRING(v);
|
||||||
int len = PyString_GET_SIZE(v);
|
Py_ssize_t len = PyString_GET_SIZE(v);
|
||||||
if (len == 0 ||
|
if (len == 0 ||
|
||||||
!isspace(Py_CHARMASK(s[len-1])) ||
|
!isspace(Py_CHARMASK(s[len-1])) ||
|
||||||
s[len-1] == ' ')
|
s[len-1] == ' ')
|
||||||
|
@ -1569,7 +1569,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
|
||||||
#ifdef Py_USING_UNICODE
|
#ifdef Py_USING_UNICODE
|
||||||
else if (PyUnicode_Check(v)) {
|
else if (PyUnicode_Check(v)) {
|
||||||
Py_UNICODE *s = PyUnicode_AS_UNICODE(v);
|
Py_UNICODE *s = PyUnicode_AS_UNICODE(v);
|
||||||
int len = PyUnicode_GET_SIZE(v);
|
Py_ssize_t len = PyUnicode_GET_SIZE(v);
|
||||||
if (len == 0 ||
|
if (len == 0 ||
|
||||||
!Py_UNICODE_ISSPACE(s[len-1]) ||
|
!Py_UNICODE_ISSPACE(s[len-1]) ||
|
||||||
s[len-1] == ' ')
|
s[len-1] == ' ')
|
||||||
|
|
|
@ -95,7 +95,7 @@ PyObject *_PyCodec_Lookup(const char *encoding)
|
||||||
{
|
{
|
||||||
PyInterpreterState *interp;
|
PyInterpreterState *interp;
|
||||||
PyObject *result, *args = NULL, *v;
|
PyObject *result, *args = NULL, *v;
|
||||||
int i, len;
|
Py_ssize_t i, len;
|
||||||
|
|
||||||
if (encoding == NULL) {
|
if (encoding == NULL) {
|
||||||
PyErr_BadArgument();
|
PyErr_BadArgument();
|
||||||
|
|
Loading…
Reference in New Issue