diff options
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 |