From 9363eafb878131f2b836357e71ce02a511dc9e2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 1 May 2024 20:03:17 +0200 Subject: [PATCH] Do not test file exists when opening it The file_open tools may be used to create a file so it may not yet exist. Also io.open will raise the proper exception if the file can not be open. Closes #13230 (grafted from ad09f3e55f6f7bd6767ea44d03566322fce6b487) --HG-- branch : 7.0 --- trytond/trytond/tools/misc.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/trytond/trytond/tools/misc.py b/trytond/trytond/tools/misc.py index bd510ff752..bdb56b4719 100644 --- a/trytond/trytond/tools/misc.py +++ b/trytond/trytond/tools/misc.py @@ -46,7 +46,7 @@ def import_module(name): def file_open(name, mode="r", subdir='modules', encoding=None): "Open a file from the root directory, using subdir folder" - path = find_path(name, subdir) + path = find_path(name, subdir, _test=None) return io.open(path, mode, encoding=encoding) @@ -84,7 +84,7 @@ def find_path(name, subdir='modules', _test=os.path.isfile): else: path = secure_join(root_path, name) - if _test(path): + if not _test or _test(path): return path else: raise FileNotFoundError("No such file or directory: %r" % name)