Commit 0b90c878 authored by Andreas Jung's avatar Andreas Jung

Workaround for Python expressions encoded as unicode string.

  See http://mail.zope.org/pipermail/zope/2007-February/170537.html
parent 9c93f289
......@@ -11,6 +11,9 @@ Zope Changes
- Undeprecated 'zLOG', which will remain a backward-compatibility
shim for the Python logging module.
- PageTemplate/ZRPythonExpr.py: expressions represented as unicode string
caused UnicodeDecodeErrors.
Zope 2.10.2 (2007/01/26)
Bugs fixed
......
......@@ -29,7 +29,13 @@ class PythonExpr(PythonExpr):
def __init__(self, name, expr, engine):
self.text = text = expr.strip().replace('\n', ' ')
code, err, warn, use = compile_restricted_eval(text, str(self))
# Unicode expression are not handled properly by RestrictedPython
# We convert the expression to UTF-8 (ajung)
if isinstance(text, unicode):
text = text.encode('utf-8')
code, err, warn, use = compile_restricted_eval(text,
self.__class__.__name__)
if err:
raise engine.getCompilerError()('Python expression error:\n%s' %
'\n'.join(err))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment