Skip to content
Snippets Groups Projects
Commit f6367091 authored by Mike Bayer's avatar Mike Bayer
Browse files

- fixed bug in python generation when variable names are used

  with identifiers like "else", "finally", etc. inside them
  [ticket:68]
parent 6c6d555c
No related branches found
No related tags found
No related merge requests found
0.2.0
- fixed bug in python generation when variable names are used
with identifiers like "else", "finally", etc. inside them
[ticket:68]
0.1.10 0.1.10
- fixed propagation of 'caller' such that nested %def calls - fixed propagation of 'caller' such that nested %def calls
within a <%call> tag's argument list propigates 'caller' within a <%call> tag's argument list propigates 'caller'
......
...@@ -138,7 +138,7 @@ class PythonPrinter(object): ...@@ -138,7 +138,7 @@ class PythonPrinter(object):
# if the current line doesnt have one of the "unindentor" keywords, # if the current line doesnt have one of the "unindentor" keywords,
# return False # return False
match = re.match(r"^\s*(else|elif|except|finally)", line) match = re.match(r"^\s*(else|elif|except|finally).*\:", line)
if not match: if not match:
return False return False
......
from setuptools import setup, find_packages from setuptools import setup, find_packages
version = '0.1.10' version = '0.2.0'
setup(name='Mako', setup(name='Mako',
version=version, version=version,
......
...@@ -99,7 +99,32 @@ and more block. ...@@ -99,7 +99,32 @@ and more block.
do_more_stuff(g) do_more_stuff(g)
""" """
def test_false_unindendor(self):
stream = StringIO()
printer = PythonPrinter(stream)
for line in [
"try:",
"elsemyvar = 12",
"if True:",
"print 'hi'",
None,
"finally:",
"dosomething",
None
]:
printer.writeline(line)
assert stream.getvalue() == \
"""try:
elsemyvar = 12
if True:
print 'hi'
finally:
dosomething
""" , stream.getvalue()
def test_backslash_line(self): def test_backslash_line(self):
block = \ block = \
""" """
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment