From: Môshe v. d. S. <me...@mo...> - 2012-05-27 13:21:14
|
This is a small bugfix that clears the exception state after trying (and failing) to read keep_cache and direct_io. Not doing this will make the exception appear in a random other place. This can easily happen in code that uses PyErr_Occured(), the code being checked might have not triggered an exception, but PyErr_Occured() will still find the getattr() exception that was not handled here. --- Hi Csaba Henk, Here is another bugfix, it prevents this Exception when direct_io and/or keep_cache are not set: Traceback (most recent call last): File "/usr/lib/python2.7/site-packages/fuse.py", line 362, in __call__ return apply(self.func, args, kw) File "/usr/lib/python2.7/site-packages/fuse.py", line 856, in __call__ return getattr(a[-1], self.name)(*(a[1:-1]), **kw) AttributeError: 'File' object has no attribute 'direct_io' On line 856 of fuse.py, the expression 'a[-1]' is actually what triggers this exception (during the read call _after_ the open call that checked for direct_io), while this is obviously valid (when the exception state is empty) and not the place that raised the exception. If you want to apply this patch, this mail is formatted as a git send-mail patch (but I copy-pasted it into my mail-client so I could add this explanation), if it does not work, I can resend it like before directly with git send-mail. Greetings, Môshe van der Sterre fuseparts/_fusemodule.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/fuseparts/_fusemodule.c b/fuseparts/_fusemodule.c index 6271699..2894c38 100644 --- a/fuseparts/_fusemodule.c +++ b/fuseparts/_fusemodule.c @@ -529,11 +529,15 @@ open_func(const char *path, struct fuse_file_info *fi) if (pytmp1) { fi->keep_cache = PyObject_IsTrue(pytmp1); Py_DECREF(pytmp1); + } else { + PyErr_Clear(); } pytmp1 = PyObject_GetAttrString(pytmp, "direct_io"); if (pytmp1) { fi->direct_io = PyObject_IsTrue(pytmp1); Py_DECREF(pytmp1); + } else { + PyErr_Clear(); } if (PyObject_IsTrue(PyTuple_GetItem(v, 1))) @@ -573,11 +577,15 @@ create_func(const char *path, mode_t mode, struct fuse_file_info *fi) if (pytmp1) { fi->keep_cache = PyObject_IsTrue(pytmp1); Py_DECREF(pytmp1); + } else { + PyErr_Clear(); } pytmp1 = PyObject_GetAttrString(pytmp, "direct_io"); if (pytmp1) { fi->direct_io = PyObject_IsTrue(pytmp1); Py_DECREF(pytmp1); + } else { + PyErr_Clear(); } if (PyObject_IsTrue(PyTuple_GetItem(v, 1))) { -- 1.7.7.6 |