Correct usage of Py_ssize_t
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10040 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
0da1552b26
commit
e49c07014d
2 changed files with 3 additions and 3 deletions
|
|
@ -128,7 +128,7 @@ SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) {
|
||||||
/* Unpack the argument tuple */
|
/* Unpack the argument tuple */
|
||||||
|
|
||||||
SWIGINTERN int
|
SWIGINTERN int
|
||||||
SWIG_Python_UnpackTuple(PyObject *args, const char *name, int min, int max, PyObject **objs)
|
SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, PyObject **objs)
|
||||||
{
|
{
|
||||||
if (!args) {
|
if (!args) {
|
||||||
if (!min && !max) {
|
if (!min && !max) {
|
||||||
|
|
@ -143,7 +143,7 @@ SWIG_Python_UnpackTuple(PyObject *args, const char *name, int min, int max, PyOb
|
||||||
PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple");
|
PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple");
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
register int l = PyTuple_GET_SIZE(args);
|
register Py_ssize_t l = PyTuple_GET_SIZE(args);
|
||||||
if (l < min) {
|
if (l < min) {
|
||||||
PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d",
|
PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d",
|
||||||
name, (min == max ? "" : "at least "), min, l);
|
name, (min == max ? "" : "at least "), min, l);
|
||||||
|
|
|
||||||
|
|
@ -1475,7 +1475,7 @@ public:
|
||||||
if (!fastunpack) {
|
if (!fastunpack) {
|
||||||
Wrapper_add_local(f, "ii", "int ii");
|
Wrapper_add_local(f, "ii", "int ii");
|
||||||
Append(f->code, "if (!PyTuple_Check(args)) SWIG_fail;\n");
|
Append(f->code, "if (!PyTuple_Check(args)) SWIG_fail;\n");
|
||||||
Append(f->code, "argc = PyObject_Length(args);\n");
|
Append(f->code, "argc = (int)PyObject_Length(args);\n");
|
||||||
Printf(f->code, "for (ii = 0; (ii < argc) && (ii < %d); ii++) {\n", maxargs);
|
Printf(f->code, "for (ii = 0; (ii < argc) && (ii < %d); ii++) {\n", maxargs);
|
||||||
Append(f->code, "argv[ii] = PyTuple_GET_ITEM(args,ii);\n");
|
Append(f->code, "argv[ii] = PyTuple_GET_ITEM(args,ii);\n");
|
||||||
Append(f->code, "}\n");
|
Append(f->code, "}\n");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue