mako icon indicating copy to clipboard operation
mako copied to clipboard

The location provided when a warning occurs in a python block is not accurate

Open rdan opened this issue 3 months ago • 0 comments

With the following code preceded by 10 empty lines:

<%
   print("\j")
%>

I get

<unknown>:1: SyntaxWarning: invalid escape sequence '\j'
memory:0x18bf4657080:36: SyntaxWarning: invalid escape sequence '\j'

"1" is ok (first line in the block "<%%>") but "36" is odd.

And with the following code preceded by 10 empty lines:

<%!
   print("\j")
%>

I get

<unknown>:1: SyntaxWarning: invalid escape sequence '\j'
memory:0x199007f7080:16: SyntaxWarning: invalid escape sequence '\j'

"1" is still ok but now "36" is replaced by "16" which is still odd.

For sure, in this use case, I just need to search for "\j" and I will find my error but in the case of a message not so clear, then the location of the warning could be far more complicated.

At the end, the ideal would be to have the same information as for an error (either directly the line number in the template or the line number of the start of the block + the line number inside the block).

rdan avatar Sep 19 '25 08:09 rdan