search for: pydict_setitemstring

Displaying 20 results from an estimated 22 matches for "pydict_setitemstring".

2017 Mar 18
0
[PATCH] python: check return value of Python APIs
...pr " if (dict == NULL) {\n"; + pr " PyErr_SetString (PyExc_RuntimeError, \"PyDict_New\");\n"; + pr " return NULL;\n"; + pr " }\n"; List.iter ( function | name, FString -> - pr " PyDict_SetItemString (dict, \"%s\",\n" name; pr "#ifdef HAVE_PYSTRING_ASSTRING\n"; - pr " PyString_FromString (%s->%s));\n" - typ name; + pr " value = PyString_FromString (%s->%s);\n" typ name;...
2017 Apr 25
1
[Bug #1406906] [PATCH] python: fix segmentation fault when setting non UTF-8 strings
...pr " if (dict == NULL) {\n"; + pr " PyErr_SetString (PyExc_RuntimeError, \"PyDict_New\");\n"; + pr " return NULL;\n"; + pr " }\n"; List.iter ( function | name, FString -> - pr " PyDict_SetItemString (dict, \"%s\",\n" name; pr "#ifdef HAVE_PYSTRING_ASSTRING\n"; - pr " PyString_FromString (%s->%s));\n" - typ name; + pr " value = PyString_FromString (%s->%s);\n" typ name;...
2017 May 11
1
[PATCH v2] RHBZ#1406906: check return value of Python object functions
...pr " PyObject *dict, *value;\n"; pr "\n"; pr " dict = PyDict_New ();\n"; + pr " if (dict == NULL)\n"; + pr " return NULL;\n"; List.iter ( function | name, FString -> - pr " PyDict_SetItemString (dict, \"%s\",\n" name; - pr " guestfs_int_py_fromstring (%s->%s));\n" - typ name + pr " value = guestfs_int_py_fromstring (%s->%s);" typ name; + pr " if (value == NULL)\n"; +...
2017 May 09
1
[PATCH] RHBZ#1406906: check return value of Python object functions
...pr " PyObject *dict, *value;\n"; pr "\n"; pr " dict = PyDict_New ();\n"; + pr " if (dict == NULL)\n"; + pr " return NULL;\n"; List.iter ( function | name, FString -> - pr " PyDict_SetItemString (dict, \"%s\",\n" name; - pr " guestfs_int_py_fromstring (%s->%s));\n" - typ name + pr " value = guestfs_int_py_fromstring (%s->%s);" typ name; + pr " if (value == NULL)\n"; +...
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
2017 May 09
1
[PATCH v2] python: add simple wrappers for PyObject<->string functions
...ring (const char *str); +extern PyObject *guestfs_int_py_fromstringsize (const char *str, size_t size); +extern char *guestfs_int_py_asstring (PyObject *obj); "; @@ -178,31 +181,16 @@ and generate_python_structs () = function | name, FString -> pr " PyDict_SetItemString (dict, \"%s\",\n" name; - pr "#ifdef HAVE_PYSTRING_ASSTRING\n"; - pr " PyString_FromString (%s->%s));\n" - typ name; - pr "#else\n"; - pr " PyU...
2017 May 09
0
[PATCH] python: add simple wrappers for PyObject<->string functions
...ring (const char *str); +extern PyObject *guestfs_int_py_fromstringsize (const char *str, size_t size); +extern char *guestfs_int_py_asstring (PyObject *obj); "; @@ -178,31 +181,16 @@ and generate_python_structs () = function | name, FString -> pr " PyDict_SetItemString (dict, \"%s\",\n" name; - pr "#ifdef HAVE_PYSTRING_ASSTRING\n"; - pr " PyString_FromString (%s->%s));\n" - typ name; - pr "#else\n"; - pr " PyU...
2016 Apr 01
1
[PATCH] python: Fix bug in code generator
...a/generator/python.ml b/generator/python.ml index 9663fb4..9d9dc4a 100644 --- a/generator/python.ml +++ b/generator/python.ml @@ -225,10 +225,12 @@ put_table (char * const * const argv) | name, FChar -> pr "#ifdef HAVE_PYSTRING_ASSTRING\n"; pr " PyDict_SetItemString (dict, \"%s\",\n" name; - pr " PyString_FromStringAndSize (&dirent->%s, 1));\n" name; + pr " PyString_FromStringAndSize (&%s->%s, 1));\n" + typ name; pr &qu...
2016 Apr 01
0
[PATCH] python: Fix bug in code generator
...a/generator/python.ml b/generator/python.ml index 9663fb4..9d9dc4a 100644 --- a/generator/python.ml +++ b/generator/python.ml @@ -225,10 +225,12 @@ put_table (char * const * const argv) | name, FChar -> pr "#ifdef HAVE_PYSTRING_ASSTRING\n"; pr " PyDict_SetItemString (dict, \"%s\",\n" name; - pr " PyString_FromStringAndSize (&dirent->%s, 1));\n" name; + pr " PyString_FromStringAndSize (&%s->%s, 1));\n" + typ name; pr &qu...
2018 Jan 30
0
Re: python 3 bindings on libguestfs
The interesting line is this one ... checking for PyString_AsString in -lc... no and if you compare that to the code, eg in python/guestfs-py.c: #ifdef HAVE_PYSTRING_ASSTRING PyDict_SetItemString (dict, "ftyp", PyString_FromStringAndSize (&dirent->ftyp, 1)); #else PyDict_SetItemString (dict, "ftyp", PyUnicode_FromStringAndSize (&dirent->ftyp, 1)); #endif So it shouldn't be using that function (PyString_...
2019 Jan 22
0
[PATCH v2 2/2] python: change types for RBufferOut/FBuffer with Python 3 (RHBZ#1661871)
...+ 1 file changed, 9 insertions(+) diff --git a/generator/python.ml b/generator/python.ml index a70faec8c..bc5af528c 100644 --- a/generator/python.ml +++ b/generator/python.ml @@ -195,8 +195,13 @@ and generate_python_structs () = pr " goto err;\n"; pr " PyDict_SetItemString (dict, \"%s\", value);\n" name; | name, FBuffer -> + pr "#if PY_MAJOR_VERSION >= 3\n"; + pr " value = PyBytes_FromStringAndSize (%s->%s, %s->%s_len);\n" + typ name typ name; + pr "#else\n&quo...
2019 Jan 22
3
[PATCH v2 0/2] python: fixes for Python 3
A couple of fixes for Python 3 to the Python binding. Unfortunately a behaviour change is needed, although it fixes broken types used. Changes from v1: - handle also FBuffer in structs Pino Toscano (2): python: fix call of Python handlers of events python: change types for RBufferOut/FBuffer with Python 3 (RHBZ#1661871) generator/python.ml | 9 +++++++++ python/handle.c | 3 ++- 2
2018 Apr 11
0
[nbdkit PATCH v2 4/5] python: Expose FUA support
...ython_failure ("pwrite"); + Py_DECREF (fn); + return -1; + } + kwargs = PyDict_New (); + if (!kwargs) { + check_python_failure ("pwrite"); + Py_DECREF (args); + Py_DECREF (fn); + return -1; + } + if (pwrite_has_fua && + PyDict_SetItemString (kwargs, "fua", + fua ? Py_True : Py_False) == -1) { + check_python_failure ("pwrite"); + Py_DECREF (kwargs); + Py_DECREF (args); + Py_DECREF (fn); + return -1; + } + r = PyObject_Call (fn, args, kwargs); Py_DECREF...
2006 Sep 29
4
[PATCH 4/6] xen: export NUMA topology in physinfo hcall
..." , chunks[i].node_id, + "start_paddr", chunks[i].node_start_pfn << XC_PAGE_SHIFT, + "end_paddr" , (chunks[i].node_start_pfn + + chunks[i].node_spanned_pages) << XC_PAGE_SHIFT )); + } + PyDict_SetItemString(ret_obj, "mem_chunks", memchunk_obj); + + /* node to cpu mappings */ + node_to_cpu_obj = PyList_New(0); + /* build list of node to cpu mappings */ + for ( i=0; i<info.nr_nodes; i++ ) + { + uint64_t cpumap = (uint64_t)map[i]; + PyObject *cpus = PyList_New(0...
2019 Nov 25
6
[nbdkit PATCH 0/5] Counterproposal for python v2 interfaces
As mentioned in my reviews, I wonder if we should make our python callbacks look a bit more Pythonic by having kwargs added for each new flag that we want to expose. The idea was first floated here: https://www.redhat.com/archives/libguestfs/2018-April/msg00108.html Note that with my proposal, there is no need for a python script to expose a global API_VERSION variable; new flags are added
2020 Apr 20
0
[PATCH] python: Fix UnicodeError in inspect_list_applications2() (RHBZ#1684004)
..._py_fromstring (\"\");\n"; + pr " PyErr_Clear ();\n"; + pr " }\n"; + | _ -> pr ""; ); pr " if (value == NULL)\n"; pr " goto err;\n"; pr " PyDict_SetItemString (dict, \"%s\", value);\n" name; -- 2.26.1.301.g55bc3eb7cb9-goog
2020 Apr 20
2
[PATCH] python: Fix UnicodeError in inspect_list_applications2() (RHBZ#1684004)
..._py_fromstring (\"\");\n"; + pr " PyErr_Clear ();\n"; + pr " }\n"; + | _ -> pr ""; ); pr " if (value == NULL)\n"; pr " goto err;\n"; pr " PyDict_SetItemString (dict, \"%s\", value);\n" name; -- 2.26.1.301.g55bc3eb7cb9-goog
2018 Apr 11
10
[nbdkit PATCH v2 0/5] FUA support in Python scripts
First out of our four language bindings to add FUA support (for reference, I added 'zero' support for python, perl, and ruby back in 1.1.13, then Rich had to add it for ocaml in 1.1.20). I tested this heavily under python 2, but for now only compile tested under python 3; I plan to do further testing there and make any tweaks if necessary. I wrote patch 5 early on, but then realized I
2018 Apr 11
0
[nbdkit PATCH v2 1/5] python: Let zero's may_trim parameter be optional
...eck_python_failure ("zero"); + Py_DECREF (fn); + return -1; + } + kwargs = PyDict_New (); + if (!kwargs) { + check_python_failure ("zero"); + Py_DECREF (args); + Py_DECREF (fn); + return -1; + } + if (zero_may_trim && + PyDict_SetItemString (kwargs, "may_trim", + may_trim ? Py_True : Py_False) == -1) { + check_python_failure ("zero"); + Py_DECREF (kwargs); + Py_DECREF (args); + Py_DECREF (fn); + return -1; + } + r = PyObject_Call (fn, args, kwargs); P...
2009 Aug 03
1
[PATCH 1/2] Convert all TABs-as-indentation to spaces.
...ot; n + pr "\\@%s" n ) (snd style); pr ");" @@ -7293,47 +7293,47 @@ py_guestfs_close (PyObject *self, PyObject *args) pr "\n"; pr " dict = PyDict_New ();\n"; List.iter ( - function - | name, FString -> - pr " PyDict_SetItemString (dict, \"%s\",\n" name; - pr " PyString_FromString (%s->%s));\n" - typ name - | name, FBuffer -> - pr " PyDict_SetItemString (dict, \"%s\",\n" name; - pr " PyString_FromStringAnd...