search for: py_h

Displaying 20 results from an estimated 23 matches for "py_h".

Did you mean: py_
2020 Mar 19
5
[nbdkit PATCH 0/2] More caching of initial setup
When I added .can_FOO caching in 1.16, I missed the case that the sh plugin itself was calling .can_flush twice in some situations (in order to default .can_fua). Then right after, I regressed it to call .can_zero twice (in order to default .can_fast_zero). I also missed that .thread_model could use better caching, because at the time, I did not add testsuite coverage. Fix that now. Eric Blake
2011 Apr 27
2
[PATCH] hivex/python fix for i386 integer size issue
...ran fine on amd64.) ,---- | $ make -C python check | make[1]: Entering directory `/home/bengen/src/deb/hivex/hivex.git/python' | 010-import.py | 020-open.py | 021-close.py | 200-write.py | python: hivex-py.c:52: get_handle: Assertion `obj' failed. `---- I narrowed this down to hivex-py.c:py_hivex_node_add_child(): The call ,---- | PyArg_ParseTuple (args, (char *) "OLs:hivex_node_add_child", | &py_h, &parent, &name) `---- results in `py_h' set to NULL, though Python's documentation claims that this cannot happen. I think this happ...
2020 Sep 08
2
[libnbd PATCH] python: Plug some memory leaks on error paths
..., *%s);\n" n n n; + pr " Py_DECREF (py_%s_mod);\n" n; pr " if (!py_%s) { PyErr_PrintEx (0); return -1; }\n" n; | CBString _ | CBUInt _ @@ -263,7 +264,7 @@ let print_python_binding name { args; optargs; ret; may_set_error } = pr " PyObject *py_h;\n"; pr " struct nbd_handle *h;\n"; pr " %s ret;\n" (C.type_of_ret ret); - pr " PyObject *py_ret;\n"; + pr " PyObject *py_ret = NULL;\n"; List.iter ( function | Bool n -> pr " int %s;\n" n @@ -279,7 +280,7 @@ let pr...
2020 Sep 01
0
[nbdkit PATCH 1/2] python: Implement .list_exports and friends
...port") == -1) + return NULL; + + name = python_to_string (r); + Py_DECREF (r); + if (!name) { + nbdkit_error ("default_export method did not return a string"); + return NULL; + } + + return nbdkit_strdup_intern (name); +} + struct handle { int can_zero; PyObject *py_h; @@ -595,6 +688,35 @@ py_close (void *handle) free (h); } +static const char * +py_export_description (void *handle) +{ + ACQUIRE_PYTHON_GIL_FOR_CURRENT_SCOPE; + struct handle *h = handle; + PyObject *fn; + PyObject *r; + CLEANUP_FREE char *desc = NULL; + + if (!callback_defined ("e...
2020 Aug 10
0
Re: [PATCH nbdkit] python: Implement can_extents + extents.
...ON_GIL_FOR_CURRENT_SCOPE; > + struct handle *h = handle; > + PyObject *fn; > + PyObject *r; > + Py_ssize_t i, size; > + > + if (callback_defined ("extents", &fn)) { > + PyErr_Clear (); > + > + r = PyObject_CallFunction (fn, "OiLI", h->py_h, count, offset, flags); > + Py_DECREF (fn); > + if (check_python_failure ("extents") == -1) > + return -1; > + > + /* We expect a list of extents to be returned. Each extent is a > + * tuple (offset, length, type). > + */ > + if (!PyList_C...
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 = {
2020 Aug 10
5
[PATCH nbdkit] python: Implement can_extents + extents.
...t nbdkit_extents *extents) +{ + ACQUIRE_PYTHON_GIL_FOR_CURRENT_SCOPE; + struct handle *h = handle; + PyObject *fn; + PyObject *r; + Py_ssize_t i, size; + + if (callback_defined ("extents", &fn)) { + PyErr_Clear (); + + r = PyObject_CallFunction (fn, "OiLI", h->py_h, count, offset, flags); + Py_DECREF (fn); + if (check_python_failure ("extents") == -1) + return -1; + + /* We expect a list of extents to be returned. Each extent is a + * tuple (offset, length, type). + */ + if (!PyList_Check (r)) { + nbdkit_error ("e...
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
2019 Jul 16
1
Re: [PATCH libnbd v2] generator: Define new Closure type instead of callbacks.
...) -> > + List.iter ( > + fun { cbname } -> > + pr " Py_INCREF (user_data->%s);\n" cbname > + ) cls > + | _ -> () > + ) args; > + Any reason this loop is a separate pass, rather than... > pr " h = get_handle (py_h);\n"; > List.iter ( > function > @@ -4044,19 +4058,20 @@ let print_python_binding name { args; ret } = > pr " %s = malloc (%s);\n" n count > | BytesPersistIn (n, _) | BytesPersistOut (n, _) -> > pr " %s_buf = nbd_internal_py_ge...
2020 Aug 10
0
Re: [PATCH nbdkit] python: Implement can_extents + extents.
...ON_GIL_FOR_CURRENT_SCOPE; > + struct handle *h = handle; > + PyObject *fn; > + PyObject *r; > + Py_ssize_t i, size; > + > + if (callback_defined ("extents", &fn)) { > + PyErr_Clear (); > + > + r = PyObject_CallFunction (fn, "OiLI", h->py_h, count, offset, flags); > + Py_DECREF (fn); > + if (check_python_failure ("extents") == -1) > + return -1; > + > + /* We expect a list of extents to be returned. Each extent is a > + * tuple (offset, length, type). > + */ > + if (!PyList_C...
2020 Sep 01
4
[nbdkit PATCH 0/2] More language bindings for .list_exports
This picks up python and ocaml. Some of our languages are lacking a number of bindings (for example, lua and perl lack .extents, so I didn't have anything to copy from), and I felt less comfortable with golang and rust. But for python and ocaml, I was able to test a working implementation. Eric Blake (2): python: Implement .list_exports and friends ocaml: Implement .list_exports and
2020 Sep 10
1
[libnbd PATCH] python: Fix more memory leaks
...sure { cbname } -> pr ", &%s_user_data->fn" cbname + | OClosure { cbname } -> pr ", &py_%s_fn" cbname | OFlags (n, _) -> pr ", &%s" n ) optargs; pr "))\n"; pr " goto out;\n"; pr " h = get_handle (py_h);\n"; + pr " if (!h) goto out;\n"; + List.iter ( + function + | OClosure { cbname } -> + pr " %s.user_data = %s_user_data = alloc_user_data ();\n" cbname cbname; + pr " if (%s_user_data == NULL) goto out;\n" cbname; + pr " if...
2019 Aug 09
0
[PATCH libnbd 1/2] generator: Handle closure args (cbargs) specially.
...| Path n -> pr " \"O&\"" | SockAddrAndLen (n, _) -> pr " \"O\"" | String n -> pr " \"s\"" @@ -4220,8 +4212,6 @@ let print_python_binding name { args; ret; may_set_error } = pr " &py_h"; List.iter ( function - | ArrayAndLen (UInt32 n, _) -> pr ", &py_%s" n - | ArrayAndLen _ -> assert false | Bool n -> pr ", &%s" n | BytesIn (n, _) | BytesPersistIn (n, _) | BytesPersistOut (n, _) -> pr ", &%s"...
2019 Aug 09
4
[PATCH libnbd 0/2] generator: Preparatory changes to the generator.
These are some simplifications to the generator. They don't probably make much sense on their own, but they are preparatory to better handling of enums, and or'd lists of flags. Rich.
2019 Jul 16
2
[PATCH libnbd v2] generator: Define new Closure type
As before, but this one has working Python bindings. OCaml still TBD. Rich.
2019 Aug 09
0
[PATCH libnbd 2/2] generator: Change handling of Flags to be a true optional argument.
...| UInt64 n -> pr " \"K\"" ) args; + List.iter ( + function + | OFlags n -> pr " \"I\"" + ) optargs; pr "\n"; pr " \":nbd_%s\",\n" name; pr " &py_h"; @@ -4217,7 +4245,6 @@ let print_python_binding name { args; ret; may_set_error } = | BytesPersistOut (n, _) -> pr ", &%s" n | BytesOut (_, count) -> pr ", &%s" count | Closure { cbname } -> pr ", &%s_user_data" cbname - | F...
2019 May 23
2
[PATCH libnbd] api: Get rid of nbd_connection.
This isn't quite finished because not all of the tests or examples have been updated, but it demonstrates an idea: Should we forget about the concept of having multiple connections managed under a single handle? In this patch there is a single ‘struct nbd_handle *’ which manages a single state machine and connection (and therefore no nbd_connection). To connect to a multi-conn server you must
2019 Jul 24
0
[PATCH libnbd v2 2/5] lib: Implement closure lifetimes.
...res then we need to - * make sure the ref count remains positive. - *) - List.iter ( - function - | Closure (false, _) -> () - | Closure (true, { cbname }) -> - pr " Py_INCREF (%s_user_data);\n" cbname - | _ -> () - ) args; - pr " h = get_handle (py_h);\n"; List.iter ( function @@ -4086,7 +4060,9 @@ let print_python_binding name { args; ret } = pr " %s = malloc (%s);\n" n count | BytesPersistIn (n, _) | BytesPersistOut (n, _) -> pr " %s_buf = nbd_internal_py_get_aio_buffer (%s);\n" n n -...
2019 Jul 25
0
[PATCH libnbd v3 1/2] lib: Implement closure lifetimes.
...res then we need to - * make sure the ref count remains positive. - *) - List.iter ( - function - | Closure (false, _) -> () - | Closure (true, { cbname }) -> - pr " Py_INCREF (%s_user_data);\n" cbname - | _ -> () - ) args; - pr " h = get_handle (py_h);\n"; List.iter ( function @@ -4007,7 +3981,9 @@ let print_python_binding name { args; ret } = pr " %s = malloc (%s);\n" n count | BytesPersistIn (n, _) | BytesPersistOut (n, _) -> pr " %s_buf = nbd_internal_py_get_aio_buffer (%s);\n" n n -...
2019 Jul 16
0
[PATCH libnbd v2] generator: Define new Closure type instead of callbacks.
.... + *) + List.iter ( + function + | Closure (false, _) -> () + | Closure (true, cls) -> + List.iter ( + fun { cbname } -> + pr " Py_INCREF (user_data->%s);\n" cbname + ) cls + | _ -> () + ) args; + pr " h = get_handle (py_h);\n"; List.iter ( function @@ -4044,19 +4058,20 @@ let print_python_binding name { args; ret } = pr " %s = malloc (%s);\n" n count | BytesPersistIn (n, _) | BytesPersistOut (n, _) -> pr " %s_buf = nbd_internal_py_get_aio_buffer (%s);\n" n n...