diff options
author | Hugo Parente Lima <hugo.pl@gmail.com> | 2010-12-13 18:36:53 -0200 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-08 16:12:48 -0300 |
commit | 97ea178de9327c8620943dd9101e45d18e6d185e (patch) | |
tree | 43751fdcc2681d4577eef63d9e643a959bc70cf5 /libshiboken | |
parent | db40f3e234f466e595ed618891aa2f50e403cd03 (diff) |
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')
-rw-r--r-- | libshiboken/conversions.h | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/libshiboken/conversions.h b/libshiboken/conversions.h index 8b312dfe1..11423ef6b 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) |