Mercurial > genshi > genshi-test
changeset 132:0288dedce3d2
Name lookup in expressions: try locals first, then the context.
author | cmlenz |
---|---|
date | Fri, 04 Aug 2006 13:39:11 +0000 |
parents | 203f459e7e26 |
children | b9a0031d4bbb |
files | markup/eval.py |
diffstat | 1 files changed, 7 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/markup/eval.py +++ b/markup/eval.py @@ -104,7 +104,7 @@ filename = filename.encode('utf-8', 'replace') elif not filename: filename = '<string>' - tree.filename = '<string>' + tree.filename = filename if lineno <= 0: lineno = 1 @@ -119,10 +119,12 @@ code.co_names, code.co_varnames, filename, code.co_name, lineno, code.co_lnotab, (), ()) -def _lookup_name(data, name, locals=None): - val = data.get(name) - if val is None and locals: - val = locals.get(name) +def _lookup_name(data, name, locals_=None): + val = None + if locals_: + val = locals_.get(name) + if val is None: + val = data.get(name) if val is None: val = getattr(__builtin__, name, None) return val