Skip to content

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

Closed

Description

@rdan

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).

Activity

  1. sqla-tester commented on Aug 4, 2026

    @sqla-tester
    Collaborator

    Mike Bayer has proposed a fix for this issue in the main branch:

    Report template location for compile time warnings https://gerrit.sqlalchemy.org/c/sqlalchemy/mako/+/6863

  2. sqla-tester commented on Aug 4, 2026

    @sqla-tester
    Collaborator

    Mike Bayer has proposed a fix for this issue in the main branch:

    Report template location for compile time warnings https://gerrit.sqlalchemy.org/c/sqlalchemy/mako/+/6864

  3. added a commit that references this issue on Aug 4, 2026
    a162c9c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions