summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorTony Asleson <tasleson@redhat.com>2013-09-26 12:19:18 -0500
committerTony Asleson <tasleson@redhat.com>2013-11-19 14:40:42 -0600
commitfe5b538c14c47e2e206d13c17f0225e39470d720 (patch)
treea4a62c98557eb970d6d9d2b66da4db67b9f4c19c /python
parent0c7a7d4d8433965313120254b68199525871b6a6 (diff)
downloadlvm2-fe5b538c14c47e2e206d13c17f0225e39470d720.tar.gz
lvm2app: Reset buffer after retrieving error message
The error buffer will stack error messages which is fine. However, once you retrieve the error messages it doesn't make sense to keep appending for each additional error message when running in the context of a library call. This patch clears and resets the buffer after the user retrieves the error message. Signed-off-by: Tony Asleson <tasleson@redhat.com>
Diffstat (limited to 'python')
-rw-r--r--python/liblvm.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/python/liblvm.c b/python/liblvm.c
index 330ef1423..6abd5ffd1 100644
--- a/python/liblvm.c
+++ b/python/liblvm.c
@@ -141,6 +141,7 @@ static lvobject *_create_py_lv(vgobject *parent, lv_t lv)
static PyObject *_liblvm_get_last_error(void)
{
PyObject *info;
+ const char *msg = NULL;
LVM_VALID(NULL);
@@ -148,7 +149,9 @@ static PyObject *_liblvm_get_last_error(void)
return NULL;
PyTuple_SetItem(info, 0, PyInt_FromLong((long) lvm_errno(_libh)));
- PyTuple_SetItem(info, 1, PyString_FromString(lvm_errmsg(_libh)));
+ msg = lvm_errmsg(_libh);
+ PyTuple_SetItem(info, 1, ((msg) ? PyString_FromString(msg) :
+ PyString_FromString("Memory error while retrieving error message")));
return info;
}