From: whitequark Date: Sat, 6 Jul 2019 18:44:25 +0000 (+0000) Subject: build.run: make sure BuildProducts._root is not easily accessible. X-Git-Tag: locally_working~111 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b6b9f0fc21f218210b49a36fd013cc066b9f0d08;p=nmigen.git build.run: make sure BuildProducts._root is not easily accessible. --- 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