mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Simplify code
This commit is contained in:
parent
2452fbc928
commit
10e5697740
@ -16,11 +16,9 @@
|
|||||||
static inline PyObject*
|
static inline PyObject*
|
||||||
set_error_from_hresult(PyObject *exc_type, const char *file, const int line, const HRESULT hr, const char *prefix="", PyObject *name=NULL) {
|
set_error_from_hresult(PyObject *exc_type, const char *file, const int line, const HRESULT hr, const char *prefix="", PyObject *name=NULL) {
|
||||||
_com_error err(hr);
|
_com_error err(hr);
|
||||||
LPCWSTR msg = err.ErrorMessage();
|
PyObject *pmsg = PyUnicode_FromWideChar(err.ErrorMessage(), -1);
|
||||||
PyObject *pmsg = PyUnicode_FromWideChar(msg, -1);
|
if (name) PyErr_Format(exc_type, "%s:%d:%s:[%li] %V: %S", file, line, prefix, hr, pmsg, "Out of memory", name);
|
||||||
PyObject *ans;
|
else PyErr_Format(exc_type, "%s:%d:%s:[%li] %V", file, line, prefix, hr, pmsg, "Out of memory");
|
||||||
if (name) ans = PyErr_Format(exc_type, "%s:%d:%s:[%li] %V: %S", file, line, prefix, hr, pmsg, "Out of memory", name);
|
|
||||||
else ans = PyErr_Format(exc_type, "%s:%d:%s:[%li] %V", file, line, prefix, hr, pmsg, "Out of memory");
|
|
||||||
Py_CLEAR(pmsg);
|
Py_CLEAR(pmsg);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user