Chromium Code Reviews| Index: recipe_modules/context/api.py |
| diff --git a/recipe_modules/context/api.py b/recipe_modules/context/api.py |
| index de7075670061fff5f591ada696c4515c01121531..33556301a8b156b43ce092068f5f8fa7a9acfbfe 100644 |
| --- a/recipe_modules/context/api.py |
| +++ b/recipe_modules/context/api.py |
| @@ -25,6 +25,7 @@ Example: |
| """ |
| +import collections |
| import copy |
| from contextlib import contextmanager |
| @@ -137,8 +138,18 @@ class ContextApi(RecipeApi): |
| check_type('env', env, dict) |
| # strify everything except None in the env to allow for ints, Paths, etc. |
| # None has special meaning (i.e. "delete this env key") |
| - kwargs['env'] = {str(k): (str(v) if v is not None else None) |
| - for k, v in env.iteritems()} |
| + new_env = {} |
| + for k, v in env.iteritems(): |
| + k = str(k) |
| + if v is not None: |
| + v = str(v) |
| + try: |
| + v % collections.defaultdict(str) |
|
nodir
2017/05/31 21:49:03
it does not fail for v==`%s'
iannucci
2017/05/31 22:07:55
Done.
|
| + except Exception: |
| + raise ValueError(('Invalid %%-formatting parameter in envvar, ' |
| + 'only %%(ENVVAR)s allowed: %r') % (v,)) |
| + new_env[k] = v |
| + kwargs['env'] = new_env |
| if not kwargs: |
| yield |