Displaying 13 results from an estimated 13 matches for "pylist_setitem".
Did you mean:
pylist_set_item
2017 May 09
1
[PATCH v2] python: add simple wrappers for PyObject<->string functions
...= 0; i < len; ++i)
+ r[i] = guestfs_int_py_asstring (PyList_GetItem (obj, i));
r[len] = NULL;
return r;
@@ -345,11 +332,7 @@ guestfs_int_py_put_string_list (char * const * const argv)
list = PyList_New (argc);
for (i = 0; i < argc; ++i) {
-#ifdef HAVE_PYSTRING_ASSTRING
- PyList_SetItem (list, i, PyString_FromString (argv[i]));
-#else
- PyList_SetItem (list, i, PyUnicode_FromString (argv[i]));
-#endif
+ PyList_SetItem (list, i, guestfs_int_py_fromstring (argv[i]));
}
return list;
@@ -367,15 +350,41 @@ guestfs_int_py_put_table (char * const * const argv)
list = PyL...
2017 May 11
1
[PATCH v2] RHBZ#1406906: check return value of Python object functions
...;;
- pr " PyObject *list;\n";
+ pr " PyObject *list, *element;\n";
pr " size_t i;\n";
pr "\n";
pr " list = PyList_New (%ss->len);\n" typ;
- pr " for (i = 0; i < %ss->len; ++i)\n" typ;
- pr " PyList_SetItem (list, i, guestfs_int_py_put_%s (&%ss->val[i]));\n" typ typ;
+ pr " if (list == NULL)\n";
+ pr " return NULL;\n";
+ pr " for (i = 0; i < %ss->len; ++i) {\n" typ;
+ pr " element = guestfs_int_py_put_%s (&%ss->val[i]);\n&...
2017 May 09
1
[PATCH] RHBZ#1406906: check return value of Python object functions
...;;
- pr " PyObject *list;\n";
+ pr " PyObject *list, *element;\n";
pr " size_t i;\n";
pr "\n";
pr " list = PyList_New (%ss->len);\n" typ;
- pr " for (i = 0; i < %ss->len; ++i)\n" typ;
- pr " PyList_SetItem (list, i, guestfs_int_py_put_%s (&%ss->val[i]));\n" typ typ;
+ pr " if (list == NULL)\n";
+ pr " return NULL;\n";
+ pr " for (i = 0; i < %ss->len; ++i) {\n" typ;
+ pr " element = guestfs_int_py_put_%s (&%ss->val[i]);\n&...
2014 Jan 15
0
[PATCH 3/4] hivex: python: Produce Unicode strings in get_* methods
...ator/generator.ml b/generator/generator.ml
index 1f2690d..908c5f3 100755
--- a/generator/generator.ml
+++ b/generator/generator.ml
@@ -2925,11 +2925,7 @@ put_string_list (char * const * const argv)
list = PyList_New (argc);
for (i = 0; i < argc; ++i) {
-#ifdef HAVE_PYSTRING_ASSTRING
- PyList_SetItem (list, i, PyString_FromString (argv[i]));
-#else
- PyList_SetItem (list, i, PyUnicode_FromString (argv[i]));
-#endif
+ PyList_SetItem (list, i, PyUnicode_DecodeUTF8 (argv[i], strlen (argv[i]), NULL));
}
return list;
@@ -2985,11 +2981,7 @@ put_val_type (char *val, size_t len, hive_type...
2017 May 09
0
[PATCH] python: add simple wrappers for PyObject<->string functions
...y_r = PyUnicode_FromString (str);
-#endif
+ py_r = guestfs_int_py_fromstring (str);
free (str);
return py_r;
@@ -345,11 +341,7 @@ guestfs_int_py_put_string_list (char * const * const argv)
list = PyList_New (argc);
for (i = 0; i < argc; ++i) {
-#ifdef HAVE_PYSTRING_ASSTRING
- PyList_SetItem (list, i, PyString_FromString (argv[i]));
-#else
- PyList_SetItem (list, i, PyUnicode_FromString (argv[i]));
-#endif
+ PyList_SetItem (list, i, guestfs_int_py_fromstring (argv[i]));
}
return list;
@@ -367,15 +359,41 @@ guestfs_int_py_put_table (char * const * const argv)
list = PyL...
2017 May 06
5
[Bug 1406906] [PATCH 0/3] Fix segmentation fault in Python bindings
This series addresses the issue where non UTF8 file names in a guest image lead to libguestfs segfault with Python 3 APIs.
The core issue is the APIs are not checking the return value when constructing a new PyObject. Therefore NULL pointers are added to Python collections (lists and dictionaries) crashing the application.
Few notes regarding the comments on the previous patch.
- Added a
2014 Jan 15
4
[PATCH 1/4] hivex: Python 2.6 does not have sysconfig.
---
configure.ac | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/configure.ac b/configure.ac
index 6785037..203f34f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -329,8 +329,8 @@ AS_IF([test "x$enable_python" != "xno"],
AC_MSG_CHECKING([for Python extension suffix (PEP-3149)])
if test -z "$PYTHON_EXT_SUFFIX"; then
2009 Aug 14
1
Code snippet to work out which RStruct/RStructList structs are used and how
--
Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones
virt-p2v converts physical machines to virtual machines. Boot with a
live CD or over the network (PXE) and turn machines into Xen guests.
http://et.redhat.com/~rjones/virt-p2v
-------------- next part --------------
>From 9efa77d717bd9bba5f61965eb6920429b7ae5d8e Mon Sep 17 00:00:00 2001
From: Richard W.M. Jones
2017 Apr 25
1
[Bug #1406906] [PATCH] python: fix segmentation fault when setting non UTF-8 strings
...;;
- pr " PyObject *list;\n";
+ pr " PyObject *list, *element;\n";
pr " size_t i;\n";
pr "\n";
pr " list = PyList_New (%ss->len);\n" typ;
- pr " for (i = 0; i < %ss->len; ++i)\n" typ;
- pr " PyList_SetItem (list, i, guestfs_int_py_put_%s (&%ss->val[i]));\n" typ typ;
+ pr " if (list == NULL) {\n";
+ pr " PyErr_SetString (PyExc_RuntimeError, \"PyList_New\");\n";
+ pr " return NULL;\n";
+ pr " }\n";
+ pr " for (i...
2017 Mar 18
0
[PATCH] python: check return value of Python APIs
...;;
- pr " PyObject *list;\n";
+ pr " PyObject *list, *element;\n";
pr " size_t i;\n";
pr "\n";
pr " list = PyList_New (%ss->len);\n" typ;
- pr " for (i = 0; i < %ss->len; ++i)\n" typ;
- pr " PyList_SetItem (list, i, guestfs_int_py_put_%s (&%ss->val[i]));\n" typ typ;
+ pr " if (list == NULL)\n";
+ pr " PyErr_SetString (PyExc_RuntimeError, \"PyList_New\");\n";
+ pr " return NULL;\n";
+ pr " }\n";
+ pr " for (i =...
2013 Sep 30
2
virNodeInfo returns MBytes instead of bytes
Hi,
http://www.libvirt.org/html/libvirt-libvirt.html#virNodeInfo says that
memory size is in kilobytes, however when I use this call I get an answer
in Megabytes, see below. The hypervisor has 16 GB of RAM.
$ python
Python 2.6.6 (r266:84292, Jul 10 2013, 22:48:45)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
Type "help", "copyright", "credits" or
2015 Sep 15
3
[PATCH 3/3] python: Allow bindings to be compiled with different version of libguestfs (RHBZ#1262983).
Patch to fix:
https://bugzilla.redhat.com/show_bug.cgi?id=1262983
Note this won't help until the first two patches get backported to the
stable branches, since <guestfs.h> won't define the necessary
GUESTFS_HAVE_* macros.
Rich.
2010 Sep 09
2
[PATCH]: add libxl python binding
...+ if ( NULL == list )
+ goto err_mem;
+
+ for(i = 0, cur = info; i < nr_dom; i++, cur++) {
+ Py_dominfo *di;
+ di = (Py_dominfo *)Pydominfo_New();
+ if ( NULL == di )
+ goto err_mem;
+ memcpy(&di->obj, cur, sizeof(di->obj));
+ PyList_SetItem(list, i, (PyObject *)di);
+ }
+
+ free(info);
+ return list;
+err_mem:
+ Py_DECREF(list);
+ PyErr_SetString(PyExc_MemoryError, "Allocating domain list");
+ return NULL;
+}
+
+static PyObject *pyxl_domid_to_name(XlObject *self, PyObject *args)
+{
+ char *domname;
+...