summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSergey Kosukhin <sergey.kosukhin@mpimet.mpg.de>2020-05-27 11:45:14 +0200
committerGitHub <noreply@github.com>2020-05-27 11:45:14 +0200
commite73c39a5db1771cc4ff66c9c367a4c0be37a400a (patch)
tree2a6fc6116fdab196d9f97df6cca5316c400a5f8c /lib
parentd8c7073a9f67fe72d94e4a20e6accf99ccbda0fc (diff)
downloadspack-e73c39a5db1771cc4ff66c9c367a4c0be37a400a.tar.gz
spack-e73c39a5db1771cc4ff66c9c367a4c0be37a400a.tar.bz2
spack-e73c39a5db1771cc4ff66c9c367a4c0be37a400a.tar.xz
spack-e73c39a5db1771cc4ff66c9c367a4c0be37a400a.zip
concretize: fix UnboundLocalError due to import within a function (#16809)
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/spec.py3
-rw-r--r--lib/spack/spack/test/concretize.py5
2 files changed, 7 insertions, 1 deletions
diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py
index 0b9500246a..03f334597a 100644
--- a/lib/spack/spack/spec.py
+++ b/lib/spack/spack/spec.py
@@ -2134,6 +2134,8 @@ class Spec(object):
consistent with requirements of its packages. See flatten() and
normalize() for more details on this.
"""
+ import spack.concretize
+
if not self.name:
raise spack.error.SpecError(
"Attempting to concretize anonymous spec")
@@ -2145,7 +2147,6 @@ class Spec(object):
force = False
user_spec_deps = self.flat_dependencies(copy=False)
- import spack.concretize
concretizer = spack.concretize.Concretizer(self.copy())
while changed:
changes = (self.normalize(force, tests=tests,
diff --git a/lib/spack/spack/test/concretize.py b/lib/spack/spack/test/concretize.py
index ec594e4088..fd0e185168 100644
--- a/lib/spack/spack/test/concretize.py
+++ b/lib/spack/spack/test/concretize.py
@@ -633,3 +633,8 @@ class TestConcretize(object):
s = Spec('mpileaks %gcc@4.5:')
s.concretize()
assert str(s.compiler.version) == '4.5.0'
+
+ def test_concretize_anonymous(self):
+ with pytest.raises(spack.error.SpecError):
+ s = Spec('+variant')
+ s.concretize()