disable compiled functemplates if not using PY2

The AST code needs rewritten for PY3. This is tracked in
https://github.com/beetbox/beets/issues/2058
This commit is contained in:
Johnny Robeson 2016-06-20 06:17:20 -04:00
parent 9f6b07fe1f
commit fd3f0b5159

View file

@ -508,7 +508,8 @@ class Template(object):
def __init__(self, template):
self.expr = _parse(template)
self.original = template
self.compiled = self.translate()
if six.PY2:
self.compiled = self.translate()
def __eq__(self, other):
return self.original == other.original
@ -524,9 +525,12 @@ class Template(object):
def substitute(self, values={}, functions={}):
"""Evaluate the template given the values and functions.
"""
try:
res = self.compiled(values, functions)
except: # Handle any exceptions thrown by compiled version.
if six.PY2:
try:
res = self.compiled(values, functions)
except: # Handle any exceptions thrown by compiled version.
res = self.interpret(values, functions)
else:
res = self.interpret(values, functions)
return res