When rewriting a traceback, Jinja attempts to rewrite the CodeType object to change the name from the internal render function to something like "template" or "block {name}". It turns out this has been failing since 3.10 renamed a positional argument to CodeType and #1334 didn't make the correct change to address this. However, the code was surrounded by try/except Exception so it was silencing the error and all tests continued to pass.
We can use CodeType.replace to greatly simplify the code on Python 3.8+, and then only need to support one set of arguments for Python 3.7. Additionally, it seems like replacing filename again isn't needed, only the function name needs to change since the code was compiled with the correct filename already.
The try/except block is there because certain platforms such as Google App Engine apparently didn't support creating new CodeType objects at the time. It's been 13 years since then, and Google App Engine has changed significantly. I don't think its runtime is limited in that way any longer.
When rewriting a traceback, Jinja attempts to rewrite the
CodeTypeobject to change the name from the internal render function to something like "template" or "block {name}". It turns out this has been failing since 3.10 renamed a positional argument toCodeTypeand #1334 didn't make the correct change to address this. However, the code was surrounded bytry/except Exceptionso it was silencing the error and all tests continued to pass.We can use
CodeType.replaceto greatly simplify the code on Python 3.8+, and then only need to support one set of arguments for Python 3.7. Additionally, it seems like replacingfilenameagain isn't needed, only the function name needs to change since the code was compiled with the correct filename already.The
try/exceptblock is there because certain platforms such as Google App Engine apparently didn't support creating newCodeTypeobjects at the time. It's been 13 years since then, and Google App Engine has changed significantly. I don't think its runtime is limited in that way any longer.