diff options
author | Pavel Hrdina <phrdina@redhat.com> | 2015-09-21 16:01:10 +0200 |
---|---|---|
committer | Pavel Hrdina <phrdina@redhat.com> | 2015-10-05 08:34:40 +0200 |
commit | 448295ed5eefafef71bb788cc2846587005ebab9 (patch) | |
tree | f0ed86ae2800de538ca7cee0b1c6971767742c4e | |
parent | b8222860959fbc92c1fc73d005ed505ae338003a (diff) | |
download | libvirt-python-448295ed5eefafef71bb788cc2846587005ebab9.tar.gz |
refactor the function to not override python exceptions
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
-rw-r--r-- | libvirt-override.c | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/libvirt-override.c b/libvirt-override.c index 4dfe332..f560f12 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -8243,7 +8243,6 @@ libvirt_virDomainGetTime(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { static PyObject * libvirt_virDomainSetTime(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { - PyObject *py_retval = NULL; PyObject *pyobj_domain; PyObject *pyobj_seconds; PyObject *pyobj_nseconds; @@ -8263,38 +8262,31 @@ libvirt_virDomainSetTime(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { if (PyDict_Check(py_dict)) { py_dict_size = PyDict_Size(py_dict); if ((pyobj_seconds = PyDict_GetItemString(py_dict, "seconds"))) { - if (libvirt_longlongUnwrap(pyobj_seconds, &seconds) < 0) { - PyErr_Format(PyExc_LookupError, "malformed 'seconds'"); - goto cleanup; - } + if (libvirt_longlongUnwrap(pyobj_seconds, &seconds) < 0) + return NULL; } else { PyErr_Format(PyExc_LookupError, "Dictionary must contains 'seconds'"); - goto cleanup; + return NULL; } if ((pyobj_nseconds = PyDict_GetItemString(py_dict, "nseconds"))) { - if (libvirt_uintUnwrap(pyobj_nseconds, &nseconds) < 0) { - PyErr_Format(PyExc_LookupError, "malformed 'nseconds'"); - goto cleanup; - } + if (libvirt_uintUnwrap(pyobj_nseconds, &nseconds) < 0) + return NULL; } else if (py_dict_size > 1) { PyErr_Format(PyExc_LookupError, "Dictionary contains unknown key"); - goto cleanup; + return NULL; } } else if (py_dict != Py_None || !flags) { PyErr_Format(PyExc_TypeError, "time must be a dictionary " "or None with flags set"); - goto cleanup; + return NULL; } LIBVIRT_BEGIN_ALLOW_THREADS; c_retval = virDomainSetTime(domain, seconds, nseconds, flags); LIBVIRT_END_ALLOW_THREADS; - py_retval = libvirt_intWrap(c_retval); - - cleanup: - return py_retval; + return libvirt_intWrap(c_retval); } #endif /* LIBVIR_CHECK_VERSION(1, 2, 5) */ |