From 2b1fb525cb92e933b788e9955358a76d2c87f95f Mon Sep 17 00:00:00 2001 From: whitequark Date: Sat, 6 Jul 2019 18:44:25 +0000 Subject: [PATCH] build.run: make sure BuildProducts._root is not easily accessible. --- nmigen/build/run.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/nmigen/build/run.py b/nmigen/build/run.py index 251ba3e..204e98d 100644 --- a/nmigen/build/run.py +++ b/nmigen/build/run.py @@ -56,11 +56,13 @@ class BuildPlan: class BuildProducts: def __init__(self, root): - self._root = root + # We provide no guarantees that files will be available on the local filesystem (i.e. in + # any way other than through `products.get()`), so downstream code must never rely on this. + self.__root = root def get(self, filename, mode="b"): assert mode in "bt" - with open(os.path.join(self._root, filename), "r" + mode) as f: + with open(os.path.join(self.__root, filename), "r" + mode) as f: return f.read() @contextmanager -- 2.30.2