From e583bf6d74322a08afb8b22d0650f2ca97d01ccc Mon Sep 17 00:00:00 2001 From: Christian Walther Date: Mon, 9 Apr 2012 09:50:40 +0200 Subject: [PATCH] Also handle Python long integers in addVarNumber. --- .../Plasma/FeatureLib/pfPython/pyNotifyGlue.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/FeatureLib/pfPython/pyNotifyGlue.cpp b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/FeatureLib/pfPython/pyNotifyGlue.cpp index 2dc689f0..f7a46845 100644 --- a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/FeatureLib/pfPython/pyNotifyGlue.cpp +++ b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/FeatureLib/pfPython/pyNotifyGlue.cpp @@ -207,6 +207,21 @@ PYTHON_METHOD_DEFINITION(ptNotify, addVarNumber, args) self->fThis->AddVarNull(name); else if (PyInt_Check(number)) self->fThis->AddVarNumber(name, PyInt_AsLong(number)); + else if (PyLong_Check(number)) + { + // try as int first + Int32 i = (Int32)PyLong_AsLong(number); + if (!PyErr_Occurred()) + { + self->fThis->AddVarNumber(name, i); + } + else + { + // OverflowError, try float + PyErr_Clear(); + self->fThis->AddVarNumber(name, (float)PyLong_AsDouble(number)); + } + } else if (PyNumber_Check(number)) { PyObject* f = PyNumber_Float(number);