summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2011-02-16 16:36:43 -0300
committerMarcelo Lira <marcelo.lira@openbossa.org>2011-02-17 10:51:09 -0300
commit30d71761e412b2b5cf833370f291e331ee237ec3 (patch)
tree998c1d84bcde8202a2794bcd6184caf368e6e430
parentd88de0d1776d9c88e52b40382e91669e66f9b708 (diff)
downloadshiboken-30d71761e412b2b5cf833370f291e331ee237ec3.tar.gz
shiboken-30d71761e412b2b5cf833370f291e331ee237ec3.tar.xz
shiboken-30d71761e412b2b5cf833370f291e331ee237ec3.zip
SbkNumber_Check now makes use of PyNumber_Check.
Plus some provisions to handle old-style classes. Reviewed by Bruno Ara├║jo <bruno.araujo@openbossa.org> Reviewed by Luciano Wolf <luciano.wolf@openbossa.org>
-rw-r--r--libshiboken/conversions.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/libshiboken/conversions.h b/libshiboken/conversions.h
index 11423ef6..e117dbe4 100644
--- a/libshiboken/conversions.h
+++ b/libshiboken/conversions.h
@@ -38,7 +38,9 @@
#define PyObject_Check(X) true
#include "autodecref.h"
-#define SbkNumber_Check(X) (PyInt_Check(X) || PyFloat_Check(X) || PyLong_Check(X))
+// Note: if there wasn't for the old-style classes, only a PyNumber_Check would suffice.
+#define SbkNumber_Check(X) \
+ (PyNumber_Check(X) && (!PyInstance_Check(X) || PyObject_HasAttrString(X, "__trunc__")))
namespace Shiboken
{