Thanks your help and useful messages.
This issue is so small and i just want to fix the ret = NULL with no exception.
So i want to make ret = -1 and make the "SystemError: error return without exception
set" disappear.
Thanks,
Luyao Huang
----- Original Message -----
From: "Peter Krempa" <pkrempa(a)redhat.com>
To: "Luyao Huang" <lhuang(a)redhat.com>, libvir-list(a)redhat.com
Sent: Monday, October 20, 2014 2:37:21 PM
Subject: Re: [libvirt] [libvirt-python v2 PATCH] Improve error output when use getTime
with a nonzero flags.
On 10/17/14 04:12, Luyao Huang wrote:
When give a nonzero flags to getTime, c_retval will get -1 and goto
cleanup.
But py_retval still is NULL,so pass c_retval value to py_retval.
This will make the output message more correct.
error before use this patch:
SystemError: error return without exception set
after use the patch:
libvirtError: unsupported flags (0x1) in function qemuDomainGetTime
v1:
https://www.redhat.com/archives/libvir-list/2014-October/msg00482.html
Signed-off-by: Luyao Huang <lhuang(a)redhat.com>
---
libvirt-override.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/libvirt-override.c b/libvirt-override.c
index 9ba87eb..c779aa3 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -7757,9 +7757,11 @@ libvirt_virDomainGetTime(PyObject *self ATTRIBUTE_UNUSED, PyObject
*args) {
c_retval = virDomainGetTime(domain, &seconds, &nseconds, flags);
LIBVIRT_END_ALLOW_THREADS;
- if (c_retval < 0)
+ if (c_retval < 0){
Missing space before '{'
+ py_retval = libvirt_intWrap(c_retval);
Returning the return value from the C api is useless here. The function
returns a dict on success path thus on error you should return None
(VIR_PY_NONE).
goto cleanup;
-
+ }
+
if (!(pyobj_seconds = libvirt_longlongWrap(seconds)) ||
PyDict_SetItemString(dict, "seconds", pyobj_seconds) < 0)
goto cleanup;
Peter