summaryrefslogtreecommitdiff
path: root/lib/spack/spack/spec.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/spack/spack/spec.py')
-rw-r--r--lib/spack/spack/spec.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py
index f37d993993..9140a3532a 100644
--- a/lib/spack/spack/spec.py
+++ b/lib/spack/spack/spec.py
@@ -213,6 +213,19 @@ def colorize_spec(spec):
return clr.colorize(re.sub(_SEPARATORS, insert_color(), str(spec)) + "@.")
+OLD_STYLE_FMT_RE = re.compile(r"\${[A-Z]+}")
+
+
+def ensure_modern_format_string(fmt: str) -> None:
+ """Ensure that the format string does not contain old ${...} syntax."""
+ result = OLD_STYLE_FMT_RE.search(fmt)
+ if result:
+ raise SpecFormatStringError(
+ f"Format string `{fmt}` contains old syntax `{result.group(0)}`. "
+ "This is no longer supported."
+ )
+
+
@lang.lazy_lexicographic_ordering
class ArchSpec:
"""Aggregate the target platform, the operating system and the target microarchitecture."""
@@ -4362,6 +4375,7 @@ class Spec:
that accepts a string and returns another one
"""
+ ensure_modern_format_string(format_string)
color = kwargs.get("color", False)
transform = kwargs.get("transform", {})