From ad3f147c5613eb747fd4824ee150a41679c2bbdf Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 22 Apr 2021 21:30:17 +0530 Subject: [PATCH] DRYer --- .../devices/mtp/windows/content_enumeration.cpp | 2 +- src/calibre/utils/cpp_binding.h | 10 +--------- 2 files changed, 2 insertions(+), 10 deletions(-) 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;