From ccf1d3506c9e64a9ab5946a6d3a1e7b155240db7 Mon Sep 17 00:00:00 2001 From: Iustin Pop Date: Fri, 29 Nov 2019 02:20:58 +0100 Subject: [PATCH] Include filename in exceptions raised in delete_default And add test for failure. --- acl.c | 2 +- tests/test_acls.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/acl.c b/acl.c index 5a8d630..2ab8b2d 100644 --- a/acl.c +++ b/acl.c @@ -1555,7 +1555,7 @@ static PyObject* aclmodule_delete_default(PyObject* obj, PyObject* args) { return NULL; if(acl_delete_def_file(filename) == -1) { - return PyErr_SetFromErrno(PyExc_IOError); + return PyErr_SetFromErrnoWithFilename(PyExc_IOError, filename); } /* Return the result */ diff --git a/tests/test_acls.py b/tests/test_acls.py index 7c51281..eccb600 100644 --- a/tests/test_acls.py +++ b/tests/test_acls.py @@ -445,6 +445,12 @@ class TestWrite: with get_dir(testdir) as dname: posix1e.delete_default(dname) + def test_delete_default_fail(self, testdir): + """Test removing the default ACL""" + with get_file_name(testdir) as fname: + with pytest.raises(IOError, match="no-such-file"): + posix1e.delete_default(fname+".no-such-file") + @NOT_PYPY def test_delete_default_wrong_arg(self): with pytest.raises(TypeError): -- 2.39.5