From 9ac635b5d37266a3908b2067e2ae2bf624f33c2a Mon Sep 17 00:00:00 2001 From: "SND\\kernelnet_cp" Date: Fri, 20 Dec 2013 10:45:38 +0000 Subject: [PATCH] [0.2.x] fixed : issue #12599 (exception raised when comparing typeInfo with None ) git-svn-id: https://pykd.svn.codeplex.com/svn@86901 9b283d60-5439-405e-af05-b73fd8c4d996 --- pykd/pykdver.h | 2 +- pykd/variant.h | 25 +++++++++++++++++++++++-- test/scripts/typeinfo.py | 7 +++++++ 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/pykd/pykdver.h b/pykd/pykdver.h index e2e9113..3081774 100644 --- a/pykd/pykdver.h +++ b/pykd/pykdver.h @@ -2,7 +2,7 @@ #define PYKD_VERSION_MAJOR 0 #define PYKD_VERSION_MINOR 2 #define PYKD_VERSION_SUBVERSION 0 -#define PYKD_VERSION_BUILDNO 26 +#define PYKD_VERSION_BUILDNO 27 #define __VER_STR2__(x) #x diff --git a/pykd/variant.h b/pykd/variant.h index a431c5c..9162db9 100644 --- a/pykd/variant.h +++ b/pykd/variant.h @@ -1,5 +1,7 @@ #pragma once +#include "dbgexcept.h" + namespace pykd { typedef boost::variant BaseTypeVariant; @@ -81,6 +83,11 @@ public: } }; +inline bool isConvertable( python::object& obj ) +{ + return PyInt_Check(obj.ptr()) || PyLong_Check(obj.ptr()) || PyBool_Check(obj.ptr()); +} + class intBase { @@ -114,11 +121,25 @@ public: } python::object eq( python::object& obj ) { - return boost::apply_visitor( VariantToPyobj(), getValue() ) == obj; + + try { + return boost::apply_visitor( VariantToPyobj(), getValue() ) == obj; + } + catch( DbgException& ) + {} + + return python::object(false); } python::object ne( python::object& obj ) { - return boost::apply_visitor( VariantToPyobj(), getValue() ) != obj; + + try { + return boost::apply_visitor( VariantToPyobj(), getValue() ) != obj; + } + catch( DbgException& ) + {} + + return python::object(true); } python::object lt( python::object& obj ) { diff --git a/test/scripts/typeinfo.py b/test/scripts/typeinfo.py index 522cffb..0ccae3a 100644 --- a/test/scripts/typeinfo.py +++ b/test/scripts/typeinfo.py @@ -243,3 +243,10 @@ class TypeInfoTest( unittest.TestCase ): def testArrayOf(self): ti = pykd.typeInfo("UInt8B").arrayOf(10) self.assertTrue( "UInt8B[10]", ti.name() ) + + def testCompareWihNone(self): + ti = None + if ti == None: + ti = pykd.typeInfo("UInt8B") + if ti == None: + pass