diff --git a/src/calibre/devices/mtp/windows/content_enumeration.cpp b/src/calibre/devices/mtp/windows/content_enumeration.cpp index 181bc8f71f..db2013925d 100644 --- a/src/calibre/devices/mtp/windows/content_enumeration.cpp +++ b/src/calibre/devices/mtp/windows/content_enumeration.cpp @@ -502,7 +502,7 @@ get_files_and_folders(unsigned int level, IPortableDevice *device, CComPtr { - public: - explicit wchar_raii() noexcept { handle = NULL; } - explicit wchar_raii(wchar_t *h) noexcept { handle = h; } - explicit wchar_raii(PyObject *unicode_object) noexcept { - if (!unicode_object || !PyUnicode_Check(unicode_object)) { handle = NULL; PyErr_SetString(PyExc_TypeError, "Not a unicode object"); } - else handle = PyUnicode_AsWideCharString(unicode_object, NULL); - } -}; +typedef generic_raii wchar_raii; static inline void python_object_destructor(void *p) { PyObject *x = reinterpret_cast(p); Py_XDECREF(x); } typedef generic_raii pyobject_raii;