Commit Graph

4 Commits

Author SHA1 Message Date
9b7674d643 Fix post-merge CI regressions in wave_diff, x64_recomp, and piecewise_parse 2026-12-01 10:54:03 -05:00
1f92ae6a5d piecewise_parse: the barry test holds on CPython 3.12.1; parse() takes pieces only where needed (TEST-TRANSLATOR-PIECEWISE-PARSE)
Two findings from the review of #2237:

test_barry_as_flufl_is_parsed_whole errored on CPython 3.12.1 (lixonik):
there the parser does not read `from __future__ import barry_as_FLUFL` from
the source, so the stock compile it took as its reference rejects `<>`.
_PyPegen_checked_future_import is missing in v3.12.0, v3.12.1 and v3.13.0
and present in v3.12.16, v3.13.13 and v3.14.7. The test now takes this
interpreter's compile outcome, tree or error, for both spellings, and still
checks that the pieces give up.

On a fixed interpreter the pieces are the slower way (GrahamboJangles:
0.21 s whole, 0.54 s in pieces for the translator on 3.14.9). support.py
already installs its loader only where needed(); parse() now does the same
for its callers, the five standalone tests, unless piece_lines is named.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-26 12:32:56 +01:00
e654d10fdf piecewise_parse: CPython 3.13.16 has the tokenizer fix too (TEST-TRANSLATOR-PIECEWISE-PARSE)
v3.13.16 and v3.13.17 no longer copy the source at an f-string field
(Parser/lexer/lexer.c keeps last_expr_start); v3.12.16 still does. needed()
is now true on 3.12, 3.13.0 to 3.13.15 and 3.14.0 to 3.14.7.

The README paragraph moves below the one about calling the translator, so
it no longer touches the lines #2114 adds.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-26 10:52:13 +01:00
21d1f0ceb8 tests: support.py compiles the translator from pieces, 7 s -> 1 s per uncached import (TEST-TRANSLATOR-PIECEWISE-PARSE)
On CPython 3.12.0 to 3.14.7 the tokenizer copies the rest of its input at
every f-string field (update_fstring_expr: strlen, PyMem_Malloc, strncpy),
and import hands a module over as one string, so compiling the 1.2 MB
tools/rdna2spirv.py takes 7 s, 0.1 s of it code generation. CPython fixed it
in 3.14.8 and 3.15.0 (gh-155525); 3.12, which CI pins, keeps it.

tests/semantic/piecewise_parse.py finds statement starts with tokenize,
parses top-level statements in pieces of 300 lines (a longer class is cut
between the statements of its body) with one newline in front for every line
before the piece, and joins them into the tree a whole-file parse gives.
Whatever does not fit returns None and the source is compiled the usual way.

tests/semantic/support.py loads the modules of TOOLS_DIR through a
SourceFileLoader subclass that compiles that tree, by a sys.meta_path finder
placed just before PathFinder, only on the interpreters above. A valid .pyc
is still used first.

tests/test_piecewise_parse.py compares the trees for every Python file of
the repository, hand-written boundary cases, the exceptions and warnings
against compile(), and code objects against compile(bytes).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-26 10:44:47 +01:00