1. Michael Bayer
  2. mako
  3. Issues


Issue #165 resolved

Incorrect line numbers in error messages

created an issue

The line numbers shown for runtime error messages are often slightly too big.

As far as I could see the problem is in exceptions.py in function _init(self, trcback), line 169. Actual code is:

for line in module_source.split("\n"): match = re.match(r'\s*# SOURCE LINE (\d+)', line) if match: template_ln = int(match.group(1)) (*) else: (*) template_ln += 1 module_ln += 1 line_map[module_ln] = template_ln

The two marked lines should be removed. It seems better to take the line from the last # SOURCE LINE statement. Increasing the line number for each python code line is not a good idea because there is more than one python code line for one template source line.

Comments (1)

  1. Log in to comment