Print the OS error's text once, the way read_premises does

This commit is contained in:
2026-09-25 17:27:09 +02:00
parent 40f0b73a19
commit 159cecaa1f
2 changed files with 2 additions and 3 deletions
+1 -1
View File
@@ -222,7 +222,7 @@ def trust(paths):
with open(config, encoding="utf-8") as handle:
data = json.load(handle)
except (OSError, ValueError) as failure:
print(f"could not read {config}: {failure}", file=sys.stderr)
print(f"could not read {config}: {getattr(failure, 'strerror', failure)}", file=sys.stderr)
return
projects = data.setdefault("projects", {})
granted = [path for path in paths if not projects.get(path, {}).get("hasTrustDialogAccepted")]
+1 -2
View File
@@ -206,8 +206,7 @@ class Trust(unittest.TestCase):
config = pathlib.Path(home, ".claude.json")
with contextlib.redirect_stderr(io.StringIO()) as err:
loop.trust(["/a"])
self.assertIn(f"could not read {config}: ", err.getvalue())
self.assertIn("No such file or directory", err.getvalue())
self.assertEqual(err.getvalue(), f"could not read {config}: No such file or directory\n")
config.write_text("{")
with contextlib.redirect_stderr(io.StringIO()) as err:
loop.trust(["/a"])