build.run: make sure BuildProducts._root is not easily accessible.
authorwhitequark <cz@m-labs.hk>
Sat, 6 Jul 2019 18:44:25 +0000 (18:44 +0000)
committerwhitequark <cz@m-labs.hk>
Sat, 6 Jul 2019 18:52:48 +0000 (18:52 +0000)
nmigen/build/run.py

index 251ba3e17938e4dd15fd7700a9a49c42143e1458..204e98d146e87905d0a46d13dc9bad16f06ffb7c 100644 (file)
@@ -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