Commit 6c715477 authored by Godefroid Chapelle's avatar Godefroid Chapelle

Problem: bad error if extends-cache with ${section:variable}

Solution: add explicit error message
parent 2480e5b6
Proper error message if extends-cache tries to expand ${section:variable}
......@@ -1786,6 +1786,7 @@ def _default_globals():
return globals_defs
variable_template_split = re.compile('([$]{[^}]*})').split
def _open(
base, filename, seen, download_options,
......@@ -1799,8 +1800,14 @@ def _open(
raw_download_options = _unannotate_section(download_options)
newest = bool_option(raw_download_options, 'newest', 'false')
fallback = newest and not (filename in downloaded)
extends_cache = raw_download_options.get('extends-cache')
if extends_cache and variable_template_split(extends_cache)[1::2]:
raise ValueError(
"extends-cache '%s' may not contain ${section:variable} to expand."
% extends_cache
)
download = zc.buildout.download.Download(
raw_download_options, cache=raw_download_options.get('extends-cache'),
raw_download_options, cache=extends_cache,
fallback=fallback, hash_name=True)
is_temp = False
downloaded_filename = None
......
......@@ -550,6 +550,28 @@ file: http://localhost/faulty.cfg (downloaded as ...), line: 1
'This is definitively not\n'
Failing if extends-cache contains ${section:variable}
-----------------------------------------------------
Because extends-cache is used to download extends, it may not contain ${section:variable}
as the state of all variables cannot be computed before all extends have been loaded.
>>> write(server_data, 'proper.cfg', """\
... [buildout]
... dummy = fjhfj
... """)
>>> write('buildout.cfg', """\
... [buildout]
... extends = %sproper.cfg
... extends-cache = ${buildout:dummy}
... """ % server_url)
>>> print_(system(buildout))
While:
Initializing.
... ValueError: extends-cache '${buildout:dummy}' may not contain ${section:variable} to expand.
Clean up
--------
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment