Skip to content

Commit 7e29c2a

Browse files
moshevdscsabahenk
authored andcommitted
Bugfix: clear exception state in open_func and create_func
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.
1 parent 602557a commit 7e29c2a

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

fuseparts/_fusemodule.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,11 +529,15 @@ open_func(const char *path, struct fuse_file_info *fi)
529529
if (pytmp1) {
530530
fi->keep_cache = PyObject_IsTrue(pytmp1);
531531
Py_DECREF(pytmp1);
532+
} else {
533+
PyErr_Clear();
532534
}
533535
pytmp1 = PyObject_GetAttrString(pytmp, "direct_io");
534536
if (pytmp1) {
535537
fi->direct_io = PyObject_IsTrue(pytmp1);
536538
Py_DECREF(pytmp1);
539+
} else {
540+
PyErr_Clear();
537541
}
538542

539543
if (PyObject_IsTrue(PyTuple_GetItem(v, 1)))
@@ -573,11 +577,15 @@ create_func(const char *path, mode_t mode, struct fuse_file_info *fi)
573577
if (pytmp1) {
574578
fi->keep_cache = PyObject_IsTrue(pytmp1);
575579
Py_DECREF(pytmp1);
580+
} else {
581+
PyErr_Clear();
576582
}
577583
pytmp1 = PyObject_GetAttrString(pytmp, "direct_io");
578584
if (pytmp1) {
579585
fi->direct_io = PyObject_IsTrue(pytmp1);
580586
Py_DECREF(pytmp1);
587+
} else {
588+
PyErr_Clear();
581589
}
582590

583591
if (PyObject_IsTrue(PyTuple_GetItem(v, 1))) {

0 commit comments

Comments
 (0)