diff --git a/lib/spack/spack/util/libc.py b/lib/spack/spack/util/libc.py index bcfbbec646a..402bf6f2444 100644 --- a/lib/spack/spack/util/libc.py +++ b/lib/spack/spack/util/libc.py @@ -128,9 +128,9 @@ def startfile_prefix(prefix: str, compatible_with: str = sys.executable) -> Opti except Exception: accept = lambda path: True - queue = [(0, prefix)] - while queue: - depth, path = queue.pop() + stack = [(0, prefix)] + while stack: + depth, path = stack.pop() try: iterator = os.scandir(path) except OSError: @@ -140,7 +140,7 @@ def startfile_prefix(prefix: str, compatible_with: str = sys.executable) -> Opti try: if entry.is_dir(follow_symlinks=True): if depth < 2: - queue.append((depth + 1, entry.path)) + stack.append((depth + 1, entry.path)) elif entry.name == "crt1.o" and accept(entry.path): return path except Exception: diff --git a/lib/spack/spack/util/spack_yaml.py b/lib/spack/spack/util/spack_yaml.py index 04f88faafaa..b3326d29591 100644 --- a/lib/spack/spack/util/spack_yaml.py +++ b/lib/spack/spack/util/spack_yaml.py @@ -497,10 +497,10 @@ def anchorify(data: Union[dict, list], identifier: Callable[[Any], str] = repr) """Replace identical dict/list branches in tree with references to earlier instances. The YAML serializer generate anchors for them, resulting in small yaml files.""" anchors: Dict[str, Union[dict, list]] = {} - queue: List[Union[dict, list]] = [data] + stack: List[Union[dict, list]] = [data] - while queue: - item = queue.pop() + while stack: + item = stack.pop() for key, value in item.items() if isinstance(item, dict) else enumerate(item): if not isinstance(value, (dict, list)): @@ -511,7 +511,7 @@ def anchorify(data: Union[dict, list], identifier: Callable[[Any], str] = repr) if anchor is None: anchors[id] = value - queue.append(value) + stack.append(value) else: item[key] = anchor # replace with reference