# HG changeset patch # User Franz Glasner # Date 1460063532 -7200 # Node ID 8715e5cc59ac0967a7559466b001866cfcc72147 # Parent ce2443285000101dbc72c095b11a727551439d2c Print a warning if a variable cannot be expanded. This is to simplify debugging. diff -r ce2443285000 -r 8715e5cc59ac configmix/config.py --- a/configmix/config.py Thu Mar 31 19:19:34 2016 +0200 +++ b/configmix/config.py Thu Apr 07 23:12:12 2016 +0200 @@ -6,6 +6,7 @@ from __future__ import division, absolute_import, print_function +import warnings try: from collections import OrderedDict as ConfigurationBase except ImportError: @@ -193,7 +194,14 @@ if end < 0: return s varname, filters = self._split_filters(s[start+2:end]) - varvalue = self._apply_filters(filters, self.getvar_s(varname)) + try: + varvalue = self._apply_filters(filters, self.getvar_s(varname)) + except KeyError: + warnings.warn("Cannot expand variable %r in string " + "%r" % (varname, s, ), + UserWarning, + stacklevel=1) + raise if varvalue is None: varvalue = u("") replaced = u(b"{0}{1}").format(s[:start], varvalue)