[Python] Don't pass Py_ssize_t for a %d printf-like format as

that's undefined behaviour when sizeof(Py_ssize_t) != sizeof(int).


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10145 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Olly Betts 2007-11-16 16:05:10 +00:00
commit bc9c671d84
2 changed files with 7 additions and 3 deletions

View file

@ -1,3 +1,7 @@
Version 1.3.33 (in progress)
============================
11/16/2007: olly
[Python] Don't pass Py_ssize_t for a %d printf-like format as
that's undefined behaviour when sizeof(Py_ssize_t) != sizeof(int).

View file

@ -135,7 +135,7 @@ SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssi
return 1;
} else {
PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got none",
name, (min == max ? "" : "at least "), min);
name, (min == max ? "" : "at least "), (int)min);
return 0;
}
}
@ -146,11 +146,11 @@ SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssi
register Py_ssize_t l = PyTuple_GET_SIZE(args);
if (l < min) {
PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d",
name, (min == max ? "" : "at least "), min, l);
name, (min == max ? "" : "at least "), (int)min, (int)l);
return 0;
} else if (l > max) {
PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d",
name, (min == max ? "" : "at most "), max, l);
name, (min == max ? "" : "at most "), (int)max, (int)l);
return 0;
} else {
register int i;