summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRenato Filho <renato.filho@openbossa.org>2010-09-03 16:16:26 -0300
committerRenato Filho <renato.filho@openbossa.org>2010-09-03 17:16:59 -0300
commit5d23ed3a8801b7152e2c3a601e3bb64595d79046 (patch)
treec78c2e43cc262f070b9d3c2768c3e99563a4a403
parent3fed4510716ad6444c77ecd50466f514e1f03848 (diff)
downloadshiboken-5d23ed3a8801b7152e2c3a601e3bb64595d79046.tar.gz
shiboken-5d23ed3a8801b7152e2c3a601e3bb64595d79046.tar.xz
shiboken-5d23ed3a8801b7152e2c3a601e3bb64595d79046.zip
Avoid call functions when an error occurs on argument conversion.
Reviewer: Luciano Wolf <luciano.wolf@openbossa.org> Hugo Parente Lima <hugo.pl@gmail.com>
-rw-r--r--cppgenerator.cpp2
-rw-r--r--tests/libsample/point.h2
-rw-r--r--tests/samplebinding/point_test.py5
3 files changed, 9 insertions, 0 deletions
diff --git a/cppgenerator.cpp b/cppgenerator.cpp
index af8ac8d1..cf162ede 100644
--- a/cppgenerator.cpp
+++ b/cppgenerator.cpp
@@ -1769,9 +1769,11 @@ void CppGenerator::writeSingleFunctionCall(QTextStream& s, const OverloadData& o
int numRemovedArgs = OverloadData::numberOfRemovedArguments(func);
+ s << INDENT << "if(!PyErr_Occurred()) {" << endl;
writeMethodCall(s, func, func->arguments().size() - numRemovedArgs);
if (!func->isConstructor())
writeNoneReturn(s, func, overloadData.hasNonVoidReturnType());
+ s << INDENT << "}" << endl;
}
void CppGenerator::writeNamedArgumentResolution(QTextStream& s, const AbstractMetaFunction* func, bool usePyArgs)
diff --git a/tests/libsample/point.h b/tests/libsample/point.h
index 585f9499..cfd1f251 100644
--- a/tests/libsample/point.h
+++ b/tests/libsample/point.h
@@ -52,6 +52,8 @@ public:
inline void setX(double x) { m_x = x; }
inline void setY(double y) { m_y = y; }
+ inline void setXAsUint(unsigned int x) { m_x = x; }
+ inline void setYAsUint(unsigned int y) { m_y = y; }
Point* copy() const;
diff --git a/tests/samplebinding/point_test.py b/tests/samplebinding/point_test.py
index d1ae3eed..752302c7 100644
--- a/tests/samplebinding/point_test.py
+++ b/tests/samplebinding/point_test.py
@@ -78,6 +78,11 @@ class PointTest(unittest.TestCase):
self.assertEqual(sys.getrefcount(pt1), refcount1 + 1)
self.assertEqual(sys.getrefcount(pt1), sys.getrefcount(pt2))
+ def testUintOverflow(self):
+ pt1 = Point(0.0, 0.0)
+ self.assertRaises(OverflowError, pt1.setXAsUint, 840835495615213080)
+ self.assertEqual(pt1.x(), 0.0)
+
if __name__ == '__main__':
unittest.main()