search for: py_ret

Displaying 20 results from an estimated 43 matches for "py_ret".

2019 Aug 13
0
[PATCH libnbd 2/6] generator: Create only one Python wrapper per closure.
...cbarg_list cbargs; + pr "\n"; + pr "{\n"; + pr " int ret = 0;\n"; + pr "\n"; + pr " if (valid_flag & LIBNBD_CALLBACK_VALID) {\n"; + pr " PyGILState_STATE py_save = PyGILState_UNLOCKED;\n"; + pr " PyObject *py_args, *py_ret;\n"; + List.iter ( + function + | CBArrayAndLen (UInt32 n, len) -> + pr " PyObject *py_%s = PyList_New (%s);\n" n len; + pr " for (size_t i = 0; i < %s; ++i)\n" len; + pr " PyList_SET_ITEM (py_%s, i, PyLong_FromUnsignedLong (%s...
2019 Aug 10
1
Re: [PATCH libnbd 2/5] python: Allow Python callbacks to auto-retire by returning an integer.
...107724..0523f0a 100755 > --- a/generator/generator > +++ b/generator/generator > @@ -4135,7 +4135,8 @@ let print_python_binding name { args; optargs; ret; may_set_error } = > pr " Py_DECREF (py_args);\n"; > pr "\n"; > pr " if (py_ret != NULL) {\n"; > - pr " Py_DECREF (py_ret); /* return value is discarded */\n"; > + pr " ret = PyLong_AsLong (py_ret);\n"; > + pr " Py_DECREF (py_ret);\n"; This doesn't detect if the user returned a non-integer type (...
2019 Aug 11
0
[PATCH libnbd v2 1/3] python: Allow Python callbacks to auto-retire by returning an integer.
...b/generator/generator index 55c4dfc..e5d9aaa 100755 --- a/generator/generator +++ b/generator/generator @@ -4234,7 +4234,12 @@ let print_python_binding name { args; optargs; ret; may_set_error } = pr " Py_DECREF (py_args);\n"; pr "\n"; pr " if (py_ret != NULL) {\n"; - pr " Py_DECREF (py_ret); /* return value is discarded */\n"; + pr " if (PyLong_Check (py_ret))\n"; + pr " ret = PyLong_AsLong (py_ret);\n"; + pr " else\n"; + pr " /* If it...
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 Aug 10
0
[PATCH libnbd 2/5] python: Allow Python callbacks to auto-retire by returning an integer.
...b/generator/generator index 0107724..0523f0a 100755 --- a/generator/generator +++ b/generator/generator @@ -4135,7 +4135,8 @@ let print_python_binding name { args; optargs; ret; may_set_error } = pr " Py_DECREF (py_args);\n"; pr "\n"; pr " if (py_ret != NULL) {\n"; - pr " Py_DECREF (py_ret); /* return value is discarded */\n"; + pr " ret = PyLong_AsLong (py_ret);\n"; + pr " Py_DECREF (py_ret);\n"; pr " }\n"; pr " else {\n"; pr &...
2019 Jul 25
2
[libnbd PATCH] generator: Let nbd_aio_get_direction return unsigned
...3850,7 @@ let print_python_binding name { args; ret } = | RConstString -> pr " const char *ret;\n" | RInt64 -> pr " int64_t ret;\n" | RString -> pr " char *ret;\n"; + | RUInt -> pr " unsigned ret;\n" ); pr " PyObject *py_ret;\n"; List.iter ( @@ -4018,14 +4034,17 @@ let print_python_binding name { args; ret } = | UInt64 n -> pr ", %s_u64" n ) args; pr ");\n"; - (match ret with - | RBool | RErr | RFd | RInt | RInt64 -> pr " if (ret == -1) {\n"; - | RConstString...
2020 Sep 08
2
[libnbd PATCH] python: Plug some memory leaks on error paths
...-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 print_python_binding name { args; optargs; ret; may_set_error } = pr " struct py_aio_buffer *%s_buf;\n" n | Closure...
2019 Aug 13
0
[PATCH libnbd 2/4] api: Add free function and remove valid_flag parameter.
...hon_closure_wrapper { cbname; cbargs } = pr "{\n"; pr " int ret = 0;\n"; pr "\n"; - pr " if (valid_flag & LIBNBD_CALLBACK_VALID) {\n"; - pr " PyGILState_STATE py_save = PyGILState_UNLOCKED;\n"; - pr " PyObject *py_args, *py_ret;\n"; + pr " PyGILState_STATE py_save = PyGILState_UNLOCKED;\n"; + pr " PyObject *py_args, *py_ret;\n"; List.iter ( function | CBArrayAndLen (UInt32 n, len) -> - pr " PyObject *py_%s = PyList_New (%s);\n" n len; - pr " for...
2019 Jun 04
0
[PATCH libnbd v2 2/4] generator: Callback returns int instead of void.
...\n"; pr "%s_%s_wrapper " name cb_name; print_c_arg_list args; pr "\n"; pr "{\n"; + pr " int ret;\n"; pr " PyGILState_STATE py_save = PyGILState_UNLOCKED;\n"; pr " PyObject *py_args, *py_ret;\n"; List.iter ( @@ -3213,10 +3214,14 @@ let print_python_binding name { args; ret } = pr "\n"; pr " Py_DECREF (py_args);\n"; pr "\n"; - pr " if (py_ret != NULL)\n"; + pr " if (py_ret != NULL) {\n"...
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 Aug 13
12
[PATCH 0/6] Implement OClosure.
Patches 1-4 are basically uncontroversial, straightforward refactoring and IMHO we should just push them. Possibly 1-3 should be squashed together, but I posted them separately so they are easier to review. Patches 5 and 6 together implement OClosure. Patch 5 adds the feature and is simple to understand. Patch 6 changes the Closure completion callbacks into OClosure, but because it doesn't
2019 Jul 16
0
[libnbd PATCH 2/2] RFC: generator: Handle shared callbacks in Python
...;%s_%s_wrapper " name cb.name; + print_c_arg_list ~handle:(Some "void *_data") cb.cbargs; + pr "\n"; + pr "{\n"; + pr " int ret;\n"; + pr " PyGILState_STATE py_save = PyGILState_UNLOCKED;\n"; + pr " PyObject *py_args, *py_ret;\n"; + pr " struct %s_data *data = _data;\n" name; + List.iter ( + function + | ArrayAndLen (UInt32 n, len) -> + pr " PyObject *py_%s = PyList_New (%s);\n" n len; + pr " for (size_t i = 0; i < %s; ++i)\n" len; + pr...
2019 Aug 12
0
[PATCH libnbd 7/7] api: Remove the valid_flag from all callbacks.
..._error } = pr "{\n"; pr " int ret = 0;\n"; pr "\n"; - pr " if (valid_flag & LIBNBD_CALLBACK_VALID) {\n"; - pr " PyGILState_STATE py_save = PyGILState_UNLOCKED;\n"; - pr " PyObject *py_args, *py_ret;\n"; + pr " PyGILState_STATE py_save = PyGILState_UNLOCKED;\n"; + pr " PyObject *py_args, *py_ret;\n"; List.iter ( function | CBArrayAndLen (UInt32 n, len) -> - pr " PyObject *py_%s = PyList_New (%s);\n" n...
2019 Jul 16
3
[RFC libnbd PATCH 0/2] Start fixing python nbd.pread_structured_callback
Posting now that I got something to compile (at the expense of breaking OCaml bindings), but I'm open to ideas on how to improve it. Eric Blake (2): generator: Tweak print_c_arg_list to take alternate first arg RFC: generator: Handle shared callbacks in Python generator/generator | 556 ++++++++++++++++++++++---------------------- 1 file changed, 280 insertions(+), 276 deletions(-) --
2019 Aug 13
1
Re: [PATCH libnbd v2 1/3] generator: Implement OClosure.
...\n"; Leaks %s_user_data, because we fail to do a matching Py_DECREF on failure paths. It would be easier to defer the Py_INCREF to after we verified it is Callable. However, on looking further, I see this is also a pre-existing bug affecting Closure. For that matter, should we be using 'py_ret = NULL; goto out;' similar to StringList, to avoid any other leaks on any other failure paths? (The generated python code still probably has a number of poor handling of failures, which needs a proper audit...) > + pr " }\n"; > + pr " }\n" > |...
2019 Jul 24
0
[PATCH libnbd v2 2/5] lib: Implement closure lifetimes.
...st ~user_data:true cbargs; + C.print_arg_list ~valid_flag:true ~user_data:true cbargs; pr "\n"; pr "{\n"; - pr " int ret;\n"; - pr " PyGILState_STATE py_save = PyGILState_UNLOCKED;\n"; - pr " PyObject *py_args, *py_ret;\n"; + pr " int ret = 0;\n"; + pr "\n"; + pr " if (valid_flag & LIBNBD_CALLBACK_VALID) {\n"; + pr " PyGILState_STATE py_save = PyGILState_UNLOCKED;\n"; + pr " PyObject *py_args, *py_ret;\n"; Lis...
2019 Jul 24
0
[PATCH libnbd 1/3] generator: Change Closure so it describes single callbacks.
...pr "%s_%s_wrapper " name cbname; + C.print_arg_list ~user_data:true cbargs; + pr "\n"; + pr "{\n"; + pr " int ret;\n"; + pr " PyGILState_STATE py_save = PyGILState_UNLOCKED;\n"; + pr " PyObject *py_args, *py_ret;\n"; List.iter ( - fun { cbname; cbargs } -> - pr "static int\n"; - pr "%s_%s_wrapper " name cbname; - C.print_arg_list ~user_data:true cbargs; - pr "\n"; - pr "{\n"; - pr &qu...
2019 Jul 24
8
[PATCH libnbd v2 0/5] lib: Implement closure lifetimes.
v1 was here: https://www.redhat.com/archives/libguestfs/2019-July/thread.html#00231 The changes address everything that Eric picked up in his review of the first two patches. I have also added two more patches (4 and 5) which respectively fix docs and change int status -> unsigned status, as discussed. Passes make, check, check-valgrind. Rich.
2019 Jul 16
0
[PATCH libnbd v2] generator: Define new Closure type instead of callbacks.
...\n"; - pr "%s_%s_wrapper " name cb_name; - print_c_arg_list args; - pr "\n"; - pr "{\n"; - pr " int ret;\n"; - pr " PyGILState_STATE py_save = PyGILState_UNLOCKED;\n"; - pr " PyObject *py_args, *py_ret;\n"; - List.iter ( - function - | ArrayAndLen (UInt32 n, len) -> - pr " PyObject *py_%s = PyList_New (%s);\n" n len; - pr " for (size_t i = 0; i < %s; ++i)\n" len; - pr " PyList_SET_ITEM (py_%s, i, PyLon...
2020 Sep 06
0
[libnbd PATCH 1/3] generator: Introduce REnum/RFlags return types
...py_string (r);\n" | RString -> diff --git a/generator/Python.ml b/generator/Python.ml index 3fa733a..c544d10 100644 --- a/generator/Python.ml +++ b/generator/Python.ml @@ -521,6 +521,8 @@ let print_python_binding name { args; optargs; ret; may_set_error } = pr " Py_INCREF (py_ret);\n" | RFd | RInt + | REnum (_) + | RFlags (_) | RUInt -> pr " py_ret = PyLong_FromLong (ret);\n" | RInt64 | RCookie -> -- 2.28.0