summaryrefslogtreecommitdiffstats
path: root/libshiboken/conversions.h
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2010-12-13 18:36:53 -0200
committerHugo Parente Lima <hugo.pl@gmail.com>2010-12-13 19:03:22 -0200
commit66bb59f9be9f7f38af48b1c4dc1108017c06ef72 (patch)
tree80fd1f69416ba3aa7891475791056f67dc62e1e6 /libshiboken/conversions.h
parent701b31ef3ddae7c43380d1513f9938f70f46eb7e (diff)
downloadshiboken-66bb59f9be9f7f38af48b1c4dc1108017c06ef72.tar.gz
shiboken-66bb59f9be9f7f38af48b1c4dc1108017c06ef72.tar.xz
shiboken-66bb59f9be9f7f38af48b1c4dc1108017c06ef72.zip
Fix bug#513 - "Hardcoded bool return type for operator overloads"
Reviewer: Renato Ara├║jo <renato.filho@openbossa.org> Luciano Wolf <luciano.wolf@openbossa.org>
Diffstat (limited to 'libshiboken/conversions.h')
-rw-r--r--libshiboken/conversions.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/libshiboken/conversions.h b/libshiboken/conversions.h
index 8b312dfe..11423ef6 100644
--- a/libshiboken/conversions.h
+++ b/libshiboken/conversions.h
@@ -203,7 +203,7 @@ struct ValueTypeConverter
template <typename T>
struct ObjectTypeConverter
{
- static inline bool checkType(PyObject* pyObj) { return PyObject_TypeCheck(pyObj, SbkType<T>()); }
+ static inline bool checkType(PyObject* pyObj) { return pyObj == Py_None || PyObject_TypeCheck(pyObj, SbkType<T>()); }
/// Py_None objects are the only objects convertible to an object type (in the form of a NULL pointer).
static inline bool isConvertible(PyObject* pyObj) { return pyObj == Py_None || PyObject_TypeCheck(pyObj, SbkType<T>()); }
/// Convenience overload that calls "toPython(const T*)" method.
@@ -452,7 +452,8 @@ struct EnumConverter
template <typename CString>
struct Converter_CString
{
- static inline bool checkType(PyObject* pyObj) { return PyString_Check(pyObj); }
+ // Note: 0 is also a const char* in C++, so None is accepted in checkType
+ static inline bool checkType(PyObject* pyObj) { return pyObj == Py_None || PyString_Check(pyObj); }
static inline bool isConvertible(PyObject* pyObj) { return pyObj == Py_None || PyString_Check(pyObj); }
static inline PyObject* toPython(void* cppobj) { return toPython(reinterpret_cast<CString>(cppobj)); }
static inline PyObject* toPython(CString cppobj)