similar to: [PATCH] python: check return value of Python APIs

Displaying 20 results from an estimated 1000 matches similar to: "[PATCH] python: check return value of Python APIs"

2017 Apr 25
1
[Bug #1406906] [PATCH] python: fix segmentation fault when setting non UTF-8 strings
When constructing the returned objects, check the return value of Python APIs. A RuntimeError will be raised on failure pointing to the problematic entry and the field name. Signed-off-by: Matteo Cafasso <noxdafox@gmail.com> --- generator/python.ml | 143 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 97 insertions(+), 46 deletions(-) diff --git
2017 May 09
0
[PATCH] python: add simple wrappers for PyObject<->string functions
The current need for #ifdef's based on the presence of PyString_FromString makes both the OCaml code of the generator, and the generated C code a mess to read. Hence, add three simple wrappers to make both the OCaml, and C code more readable, and easier to tweak in the future. --- generator/python.ml | 72 ++++++++++++----------------------------------------- python/handle.c | 52
2017 May 09
1
[PATCH v2] python: add simple wrappers for PyObject<->string functions
The current need for #ifdef's based on the presence of PyString_FromString makes both the OCaml code of the generator, and the generated C code a mess to read. Hence, add three simple wrappers to make both the OCaml, and C code more readable, and easier to tweak in the future. --- generator/python.ml | 72 ++++++++++++----------------------------------------- python/handle.c | 65
2017 May 11
1
[PATCH v2] RHBZ#1406906: check return value of Python object functions
Verify the returned values of Python Object constructor functions are not NULL before adding them to a collection. This is particularly relevant when constructing Unicode strings in Python 3 as they will return NULL if non UTF-8 characters are present. Signed-off-by: Matteo Cafasso <noxdafox@gmail.com> --- generator/python.ml | 102 ++++++++++++++++++++++++++---------------
2017 May 09
1
[PATCH] RHBZ#1406906: check return value of Python object functions
Verify the returned values of Python Object constructor functions are not NULL before adding them to a collection. This is particularly relevant when constructing Unicode strings in Python 3 as they will return NULL if non UTF-8 characters are present. Signed-off-by: Matteo Cafasso <noxdafox@gmail.com> --- generator/python.ml | 102 ++++++++++++++++++++++++++---------------
2014 Jan 15
0
[PATCH 3/4] hivex: python: Produce Unicode strings in get_* methods
--- generator/generator.ml | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/generator/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
2019 Jan 22
0
[PATCH v2 2/2] python: change types for RBufferOut/FBuffer with Python 3 (RHBZ#1661871)
So far RBufferOut return values, and FBuffer struct fields are 'str' on all the versions of Python. Python 3 distinguishes between 'str' (unicode strings), and 'bytes', with 'str' no more able to hold arbitrary data. For this reason, switch the return value of RBufferOut functions, and FBuffer struct fields to bytes on Python 3: while this is a potentially
2020 Jan 09
0
[PATCH 5/7] python: replace guestfs_int_py_fromstringsize in Py2 branches
In Python 2 code branches use PyString_FromStringAndSize directly instead of the guestfs_int_py_fromstringsize wrapper (which calls PyString_FromStringAndSize anyway on Python < 3). --- generator/python.ml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/generator/python.ml b/generator/python.ml index 2a1a48fc0..0e1ed20d8 100644 --- a/generator/python.ml +++
2015 Feb 14
0
[PATCH] python: Call PyErr_Clear() on non-error paths out of the Python bindings.
We also need to be more careful about PyString_FromString and similar functions returning NULL on failure. Currently we don't check this every time. This commit adds more checks, but is still not complete. --- TODO | 6 ------ generator/python.ml | 19 +++++++++++++++---- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/TODO b/TODO index 075bdc6..666400e
2016 Apr 01
1
[PATCH] python: Fix bug in code generator
When a struct containing FChar fields is defined in generator/structs.ml, the Python code generator will generate code referencing a dirent struct instead of the correct one thus breaking at compile time. This bug was left unnoticed because the dirent struct is the only one using FChar fields. Yet it prevents any other struct from using such fields. Signed-off-by: Matteo Cafasso <noxdafox at
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
2016 Apr 01
0
[PATCH] python: Fix bug in code generator
EDIT: forgot to add the list to the subject, sorry for the spam. When a struct containing FChar fields is defined in generator/structs.ml, the Python code generator will generate code referencing a dirent struct instead of the correct one thus breaking at compile time. This bug was left unnoticed because the dirent struct is the only one using FChar fields. Yet it prevents any other struct from
2014 Aug 08
2
[PATCH 1/2] Add type checking, support integers as value
Before this patch, Python would segfault once you pass a non-string key or value to node_set_value. It was also not possible to set bytes on Python 3 as Unicode was assumed (Python 2 was not affected by this). This patch fixes recognition of bytes for Python 3, but in addition it recognizes ints (includes 'long' in Python 2) for DWORD (LE + BE) and QWORDs. For this purpose, a new field
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",
2009 Aug 03
1
[PATCH 1/2] Convert all TABs-as-indentation to spaces.
Per discussion on IRC, here are two changes to convert all TABs-as-indentation to spaces. The first one is the fully-automated conversion. However, note that the command mentioned uses a file (the .x-sc* one) that is added only in the following patch. The second patch adds rules to help keep things that way: Document and enforce the new spaces-only indentation policy. * cfg.mk
2017 May 11
1
[PATCH] python: improve few exceptions thrown on error
Make use of functions and types that fit more, and that do the same job: - use PyErr_NoMemory() on malloc failure - use PyErr_SetFromErrno when setting an exception from an errno - throw TypeError if not getting a list when required --- python/handle.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/python/handle.c b/python/handle.c index 88024e1..9746dca 100644 ---
2019 Jan 22
0
[PATCH 2/2] python: change return type for RBufferOut with Python 3 (RHBZ#1661871)
So far RBufferOut return values are 'str' on all the versions of Python. Python 3 distinguishes between 'str' (unicode strings), and 'bytes', with 'str' no more able to hold arbitrary data. For this reason, switch the return value of RBufferOut functions to bytes on Python 3: while this is a potentially incompatibile change, this is the only way to handle safely
2020 Jan 09
9
[PATCH 0/7] Various Python cleanups.
Patch #7 depends on: https://www.redhat.com/archives/libguestfs/2020-January/msg00035.html No, Python < 3 support is not dropped yet, however it will be easier after this series. Pino Toscano (7): build: enforce a minimum Python version python: drop code for Python < 2.5 python: assume support for Capsules python: remove compile time check for PyString_AsString python: replace
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
2020 Jun 01
1
[PATCH] erlang: Port to libei for Erlang 23
From: Sergei Golovan <sgolovan@gmail.com> Replace the use of liberl_interface, which is removed in Erlang 23, by libei. The implementation uses the ei_decode_iodata() function which has been introduces only for Erlang 23, so it doesnt work with earlier Erlang versions. --- erlang/Makefile.am | 1 - erlang/main.c | 312 +++++++++++++++++++++++++-------------------