You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Difficult to identify the location of an error of type: SyntaxException: Expected: \|,} at line: 3680 char: 2 #428
Hello,
I am using mako to create a generator of files (.c, .h, ...).
While implementing the templates, I faced the error: SyntaxException: Expected: \|,} at line: 3680 char: 2.
It took me some time to identify where the issue was.
I finally identified its location: 99: #define EVADC_u32CFG${Cfg_Adc["INDEX"]}_${CfgrdGroup}_CFGD_FADCI_KHz ${CfgrdGroup["FADCI_KHz"]
(there is a missing '}' at the end).
After searching in the code who is reporting this error, I found that "Lexer.parse_until_text()" is.
The difficulty with the exception generated by this function is that it points to a location far far from the source of the problem.
So, I did the following modifications in the function:
1/
I added the following lines at the start of the function:
self.matched_lineno = startlineno
self.matched_charpos = startcharpos
raise exceptions.SyntaxException(
"Expected '%s' while parsing text starting" % ",".join(text), **self.exception_kwargs
)
And now, the reported error message is: SyntaxException: Expected '\|,}' while parsing text starting at line: 99 char: 69
This way, at least I am able to identify the python block or expression that triggered the exception.
I don't know if this is the proper way to reach this goal, but at least I think it would be beneficial for every user of mako to be able to identify the python block/expression in which an error has been detected.
Activity
zzzeek commentedon Sep 19, 2025
we accept pull requests for simple fixes like this.
sqla-tester commentedon Aug 4, 2026
Mike Bayer has proposed a fix for this issue in the main branch:
Report the start of an unterminated tag or expression https://gerrit.sqlalchemy.org/c/sqlalchemy/mako/+/6866
Report the start of an unterminated tag or expression