提交 5e3f90ff authored 作者: Frederic's avatar Frederic

Do not trigger the call to callable default value when we create the config value.

We want to have it evaluated only if the config value get used. Otherwise, this will trigger compilation at import time for a following commit.
上级 cfdacf50
...@@ -226,8 +226,18 @@ def AddConfigVar(name, doc, configparam, root=config, in_c_key=True): ...@@ -226,8 +226,18 @@ def AddConfigVar(name, doc, configparam, root=config, in_c_key=True):
configparam.fullname) configparam.fullname)
configparam.doc = doc configparam.doc = doc
configparam.in_c_key = in_c_key configparam.in_c_key = in_c_key
# trigger a read of the value from config files and env vars # Trigger a read of the value from config files and env vars
configparam.__get__() # This allow to filter wrong value from the user.
if not callable(configparam.default):
configparam.__get__()
else:
# We do not want to evaluate now the default value when it is a callable.
try:
fetch_val_for_key(configparam.fullname)
# The user provided a value, filter it now.
configparam.__get__()
except KeyError:
pass
setattr(root.__class__, sections[0], configparam) setattr(root.__class__, sections[0], configparam)
_config_var_list.append(configparam) _config_var_list.append(configparam)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论