From 9537f69323768e1cf65b63c3f25e114588770267 Mon Sep 17 00:00:00 2001 From: Marcelo Matus Date: Tue, 22 Feb 2005 19:52:43 +0000 Subject: [PATCH] fix empty map bug git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6980 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/python/std_map.i | 20 ++++++++++---------- Lib/python/std_multimap.i | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Lib/python/std_map.i b/Lib/python/std_map.i index bfc4fb201..4259b32ac 100644 --- a/Lib/python/std_map.i +++ b/Lib/python/std_map.i @@ -39,8 +39,8 @@ static PyObject *from(const map_type& map) { size_type size = map.size(); - int pysize = size <= INT_MAX ? (int) size : 0; - if (!pysize) { + int pysize = (size <= (size_type) INT_MAX) ? (int) size : -1; + if (pysize < 0) { PyErr_SetString(PyExc_OverflowError, "map size not valid in python"); Py_INCREF(Py_None); @@ -89,8 +89,8 @@ PyObject* keys() { Map::size_type size = self->size(); - int pysize = size <= INT_MAX ? (int) size : 0; - if (!pysize) { + int pysize = (size <= (Map::size_type) INT_MAX) ? (int) size : -1; + if (pysize < 0) { PyErr_SetString(PyExc_OverflowError, "map size not valid in python"); Py_INCREF(Py_None); @@ -106,8 +106,8 @@ PyObject* values() { Map::size_type size = self->size(); - int pysize = size <= INT_MAX ? (int) size : 0; - if (!pysize) { + int pysize = (size <= (Map::size_type) INT_MAX) ? (int) size : -1; + if (pysize < 0) { PyErr_SetString(PyExc_OverflowError, "map size not valid in python"); Py_INCREF(Py_None); @@ -123,8 +123,8 @@ PyObject* items() { Map::size_type size = self->size(); - int pysize = size <= INT_MAX ? (int) size : 0; - if (!pysize) { + int pysize = (size <= (Map::size_type) INT_MAX) ? (int) size : -1; + if (pysize < 0) { PyErr_SetString(PyExc_OverflowError, "map size not valid in python"); Py_INCREF(Py_None); @@ -145,8 +145,8 @@ PyObject* __iter__() { Map::size_type size = self->size(); - int pysize = size <= INT_MAX ? (int) size : 0; - if (!pysize) { + int pysize = (size <= (Map::size_type) INT_MAX) ? (int) size : -1; + if (pysize < 0) { PyErr_SetString(PyExc_OverflowError, "map size not valid in python"); Py_INCREF(Py_None); diff --git a/Lib/python/std_multimap.i b/Lib/python/std_multimap.i index e5b941b34..7b93f6434 100644 --- a/Lib/python/std_multimap.i +++ b/Lib/python/std_multimap.i @@ -38,8 +38,8 @@ static PyObject *from(const multimap_type& multimap) { size_type size = multimap.size(); - int pysize = size <= INT_MAX ? (int) size : 0; - if (!pysize) { + int pysize = (size <= (size_type) INT_MAX) ? (int) size : -1; + if (pysize < 0) { PyErr_SetString(PyExc_OverflowError, "multimap size not valid in python"); Py_INCREF(Py_None);