Repository navigation
Conversation
…ngine)
Tags that are unknown or not where an open statement looks for them now say what Jinja2
does (parser.py _fail_ut_eof): "Encountered unknown tag 'endif'. Jinja was looking for the
following tags: ...". The code stays UnexpectedStatement, ExtraParams[0] is the tag and
ExtraParams[1] the sentence; an unknown name (`{% unknown_tag %}`) now reports it too instead
of UnexpectedToken. A template that ends inside a statement is the new
ErrorCode::TemplateSyntaxError ("Unexpected end of template. ..."), as are the trans-block
and required-block errors (reported at the end tag, as Jinja2 does); the compile-time checks
(unknown pluralization variable, a trans variable defined twice, a `caller` parameter with no
default that the body uses) are the new ErrorCode::TemplateAssertionError.
ErrorCode::TemplateRuntimeError gets ExtraParams[1] "TypeError" or "ValueError" where the
engine knows the class Jinja2 raises: not iterable, an undefined slice bound, the doubled
caller argument, and an invalid xmlattr key, whose message is now Jinja2's with the key's repr.
A name a `from ... import` cannot find is an undefined value whose message is Jinja2's ("the
template 'module' (imported on line 1) does not export the requested name 'x'"), and
`{% include x %}` tries the names of a host sequence in turn, as for a template list.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AWNL7kzwUCnXqkdTKL5Gb8
0432 module: TemplateAssertionError for the new code, Python's TypeError and ValueError where the engine names them, TemplatesNotFound for an include of several names, the search path in a FileSystemLoader's TemplateNotFound, the source of an included template's syntax error, and a template frame in tracebacks (jinja2cpp._debug, as Jinja2's fake_traceback). The engine half adds a Jinja2 message for a hyphenated block name. 0436: Template.generate runs the render on a daemon thread that takes turns with the caller, at most one 512-character batch ahead, in a copy of the caller's context; close, del and atexit end it, Ctrl-C stops it. Items are Jinja2's through the new RenderOptions::writeEachPiece. Follow-up 0452. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AWNL7kzwUCnXqkdTKL5Gb8
… read loader sources for errors only (0436, 0432) generate() renders on the caller's thread at the first item and yields Jinja2's items (writeEachPiece). The on-demand design moves to 0454. Loaders re-run a Python get_source only to show an error's source line. Template frames keep their file name; files 0452, 0454 and 0455. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AWNL7kzwUCnXqkdTKL5Gb8
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AWNL7kzwUCnXqkdTKL5Gb8
…und 2 limits (0436, 0432) A macro output past the 512-character buffer arrives in pieces (0456), more empty and folded items (0456), a Python loader's own TemplateNotFound message (0458), the error-path get_source call (docs/python.md), and the public-header growth in api-2.0.md and the G1 row. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AWNL7kzwUCnXqkdTKL5Gb8
…ng before an alignas member) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AWNL7kzwUCnXqkdTKL5Gb8
…aises (0432) transformers records these as TypeError; the module now raises Python's class where the engine names it. The transformers importorskip moves into a fixture, so the corpus test runs without transformers installed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AWNL7kzwUCnXqkdTKL5Gb8
Member
Author
|
@codex review Generated by Claude Code |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d479fb098a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…2 on #830) The names were drained into a list first, so an iterator that raised or never ended after a found name failed the include; Python's select_template stops at the first found name. The names tried are kept for the error, each counted against the sequence limit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AWNL7kzwUCnXqkdTKL5Gb8
…ce-param-not-moved) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AWNL7kzwUCnXqkdTKL5Gb8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Ruslan · project thread
Problem
The upstream Jinja2 3.1.6 suite through the Python module (
fallback="never") passed 607 of 856. The two largest gaps were the error contract (0432: wrong exception classes and messages, no template frame in tracebacks) andgenerate()(0436: one item for the whole output instead of Jinja2's items).Result
0432, engine. New additive codes
ErrorCode::TemplateSyntaxError = 1023andTemplateAssertionError = 1024(ExtraParams[0]is Jinja2's message). Unknown and misplaced tags say Jinja2's sentence ("Encountered unknown tag 'endif'. Jinja was looking for the following tags: ...";UnexpectedStatementkeeps the tag in[0], the sentence in[1]); a template ending inside a statement says "Unexpected end of template"; trans and required-block errors are reported at the end tag as in Jinja2; compile-time checks areTemplateAssertionError.TemplateRuntimeErrornames the Python class ([1]=TypeError/ValueError) where Jinja2 raises one. A namefrom ... importcannot find is an undefined value with Jinja2's message;{% include x %}takes a host sequence of names.0432, module. Jinja2's classes (
TemplateAssertionError,TypeError/ValueError,TemplatesNotFound), a FileSystemLoader'sTemplateNotFoundnaming the search path, the source of an included template's syntax error, and a template frame in tracebacks (jinja2cpp._debug, as Jinja2'sfake_traceback).0436. New public
RenderOptions::writeEachPiece: a sink gets oneWriteper piece Jinja2'sgenerate()yields (a text run, a{{ }}value, a macro or call block's output).Template.generate()/stream()yield those items, and an error after the items written before it. The render still runs at the first item, on the caller's thread: a worker-thread lazy generate was built and dropped after verifier round 1 (thread affinity of sqlite,threading.localand RLock; a gevent deadlock; an abort at interpreter exit). The on-demand design (a same-thread fiber) is filed as 0457.Upstream suite: 628 / 856 (73.4%), 95.9% of the supported subset. The expected-failures list drops the passing 0432 lines and both TestStreaming lines; two traceback tests are
deliberate(class names arejinja2cpp.exceptions.*).Follow-ups filed: 0456 (items Jinja2 folds into one: constants,
super(),self.b(), recursive loop, empty items, macro output over 512 characters), 0457 (on-demandgenerate()), 0458 (include and constructor errors with Jinja2's classes, a Python loader's own TemplateNotFound message).Public-header growth (two
ErrorCodevalues,RenderOptions::writeEachPiece) is recorded indocs/api-2.0.mdand in the G1 row ofdocs/release-2.0.md; it lands before G1.Validation
ctest(Debug) passes; Python tests 1636 passed, 16 skipped, 2 xfailed, plus the new BaseException test.scripts/preflight.sh --perfagainst e363ec2: all checks pass, largest instruction change +0.93%.address+undefinedRelWithDebInfo build, fullctestand the touched suites under ASan/UBSan pass.generate()items with Jinja2 on 10,500 random and about 55 hand-written templates (joined output always equal, no item coarser than Jinja2's).Limits
generate()renders the whole template at the first item (0457); some items are finer than Jinja2's (0456); a Python loader'sget_sourceruns again when a template fails to compile, to show the error's line.Process
writeEachPiece, include names,_debug.pycompile).boolbeforeOutStream'salignasbuffer padded the struct; moved after the buffer) and in the Python jobs (the chat-template corpus test caught onlyTemplateError, but 0432 now raises Python'sTypeErrorwhere transformers records one; I had run the Python tests with that file ignored locally, where a module-levelimportorskipskipped it, now a fixture). d479fb0 was green. 0f37cfd failed clang-tidy (an rvalue parameter not moved; I pushed it with preflight red), fixed in 3c2328b.Generated by Claude Code