diff options
author | Massimiliano Culpo <massimiliano.culpo@gmail.com> | 2020-03-12 09:21:19 +0100 |
---|---|---|
committer | Todd Gamblin <tgamblin@llnl.gov> | 2020-03-20 11:45:40 -0700 |
commit | 296d58ef6bf07fa1440c988d6b2e1268d83e671f (patch) | |
tree | d4296e5f9f0d502b797f12f4df40a122b37e3408 | |
parent | ec720bf28d04bb5eadafaea5607832428d92d9d5 (diff) | |
download | spack-296d58ef6bf07fa1440c988d6b2e1268d83e671f.tar.gz spack-296d58ef6bf07fa1440c988d6b2e1268d83e671f.tar.bz2 spack-296d58ef6bf07fa1440c988d6b2e1268d83e671f.tar.xz spack-296d58ef6bf07fa1440c988d6b2e1268d83e671f.zip |
Creating versions from urls doesn't modify class attributes (#15452)
fixes #15449
Before this PR a call to pkg.url_for_version was modifying
class attributes determining different results for subsequents
calls and an error when the urls was empty.
-rw-r--r-- | lib/spack/spack/fetch_strategy.py | 2 | ||||
-rw-r--r-- | lib/spack/spack/package.py | 2 | ||||
-rw-r--r-- | lib/spack/spack/test/url_fetch.py | 2 |
3 files changed, 3 insertions, 3 deletions
diff --git a/lib/spack/spack/fetch_strategy.py b/lib/spack/spack/fetch_strategy.py index eaf9f130c5..a01bc143aa 100644 --- a/lib/spack/spack/fetch_strategy.py +++ b/lib/spack/spack/fetch_strategy.py @@ -1239,7 +1239,7 @@ def _from_merged_attrs(fetcher, pkg, version): # TODO: refactor this logic into its own method or function # TODO: to avoid duplication mirrors = [spack.url.substitute_version(u, version) - for u in getattr(pkg, 'urls', [])] + for u in getattr(pkg, 'urls', [])[1:]] attrs = {fetcher.url_attr: url, 'mirrors': mirrors} else: url = getattr(pkg, fetcher.url_attr) diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py index b7efc3989b..b2d841f145 100644 --- a/lib/spack/spack/package.py +++ b/lib/spack/spack/package.py @@ -763,7 +763,7 @@ class PackageBase(with_metaclass(PackageMeta, PackageViewMixin, object)): # If no specific URL, use the default, class-level URL url = getattr(self, 'url', None) urls = getattr(self, 'urls', [None]) - default_url = url or urls.pop(0) + default_url = url or urls[0] # if no exact match AND no class-level default, use the nearest URL if not default_url: diff --git a/lib/spack/spack/test/url_fetch.py b/lib/spack/spack/test/url_fetch.py index 71a122455f..679240049d 100644 --- a/lib/spack/spack/test/url_fetch.py +++ b/lib/spack/spack/test/url_fetch.py @@ -32,7 +32,7 @@ def pkg_factory(): def factory(url, urls): def fn(v): - main_url = url or urls.pop(0) + main_url = url or urls[0] return spack.url.substitute_version(main_url, v) return Pkg( |