diff --git a/lib/spack/spack/spec_parser.py b/lib/spack/spack/spec_parser.py index cfdd46bd502..751ffb88751 100644 --- a/lib/spack/spack/spec_parser.py +++ b/lib/spack/spack/spec_parser.py @@ -286,7 +286,7 @@ def add_dependency(dep, **edge_properties): raise SpecParsingError(str(e), self.ctx.current_token, self.literal_str) from e # Get toolchain information outside of loop - toolchains = spack.config.get("toolchains", {}) + toolchains = spack.config.CONFIG.get("toolchains", {}) initial_spec = initial_spec or spack.spec.Spec() root_spec, parser_warnings = SpecNodeParser(self.ctx, self.literal_str).parse(initial_spec) @@ -319,11 +319,11 @@ def add_dependency(dep, **edge_properties): elif self.ctx.accept(SpecTokens.DEPENDENCY): # String replacement for toolchains # Look ahead to match upcoming value to list of toolchains - if self.next_token.value in toolchains: + if self.ctx.next_token.value in toolchains: assert self.ctx.accept(SpecTokens.UNQUALIFIED_PACKAGE_NAME) - # accepting the token advances it to the current token + # accepting the token advances it to be the current token # Push associated tokens back to the TokenContext - self.ctx.push(parseable_tokens(toolchains[self.current_token.value])) + self.ctx.push(parseable_tokens(toolchains[self.ctx.current_token.value])) continue is_direct = self.ctx.current_token.value[0] == "%" diff --git a/lib/spack/spack/test/conftest.py b/lib/spack/spack/test/conftest.py index b5b8e4d9825..5068cf48338 100644 --- a/lib/spack/spack/test/conftest.py +++ b/lib/spack/spack/test/conftest.py @@ -2054,7 +2054,7 @@ def shell_as(shell): @pytest.fixture() def nullify_globals(request, monkeypatch): ensure_configuration_fixture_run_before(request) - monkeypatch.setattr(spack.config, "CONFIG", None) + monkeypatch.setattr(spack.config, "CONFIG", {}) # So basic get operations do not throw monkeypatch.setattr(spack.caches, "MISC_CACHE", None) monkeypatch.setattr(spack.caches, "FETCH_CACHE", None) monkeypatch.setattr(spack.repo, "PATH", None)