Displaying 20 results from an estimated 58 matches for "pyerr_clear".
2018 Apr 11
0
[nbdkit PATCH v2 5/5] RFC: python: Track and cache per-connection state in C struct
...nHandle *h = malloc (sizeof *h);
+ if (!h) {
+ nbdkit_error ("%s: %m", script);
+ return NULL;
+ }
if (!callback_defined ("open", &fn)) {
nbdkit_error ("%s: missing callback: %s", script, "open");
+ free (h);
return NULL;
}
PyErr_Clear ();
- handle = PyObject_CallFunctionObjArgs (fn, readonly ? Py_True : Py_False,
+ h->obj = PyObject_CallFunctionObjArgs (fn, readonly ? Py_True : Py_False,
NULL);
Py_DECREF (fn);
- if (check_python_failure ("open") == -1)
+ if (check_py...
2018 Apr 06
0
[nbdkit PATCH 2/2] python: Simplify calling into plugin
...@@ py_config (const char *key, const char *value)
FILE *fp;
PyObject *modname;
PyObject *fn;
- PyObject *args;
PyObject *r;
if (!script) {
@@ -258,17 +257,8 @@ py_config (const char *key, const char *value)
/* Other parameters are passed to the Python .config callback. */
PyErr_Clear ();
- args = PyTuple_New (2);
-#ifdef HAVE_PYSTRING_FROMSTRING
- PyTuple_SetItem (args, 0, PyString_FromString (key));
- PyTuple_SetItem (args, 1, PyString_FromString (value));
-#else
- PyTuple_SetItem (args, 0, PyUnicode_FromString (key));
- PyTuple_SetItem (args, 1, PyUnicode_From...
2018 Apr 19
1
Re: [nbdkit PATCH v2 5/5] RFC: python: Track and cache per-connection state in C struct
...; + nbdkit_error ("%s: %m", script);
> + return NULL;
> + }
> if (!callback_defined ("open", &fn)) {
> nbdkit_error ("%s: missing callback: %s", script, "open");
> + free (h);
> return NULL;
> }
>
> PyErr_Clear ();
>
> - handle = PyObject_CallFunctionObjArgs (fn, readonly ? Py_True : Py_False,
> + h->obj = PyObject_CallFunctionObjArgs (fn, readonly ? Py_True : Py_False,
> NULL);
> Py_DECREF (fn);
> - if (check_python_failure ("open...
2015 Feb 14
0
[PATCH] python: Call PyErr_Clear() on non-error paths out of the Python bindings.
...s(-)
diff --git a/TODO b/TODO
index 075bdc6..666400e 100644
--- a/TODO
+++ b/TODO
@@ -563,12 +563,6 @@ Write an extension for mc that would let people browse into
filesystems. See
http://repo.or.cz/w/midnight-commander.git/tree/HEAD:/misc/ext.d
-Python
-------
-
-It seems as if we should call PyErr_Clear() somewhere in every
-Python binding.
-
Improvements in virt-log
------------------------
diff --git a/generator/python.ml b/generator/python.ml
index 4b823e6..637f22d 100644
--- a/generator/python.ml
+++ b/generator/python.ml
@@ -455,7 +455,8 @@ put_table (char * const * const argv)...
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
2018 Apr 11
10
[nbdkit PATCH v2 0/5] FUA support in Python scripts
First out of our four language bindings to add FUA support (for
reference, I added 'zero' support for python, perl, and ruby
back in 1.1.13, then Rich had to add it for ocaml in 1.1.20).
I tested this heavily under python 2, but for now only compile
tested under python 3; I plan to do further testing there and
make any tweaks if necessary.
I wrote patch 5 early on, but then realized I
2019 Nov 22
0
[PATCH nbdkit v2 05/10] python: Share common code in boolean callbacks.
...atic int
-py_can_write (void *handle)
+boolean_callback (void *handle, const char *can_fn, const char *plain_fn)
{
PyObject *obj = handle;
PyObject *fn;
PyObject *r;
int ret;
- if (callback_defined ("can_write", &fn)) {
+ if (callback_defined (can_fn, &fn)) {
PyErr_Clear ();
r = PyObject_CallFunctionObjArgs (fn, obj, NULL);
Py_DECREF (fn);
- if (check_python_failure ("can_write") == -1)
+ if (check_python_failure (can_fn) == -1)
return -1;
ret = r == Py_True;
Py_DECREF (r);
return ret;
}
- /* No Python can_write...
2019 Nov 21
10
[PATCH nbdkit 0/8] Implement nbdkit API v2 for Python plugins.
And fill out most of the missing bits of the API.
Rich.
2018 Apr 11
0
[nbdkit PATCH v2 3/5] python: Update internals to plugin API level 2
...int
py_pwrite (void *handle, const void *buf,
- uint32_t count, uint64_t offset)
+ uint32_t count, uint64_t offset, uint32_t flags)
{
PyObject *obj = handle;
PyObject *fn;
PyObject *r;
+ assert (!flags);
if (callback_defined ("pwrite", &fn)) {
PyErr_Clear ();
@@ -495,12 +498,13 @@ py_pwrite (void *handle, const void *buf,
}
static int
-py_flush (void *handle)
+py_flush (void *handle, uint32_t flags)
{
PyObject *obj = handle;
PyObject *fn;
PyObject *r;
+ assert (!flags);
if (callback_defined ("flush", &fn)) {
PyE...
2019 Nov 22
0
[PATCH nbdkit v2 03/10] python: Implement nbdkit API version 2.
...static int last_error;
@@ -356,6 +359,26 @@ py_config (const char *key, const char *value)
"nbdkit requires these callbacks.", script);
return -1;
}
+
+ /* Get the API version. */
+ if (callback_defined ("api_version", &fn)) {
+ PyErr_Clear ();
+
+ r = PyObject_CallObject (fn, NULL);
+ Py_DECREF (fn);
+ if (check_python_failure ("api_version") == -1)
+ return -1;
+ py_api_version = (int) PyLong_AsLong (r);
+ Py_DECREF (r);
+ if (check_python_failure ("PyLong_AsLong") == -1)
+...
2019 Nov 23
0
[PATCH nbdkit v3 2/7] python: Implement nbdkit API version 2.
...YTHON_ABI_VERSION);
+ /* Maximum nbdkit API version supported. */
+ printf ("nbdkit_python_maximum_api_version=%d\n", NBDKIT_API_VERSION);
+
+ /* If the script has a dump_plugin function, call it. */
if (script && callback_defined ("dump_plugin", &fn)) {
PyErr_Clear ();
@@ -297,6 +305,30 @@ py_dump_plugin (void)
}
}
+static int
+get_py_api_version (void)
+{
+ PyObject *obj;
+ long value;
+
+ obj = PyObject_GetAttrString (module, "API_VERSION");
+ if (obj == NULL)
+ return 1; /* Default to API version 1. */
+
+ value...
2020 Apr 26
5
[PATCH v3] python: Fix UnicodeError in inspect_list_applications2() (RHBZ#1684004)
...endif
}
@@ -397,7 +397,12 @@ guestfs_int_py_fromstringsize (const char *str, size_t size)
#if PY_MAJOR_VERSION < 3
return PyString_FromStringAndSize (str, size);
#else
- return PyUnicode_FromStringAndSize (str, size);
+ PyObject *s = PyUnicode_FromString (str);
+ if (s == NULL) {
+ PyErr_Clear ();
+ s = PyUnicode_Decode (str, strlen(str), "latin1", "strict");
+ }
+ return s;
#endif
}
--
2.26.2.303.gf8c07b1a785-goog
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.
2019 Nov 23
3
[PATCH nbdkit] python: Pass memoryview to pwrite()
...gins/python/python.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/plugins/python/python.c b/plugins/python/python.c
index 214fffb..2b4361a 100644
--- a/plugins/python/python.c
+++ b/plugins/python/python.c
@@ -496,8 +496,8 @@ py_pwrite (void *handle, const void *buf,
PyErr_Clear ();
r = PyObject_CallFunction (fn, "ONL", obj,
- PyByteArray_FromStringAndSize (buf, count),
- offset, NULL);
+ PyMemoryView_FromMemory ((char *)buf, count, PyBUF_READ),
+ offset, NULL);
Py_DECRE...
2020 Apr 20
2
[PATCH] python: Fix UnicodeError in inspect_list_applications2() (RHBZ#1684004)
...plication", "app_description"
+ | "application2", "app2_description" ->
+ pr " if (value == NULL) {\n";
+ pr " value = guestfs_int_py_fromstring (\"\");\n";
+ pr " PyErr_Clear ();\n";
+ pr " }\n";
+ | _ -> pr ""; );
pr " if (value == NULL)\n";
pr " goto err;\n";
pr " PyDict_SetItemString (dict, \"%s\", value);\n" name;
--
2.26.1.301....
2019 Nov 22
0
[PATCH nbdkit v2 01/10] python: Use PyObject_CallFunction instead of constructing the tuple.
...644
--- a/plugins/python/python.c
+++ b/plugins/python/python.c
@@ -557,26 +557,21 @@ py_zero (void *handle, uint32_t count, uint64_t offset, int may_trim)
{
PyObject *obj = handle;
PyObject *fn;
- PyObject *args;
PyObject *r;
if (callback_defined ("zero", &fn)) {
PyErr_Clear ();
last_error = 0;
- args = PyTuple_New (4);
- Py_INCREF (obj); /* decremented by Py_DECREF (args) */
- PyTuple_SetItem (args, 0, obj);
- PyTuple_SetItem (args, 1, PyLong_FromUnsignedLongLong (count));
- PyTuple_SetItem (args, 2, PyLong_FromUnsignedLongLong (offset));
- Py...
2019 Nov 21
0
[PATCH nbdkit 1/8] python: Use PyObject_CallFunction instead of constructing the tuple.
...644
--- a/plugins/python/python.c
+++ b/plugins/python/python.c
@@ -557,26 +557,21 @@ py_zero (void *handle, uint32_t count, uint64_t offset, int may_trim)
{
PyObject *obj = handle;
PyObject *fn;
- PyObject *args;
PyObject *r;
if (callback_defined ("zero", &fn)) {
PyErr_Clear ();
last_error = 0;
- args = PyTuple_New (4);
- Py_INCREF (obj); /* decremented by Py_DECREF (args) */
- PyTuple_SetItem (args, 0, obj);
- PyTuple_SetItem (args, 1, PyLong_FromUnsignedLongLong (count));
- PyTuple_SetItem (args, 2, PyLong_FromUnsignedLongLong (offset));
- Py...
2019 Nov 25
7
[PATCH nbdkit v2 0/7] Implement nbdkit API v2 for Python plugins.
v3 was here:
https://www.redhat.com/archives/libguestfs/2019-November/msg00209.html
In v4:
- Rebase on top of current master. Includes various fixes and
updates required because of Nir's patches that went into master.
- Fix api_version() -> API_VERSION in patch 2 noted previously on the
mailing list.
Rich.
2019 Nov 23
8
[PATCH nbdkit v3 0/7] Implement nbdkit API v2 for Python plugins.
v2 was here:
https://www.redhat.com/archives/libguestfs/2019-November/msg00163.html
I pushed patch 1 (with spelling fix), patch 4 and patch 5 since those
were previously ACKed on the list.
Differences in v3:
- Add error checking to PyModule_AddIntConstant.
- Use API_VERSION constant instead of function.
- Add max API version supported to --dump-plugin output.
- Print API_VERSION selected by
2017 Jan 26
0
[nbdkit PATCH v2 6/6] python: Support zero callback
...6 +444,48 @@ py_trim (void *handle, uint32_t count, uint64_t offset)
}
static int
+py_zero (void *handle, uint32_t count, uint64_t offset, int may_trim)
+{
+ PyObject *obj = handle;
+ PyObject *fn;
+ PyObject *args;
+ PyObject *r;
+
+ if (callback_defined ("zero", &fn)) {
+ PyErr_Clear ();
+
+ last_error = 0;
+ args = PyTuple_New (4);
+ Py_INCREF (obj); /* decremented by Py_DECREF (args) */
+ PyTuple_SetItem (args, 0, obj);
+ PyTuple_SetItem (args, 1, PyLong_FromUnsignedLongLong (count));
+ PyTuple_SetItem (args, 2, PyLong_FromUnsignedLongLong (offset));
+ Py...