From e3fa403ad2adc1fe9ccdc689dd786317906821d4 Mon Sep 17 00:00:00 2001 From: Tai Lee Date: Sat, 25 May 2013 12:28:52 +1000 Subject: [PATCH] Only execute `pathfields` expressions and functions if they are called with an `Item` argument. Otherwise, return an empty string. --- beetsplug/inline.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/beetsplug/inline.py b/beetsplug/inline.py index 086ed7160..2fc095983 100644 --- a/beetsplug/inline.py +++ b/beetsplug/inline.py @@ -80,6 +80,8 @@ def compile_inline(python_code): if is_expr: # For expressions, just evaluate and return the result. def _expr_func(obj): + if not isinstance(obj, Item): + return u'' values = _record(obj) try: return eval(code, values) @@ -90,6 +92,8 @@ def compile_inline(python_code): # For function bodies, invoke the function with values as global # variables. def _func_func(obj): + if not isinstance(obj, Item): + return u'' func.__globals__.update(_record(obj)) try: return func()