Displaying 20 results from an estimated 2000 matches similar to: "[PATCH libnbd v3] python: Raise a custom exception containing error string and errno."
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 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
2
Re: [PATCH libnbd v3] python: Raise a custom exception containing error string and errno.
On 6/28/19 1:27 PM, Richard W.M. Jones wrote:
> 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):
2019 Aug 13
2
Re: [PATCH libnbd 5/6] generator: Implement OClosure.
On 8/13/19 5:06 AM, Richard W.M. Jones wrote:
> An optional Closure parameter, but otherwise works the same way as
> Closure.
> @@ -3778,6 +3777,7 @@ let generate_lib_api_c () =
> ) args;
> List.iter (
> function
> + | OClosure { cbname } -> pr ", %s_callback ? \"<fun>\" : \"NULL\"" cbname
Well, it also permits a
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
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
Re: [PATCH libnbd v3] python: Raise a custom exception containing error string and errno.
On Fri, Jun 28, 2019 at 01:53:11PM -0500, Eric Blake wrote:
> On 6/28/19 1:27 PM, Richard W.M. Jones wrote:
> > 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
2019 Sep 11
4
[PATCH nbdkit] tests: Convert some tests to use nbdsh instead of qemu-io.
Very much a work in progress as there are still many tests using
qemu-io which are candidates for conversion.
You'll notice at the end of test-full.sh that the new test has some
duplicated code which looks as if it ought to be refactored into a
Python function. When I tried to do that, I got loads of strange
Python problems which may indicate bugs in nbdsh itself or problems
with my
2019 Aug 10
7
[PATCH libnbd 0/5] WIP: python: Add test for doing asynch copy.
This doesn't yet work. However it does make me more convinced than
ever that we really need to sort out persistent buffer lifetimes in
the library (similar to what we did for closures).
Rich.
2019 Jun 28
1
Re: [PATCH libnbd v3] python: Raise a custom exception containing error string and errno.
On 6/28/19 2:17 PM, Richard W.M. Jones wrote:
>>
>> Looks good to me now! Thanks for figuring this out while I was
>> struggling with reading lots of documentation on C bindings.
>>
>> ACK
>
> I pushed it, but there may be a few issues still:
>
> - Still no error checking in raise_exception(). We're on an error
> path already here so it's
2019 Jun 17
2
[nbdkit PATCH] extents: Cap maximum reply length
A devious plugin can cause an 8-fold increase in the reply size in
relation to the request size, by alternating status every byte of the
request. In the worst case, this can cause the client to reject our
response and kill the connection because the response is too large.
What's more, it consumes a lot of memory to track that many extents.
Let's put an upper bound on the maximum number of
2018 Apr 06
6
[nbdkit PATCH 0/2] Python cleanups
I noticed these while working on adding fua support into python,
these are independent enough to push now (and I'll have to rebase
my 'optional may_trim' patch on top of this).
Eric Blake (2):
python: Use Py_XDEFREF()
python: Simplify calling into plugin
plugins/python/python.c | 106 ++++++++----------------------------------------
1 file changed, 18 insertions(+), 88
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
2019 Aug 11
4
[PATCH libnbd v2 0/3] python: Add test for doing asynch copy.
v1 was here:
https://www.redhat.com/archives/libguestfs/2019-August/msg00103.html
In v2 I've made several changes:
- Fix Python callbacks so if they don't return something
which is int-like, we assume they mean to return 0.
- Add nbd.Buffer free() method. Read commit message in
patch 2 to see what this is about.
- Fixed the asynch copy test to deal with the unbelievably
2019 Nov 22
18
[PATCH nbdkit v2 00/10] Implement nbdkit API v2 for Python plugins.
v1:
https://www.redhat.com/archives/libguestfs/2019-November/msg00153.html
v2:
- Fix implementation of can_cache.
- Add implementation of can_fua.
- Add a very thorough test suite which tests every command + flag
combination.
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 Jan 26
10
[nbdkit PATCH v2 0/6] bind .zero to Python
Fix some things I noticed while reviewing v1, and follow Rich's
idea to add a new nbdkit_set_error() utility function with a
binding for Python users to request a particular error (rather
than being forced to live with whatever stale value is in errno
after all the intermediate binding glue code).
I could not easily find out how to register a C function callable
from perl bindings, and have
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 Feb 03
1
[PATCH] hivex: python: value_value no longer generates Unicode strings
This fixes Github issue #2 reported by "kupiakos".
<https://github.com/libguestfs/hivex/issues/2>
---
generator/generator.ml | 2 +-
python/t/210-setvalue.py | 26 +++++++++++++++++---------
2 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/generator/generator.ml b/generator/generator.ml
index 908c5f3..02aaf12 100755
--- a/generator/generator.ml
+++
2017 Jan 24
4
[nbdkit PATCH 0/2] bind .zero to more languages
Begin the language binding followups to my new .zero callback, since
Rich was indeed correct that we want them.
I'm more familiar with python and perl (at least to the point that
I was able to modify the appropriate example files and prove to
myself that the bindings worked), so I've started with those.
I'm less familiar with ruby and ocaml, so I've left those for
tomorrow (it