1
0
Fork 0
mirror of https://github.com/Kozea/Radicale.git synced 2025-08-10 18:40:53 +00:00

config & rights: use open() for better error messages

ConfigParser().read() doesn't differentiate between different types of
failure to read files, causing eg. "No such file" to be logged in all
cases, for example if permissions are insufficient. fix that by using
open() and ConfigParser().read_file() instead.
This commit is contained in:
Lauri Tirkkonen 2022-01-11 20:22:19 +02:00 committed by Unrud
parent 8fa4345b6f
commit 4c44940ec1
2 changed files with 10 additions and 9 deletions

View file

@ -56,8 +56,8 @@ class Rights(rights.BaseRights):
escaped_user = re.escape(user)
rights_config = configparser.ConfigParser()
try:
if not rights_config.read(self._filename):
raise RuntimeError("No such file: %r" % self._filename)
with open(self._filename, "r") as f:
rights_config.read_file(f)
except Exception as e:
raise RuntimeError("Failed to load rights file %r: %s" %
(self._filename, e)) from e