diff options
author | Renato Filho <renato.filho@openbossa.org> | 2011-09-28 17:55:54 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-08 16:18:18 -0300 |
commit | b9ab302dd7aff3ecbbbc7ffe1ef2ef0bf4956a5a (patch) | |
tree | b2c62e3ae790b7c5a70f7308282ec2975aa168a2 /tests/samplebinding/handle_conversions.h | |
parent | 6b21c2fa5eeb6a7c7b6533f1c966a47d8ef07e69 (diff) |
Fixed tests to work with python3.x and python2.x
Diffstat (limited to 'tests/samplebinding/handle_conversions.h')
-rw-r--r-- | tests/samplebinding/handle_conversions.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/samplebinding/handle_conversions.h b/tests/samplebinding/handle_conversions.h index a6e561359..6e1093f6b 100644 --- a/tests/samplebinding/handle_conversions.h +++ b/tests/samplebinding/handle_conversions.h @@ -13,6 +13,8 @@ struct Converter<HANDLE> static inline bool isConvertible(PyObject* pyObj) { + if (pyObj == Py_None) + return true; #ifdef IS_PY3K return PyCapsule_CheckExact(pyObj); #else @@ -28,6 +30,8 @@ struct Converter<HANDLE> static inline PyObject* toPython(HANDLE cppobj) { + if (!cppobj) + Py_RETURN_NONE; #ifdef IS_PY3K return PyCapsule_New(cppobj, 0, 0); #else @@ -37,6 +41,9 @@ struct Converter<HANDLE> static inline HANDLE toCpp(PyObject* pyobj) { + if (pyobj == Py_None) + return (HANDLE) 0; + #ifdef IS_PY3K return (HANDLE) PyCapsule_GetPointer(pyobj, 0); #else |