similar to: [PATCH] python: improve few exceptions thrown on error

Displaying 20 results from an estimated 300 matches similar to: "[PATCH] python: improve few exceptions thrown on error"

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
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 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
2014 Aug 04
6
[hivex] Segfault for an integer value to node_set_value
Hi, When an integer argument is passed as value, node_set_value segfaults. Reproducer is at the end of this message The backtrace points at hivex-py.c, function get_value. While obj is non-NULL, `bytes = PyUnicode_AsUTF8String (obj);` returns NULL. Kind regards, Peter https://lekensteyn.nl #!/usr/bin/env python3 import hivex, sys h = hivex.Hivex(sys.argv[1]) print(h) val = {
2014 Aug 16
7
[hivex] [PATCH 0/6] Python fixes for node_set_value
Hi, This patch series is based on a prior patch[1], splitting off changes as requested and incorporating feedback from Richard Jones. It introduces type validation to avoid segmentation faults (instead, it reports an exception) and fixes handling of the bytes type in Python 3. Major changes since that series: - Drop newly introduced support for integer types for DWORD/QWORDS - Reject Unicode
2017 Mar 18
0
[PATCH] python: check return value of Python APIs
Addressing issue #1406906. When constructing the returned objects, check the return value of Python APIs. This is especially relevant when dealing with non UTF-8 strings. 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
2003 May 18
1
Problems with the pyvorbis Python wrapper under Windows
Hi! The following Python code does what is excepted under Linux: >>> from ogg.vorbis import * >>> com=VorbisFile('01.ogg').comment() >>> com['title']='foo' >>> com.write_to('01.ogg') but under Windows I get the following error: Traceback (most recent call last): File "<stdin>", line 1, in ? IOError: [Errno
2019 Aug 09
0
[PATCH libnbd 1/2] generator: Handle closure args (cbargs) specially.
If we accept that callbacks will never handle the full range of parameters then we can simplify the generator quite a bit by using a special type for closure args vs normal method args. This removes many asserts and quite a bit of unreachable code (eg. Python code for handling ArrayAndLen in normal methods that was never used). The output of the generator after this commit should be identical.
2019 Jul 16
1
Re: [PATCH libnbd v2] generator: Define new Closure type instead of callbacks.
On 7/16/19 6:04 AM, Richard W.M. Jones wrote: > A Closure is a list of (usually one, but can be more) closures. In C > there is also a singe ‘void *user_data’ parameter which is passed by > the caller into the function and through as the first parameter of > each callback invocation. > > By grouping the previously separate Opaque and Callback* parameters > together we can
2020 Sep 10
1
[libnbd PATCH] python: Fix more memory leaks
h.nbd_connect_command was leaking a python object per parameter, and also leaks memory on failure. In fact, it was possible to segfault on something as trivial as: nbdsh -c 'h.connect_command(["true",1])' h.nbd_pread was leaking a read buffer on every single synchronous read. My previous patch to address closure callbacks had a bug in h.nbd_pread_structured and similar: if the
2019 Jun 28
3
[PATCH libnbd v2] python: Raise a custom exception containing error string and errno.
This kind of fixes the problems in v1. The exception still primarily lives in the libnbdmod and you could still refer to it using libnbdmod.Error (but don't do that). However when the exception is printed it now appears as nbd.Error, and you can catch it also using the same name. Other problems: - There is no "nice" interface to accessing the exception fields. You have to use
2019 Aug 12
0
[PATCH libnbd 6/7] python: Use free callback to free closure root.
Same as the previous commit, but for Python. --- generator/generator | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/generator/generator b/generator/generator index 109fad6..a0322ee 100755 --- a/generator/generator +++ b/generator/generator @@ -4315,9 +4315,6 @@ let print_python_binding name { args; optargs; ret; may_set_error } = ) cbargs; pr
2020 Sep 08
0
[libnbd PATCH] hack for testing python closure leaks: NOT FOR COMMIT
Just posting this for posterity, on something I used to track down memory leaks related to python closures. --- generator/Python.ml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/generator/Python.ml b/generator/Python.ml index 4a96cf6..2ff17dd 100644 --- a/generator/Python.ml +++ b/generator/Python.ml @@ -578,9 +578,27 @@ let generate_python_methods_c () = pr "
2006 Aug 30
3
arch-specific xc.c code?
Hi Ewan/Alistair, I have a patch that looks like this: diff -r a39ad4c78850 tools/libxc/xenctrl.h --- a/tools/libxc/xenctrl.h Wed Aug 30 13:51:12 2006 +0100 +++ b/tools/libxc/xenctrl.h Wed Aug 30 15:11:20 2006 -0500 @@ -416,6 +416,10 @@ int xc_domain_memory_populate_physmap(in unsigned int address_bits, xen_pfn_t
2005 May 31
0
[PATCH] Store page and evtchn in start_info_t
Hi all, This is a trivial patch which adds the two fields to start_info_t for the shared page and event channel port for the share. Feel free to destroy this in any way. The python binding just fills zeros in for the moment, making it harmless. Mike Wray has a nicer version in his tree, but this is the minimal version. (Thanks to Mike for the .esp fix, too). Cheers, Rusty. diff -ur
2019 Jun 28
0
[PATCH libnbd v2] python: Raise a custom exception containing error string and errno.
Previously errors caused a RuntimeException to be raised. This commit defines a custom exception (nbd.Error) which has two parameters, the required error string, and the optional errno (which may be 0 if unavailable). For example: $ ./run nbdsh -c 'h.pread(0, 0)' Traceback (most recent call last): File "/usr/lib64/python3.7/runpy.py", line 193, in _run_module_as_main
2019 Jun 28
0
[PATCH libnbd v3] python: Raise a custom exception containing error string and errno.
Previously errors caused a RuntimeException to be raised. This commit defines a custom exception (nbd.Error) which has two parameters, the required error string, and the optional errno (which may be 0 if unavailable). For example: $ ./run nbdsh -c 'h.pread(0, 0)' Traceback (most recent call last): File "/usr/lib64/python3.7/runpy.py", line 193, in _run_module_as_main
2019 Jun 28
1
[PATCH libnbd] python: Raise a custom exception containing error string and errno.
I spent a good few hours this morning trying to make this work and came up with the following patch. It's not quite right though. The exception I've created exists in the libnbdmod module (ie. the underlying C module that we use for the Python bindings). Ideally we'd define and throw an exception from the normal nbd module, but I couldn't work out how to do that. Probably
2019 Jun 28
3
[PATCH libnbd v3] python: Raise a custom exception containing error string and errno.
Following Eric's suggestions from v2, this adds .string, .errno and .__str__ properties. The .string property returns the error string. The .errno property returns the errno (from the errno module), or None. The __str__ property makes the exception nicely printable. Rich.