aboutsummaryrefslogtreecommitdiffstats
path: root/mako/pyparser.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2010-03-02 23:05:41 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2010-03-02 23:05:41 +0000
commit004aca569a2eebc903044f95e93f36516a44a658 (patch)
tree5f7a719c84ac009684d5108d45d20dc057c360b4 /mako/pyparser.py
parent16326e69035fd606dd563eaf322033304da8c20c (diff)
downloadexternal_python_mako-004aca569a2eebc903044f95e93f36516a44a658.tar.gz
external_python_mako-004aca569a2eebc903044f95e93f36516a44a658.tar.bz2
external_python_mako-004aca569a2eebc903044f95e93f36516a44a658.zip
- ensure lru threading test doesn't run
- Source code escaping has been simplified. In particular, module source files are now generated with the Python "magic encoding comment", and source code is passed through mostly unescaped, except for that code which is regenerated from parsed Python source. This fixes usage of unicode in <%namespace:defname> tags. [ticket:99]
Diffstat (limited to 'mako/pyparser.py')
-rw-r--r--mako/pyparser.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/mako/pyparser.py b/mako/pyparser.py
index c79692c..34b2a6a 100644
--- a/mako/pyparser.py
+++ b/mako/pyparser.py
@@ -28,10 +28,14 @@ except ImportError:
def parse(code, mode='exec', **exception_kwargs):
"""Parse an expression into AST"""
+
+
try:
if _ast:
return _ast_util.parse(code, '<unknown>', mode)
else:
+ if isinstance(code, unicode):
+ code = code.encode('ascii', 'backslashreplace')
return compiler_parse(code, mode)
except Exception, e:
raise exceptions.SyntaxException("(%s) %s (%s)" % (e.__class__.__name__, str(e), repr(code[0:50])), **exception_kwargs)