|
|
|
|
|
|
|
|
|
|
xen-changelog
[Xen-changelog] Change read and list to return None if key/dir doesn't e
# HG changeset patch
# User cl349@xxxxxxxxxxxxxxxxxxxx
# Node ID c66a660872e7ab730e4e35dc613280530713fca6
# Parent 89ed236b6b66a66e2f0b0fb977e48cd943ce9dc1
Change read and list to return None if key/dir doesn't exist.
Signed-off-by: Christian Limpach <Christian.Limpach@xxxxxxxxxxxx>
diff -r 89ed236b6b66 -r c66a660872e7 tools/python/xen/lowlevel/xs/xs.c
--- a/tools/python/xen/lowlevel/xs/xs.c Tue Sep 13 10:42:15 2005
+++ b/tools/python/xen/lowlevel/xs/xs.c Tue Sep 13 14:45:34 2005
@@ -74,6 +74,7 @@
" path [string]: xenstore path\n" \
"\n" \
"Returns: [string] data read.\n" \
+ " None if key doesn't exist.\n" \
"Raises RuntimeError on error.\n" \
"\n"
@@ -97,7 +98,11 @@
xsval = xs_read(xh, path, &xsval_n);
Py_END_ALLOW_THREADS
if (!xsval) {
- PyErr_SetFromErrno(PyExc_RuntimeError);
+ if (errno == ENOENT) {
+ Py_INCREF(Py_None);
+ val = Py_None;
+ } else
+ PyErr_SetFromErrno(PyExc_RuntimeError);
goto exit;
}
val = PyString_FromStringAndSize(xsval, xsval_n);
@@ -160,6 +165,7 @@
" path [string]: path to list.\n" \
"\n" \
"Returns: [string array] list of subdirectory names.\n" \
+ " None if key doesn't exist.\n" \
"Raises RuntimeError on error.\n" \
"\n"
@@ -183,12 +189,17 @@
xsval = xs_directory(xh, path, &xsval_n);
Py_END_ALLOW_THREADS
if (!xsval) {
- PyErr_SetFromErrno(PyExc_RuntimeError);
- goto exit;
+ if (errno == ENOENT) {
+ Py_INCREF(Py_None);
+ val = Py_None;
+ } else
+ PyErr_SetFromErrno(PyExc_RuntimeError);
+ goto exit;
}
val = PyList_New(xsval_n);
for (i = 0; i < xsval_n; i++)
PyList_SetItem(val, i, PyString_FromString(xsval[i]));
+ free(xsval);
exit:
return val;
}
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|
<Prev in Thread] |
Current Thread |
[Next in Thread> |
- [Xen-changelog] Change read and list to return None if key/dir doesn't exist.,
Xen patchbot -unstable <=
|
|
|
|
|