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.
This commit is contained in:
Massimiliano Culpo 2020-03-12 09:21:19 +01:00 committed by Todd Gamblin
parent ec720bf28d
commit 296d58ef6b
3 changed files with 3 additions and 3 deletions

View file

@ -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)

View file

@ -763,7 +763,7 @@ def url_for_version(self, version):
# 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:

View file

@ -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(