[3.5] bpo-28598: Support __rmod__ for RHS subclasses of str in % string formatting operations by mjpieters · Pull Request #94 · python/cpython
…tr in % string formatting operations
Martijn Pieters added 2 commits
…into bpo28598_backport_3.5
serhiy-storchaka
changed the title
[backport to 3.5] bpo-28598: Support __rmod__ for RHS subclasses of str in % string formatting operations
[3.5] bpo-28598: Support __rmod__ for RHS subclasses of str in % string formatting operations
akruis pushed a commit to akruis/cpython that referenced this pull request
akruis pushed a commit to akruis/cpython that referenced this pull request
This was referenced
SonicField added a commit to SonicField/cpython that referenced this pull request
Rename hir_builder_static_method_stack_pop_c to hir_builder_state_static_method_stack_pop_cpp, aligning with the state-bridge _cpp suffix convention established in Batch 2 (Phase 3 exception_table_) and Batch 4 (block_map_). Decl moved from the legacy extern "C" block in builder.h to builder_state_c.h alongside other state bridges. Class B-kept disposition for static_method_stack_ (jit::Stack<Register*>) now 100% closed: - Pop side: hir_builder_state_static_method_stack_pop_cpp bridge (renamed) + 1 C-side caller in builder_emit_c.c (emitInvokeMethod static-typed branch) - Push side: stays C++-direct from C++ method context (builder.cpp:3449); no C-side push-caller materialized, push_cpp bridge deferred per as-needed discipline (theologian 00:28:34Z + supervisor 00:28:51Z, Batch 4 precedent). ZERO new bridges (pure rename). NO opaque pointer added to PhxHirBuilderState (Class B-kept per Batch 4 precedent: bridge available, struct doc-comment notes "in spirit"; subsequent Phase 3 closure amendment per pythia python#94 (3) will explicitly declare keep-bias as final HirBuilder state disposition). Numstat (vs HEAD eb3cdf3): Python/jit/hir/builder.cpp +1 -1 (extern "C" decl rename) Python/jit/hir/builder.h +1 -2 (delete legacy extern; rename friend) Python/jit/hir/builder_emit_c.c +3 -3 (extern + 1 caller + 1 doc-comment rename) Python/jit/hir/builder_state_c.h +9 -0 (NEW decl with state- bridge naming + history) scripts/w45_bridge_drift_falsifier.sh +1 -0 (1 new fixture) TOTAL: NET +9L (forecast +10L; -1L variance, ~10%, under threshold). W45 fixture: 1 new (state_static_method_stack_pop_cpp) added per shepard 22:46:33Z same-commit discipline. Dry-run: 14/14 fixtures stage cleanly. Pre-commit compile-check: testkeeper 00:33:26Z BUILD_EXIT=0, 3-test sanity green (partial_conversions + W22 + W44). W44 gate: PASS. Authorization: theologian 00:28:34Z (P-strict over P-pre-emptive per as-needed consistency) + supervisor 00:28:51Z (DISPOSITION GO P-strict).
SonicField added a commit to SonicField/cpython that referenced this pull request
Rename hir_builder_temps_alloc_stack to hir_builder_state_temps_alloc_stack_cpp, aligning with the state-bridge _cpp suffix convention established in Batches 2/4/5. Decl moved from the legacy extern "C" block in builder.h to builder_state_c.h alongside other state bridges. 71 C-side caller sites in builder_emit_c.c renamed in lockstep (mechanical sed-style; line-count preserved). Class B-kept disposition for temps_ (TempAllocator) now CLOSED: - AllocateStack side: hir_builder_state_temps_alloc_stack_cpp bridge (renamed) + 71 C-side callers in builder_emit_c.c - AllocateNonStack + GetOrAllocateStack: stay C++-direct (zero C-side callers verified pre-Step-A by generalist 00:51:54Z + theologian 00:53:06Z); per as-needed discipline. Phase 3 §5 forcing-decision now COMPLETE across all 5 Class B members: - exception_table_ CLOSED via Batch 2 (push + size + entry + find) - block_map_ CLOSED via Batch 4 (blocks_lookup_cpp) - pending_b2_blocks_ DELETED via Batch 3 (dead-state, post-W26 refactor) - static_method_stack_ CLOSED via Batch 5 (pop_cpp rename) - temps_ CLOSED via Batch 6 (alloc_stack_cpp rename) Post-this-commit, theologian will amend spec §5 to declare "Class B-kept is FINAL disposition for HirBuilder state" per pythia python#94 (3) cathedral-scaffold concern + supervisor 23:59:54Z + 00:00:42Z closure-amendment commitment. Numstat (vs HEAD 782d56d): Python/jit/hir/builder.cpp +1 -1 (extern "C" decl rename) Python/jit/hir/builder.h +1 -2 (delete top-of-file extern; rename friend) Python/jit/hir/builder_emit_c.c +73 -73 (mechanical sed: 1 extern + 71 callers + 1 doc-comment) Python/jit/hir/builder_state_c.h +14 -0 (NEW decl with §5 closure history doc) scripts/w45_bridge_drift_falsifier.sh +1 -0 (1 new fixture) TOTAL: NET +14L (forecast +10L; +4L variance from larger §5 closure history doc-comment in builder_state_c.h — substantive explanatory content, not surface-bloat). W45 fixture: 1 new (state_temps_alloc_stack_cpp) added per shepard 22:46:33Z same-commit discipline. Dry-run: 15/15 fixtures stage cleanly. Pre-commit compile-check: testkeeper 00:56:59Z BUILD_EXIT=0, 3-test sanity green (partial_conversions + W22 + W44). W44 gate: PASS. §3.5 BUILD MODE required this batch (touched-files heuristic per supervisor 00:39:20Z amendment — all 4 builder*.{cpp,h,c} files in scope). To be exercised in testkeeper STRICT VERIFY post-commit. Authorization: theologian 00:53:06Z (R-single ATOMIC GO + +10L forecast confirmed; 73-site mechanical rename mitigated by sed-discipline + per-bench floor + §3.5 BUILD MODE catch any unintended runtime change) + supervisor 00:53:18Z (Step B GO).
SonicField added a commit to SonicField/cpython that referenced this pull request
Per docs/tier8-class-b-cport-migrate-arm-spec.md theologian 01:01:50Z + supervisor 01:02:46Z ADOPTED + supervisor 01:18:35Z + 03:44:19Z + 04:14:27Z (8-incident root-cause attribution to §3.5 restore-trap + b83f084 fix LIVE). Migrates HIRBuilder std::vector<ExceptionTableEntry> exception_table_ field to PhxExceptionTable (purpose-built typed-inline pure-C container in PhxHirBuilderState.exception_table_phx). Validates Pythia python#103 + python#94 (3) §5 forcing-decision MIGRATE-ARM via 1-pilot port (vs Phase 3's 4-Class-B-kept disposition). CONTAINER: PhxExceptionTable (builder_state_c.h): typed-inline data/count/capacity with 6 inline funcs (init/destroy/push/size/at/clear). Lazy-init, doubling realloc, free at HIRBuilder dtor. ExceptionTableEntry (builder_state_c.h): POD mirror of deleted C++ struct, fields flattened BCOffset → int + bool → unsigned char. C BODY PORTS (builder_state_c.c): hir_builder_state_init: also calls phx_exception_table_init hir_builder_state_destroy: NEW (calls phx_exception_table_destroy) parse_exception_table_c: pushes ExceptionTableEntry via phx_exception_table_push (replaces deleted push_cpp bridge) find_exception_handler_c: linear scan via phx_exception_table_size + at (replaces deleted size_cpp/entry_cpp bridges) C++ SHIM (transient compatibility per Phase A; Phase B deletes): HIRBuilder::parseExceptionTable → 1-line delegate to C body HIRBuilder::findExceptionHandler → C body returns index, shim converts via phx_exception_table_at preserving caller-contract HIRBuilder::buildHIRImpl translate-loop iterates PhxExceptionTable via size+at; .clear() goes to phx_exception_table_clear HIRBuilder::getSimpleExceptInfo wraps handler.target in BCOffset{} (now plain int post-C struct migration) emit_call_method_exception_handler_inline_c at builder.cpp:2883 still calls self->findExceptionHandler (KEPT shim — Phase B will rewire) DELETED: 3 _cpp bridge impls in builder.cpp (push/size/entry, ~37L) 3 friend decls in builder.h C++ struct ExceptionTableEntry in builder.h (5L) std::vector<ExceptionTableEntry> exception_table_ field in builder.h W45 §1-§2 fixture removals (3): the deleted bridges no longer have signatures to fuzz. Cumulative bridge-count delta: -3 (per Tier 8 spec §5 python#11 acceptance). Numstat (vs HEAD b83f084): Python/jit/hir/builder.cpp +21 -44 (-23 NET) Python/jit/hir/builder.h +14 -19 (-5 NET) Python/jit/hir/builder_state_c.c +30 -17 (+13 NET) Python/jit/hir/builder_state_c.h +103 -48 (+55 NET) scripts/w45_bridge_drift_falsifier.sh +0 -3 (-3 NET) TOTAL: NET +37L, bridge-count delta -3. Per Tier 8 spec §5 python#10 amendment (theologian 01:14:29Z): full Tier 8 endpoint ≤+0L cumulative is across all 4 Class B containers, not single pilot. exception_table_ pilot subtracts ~19% of Phase 3 +257L foundation cost; Phase 3 + Tier 8 Phase A cumulative now +257 + 37 = +294L. Apply mechanism: python single-process write (8-incident root cause was §3.5 restore-trap, NOT Write-tool-burst — but python single-process remains best practice per Pythia python#107 (4) isolation principle). Apply script: /tmp/apply_phase_a.py. EXPANDED PRE-COMMIT GATE per supervisor 01:17:23Z (testkeeper 04:24:49Z): Stage 1 compile-check: BUILD_EXIT=0 Stage 2 §3.5 BUILD MODE: 4/4 PASS, PhxExceptionTable INTACT post (§3.5 fix b83f084 VINDICATED) Stage 3 per-bench gate: GEO 1.27x, all 4 floor criteria PASS §5 forcing-decision MIGRATE-ARM EMPIRICALLY VALIDATED via this pilot: exception_table_ migrated to PhxArray-equivalent pure-C container without C++-side-keep dependency in C-side reads. Pattern propagatable to remaining 3 Class B containers (block_map_, temps_, static_method_stack_) in future Tier 8 batches per spec §1.1 container-shape transferability caveat. Phase B follow-up commit (NEXT) deletes C++ shims + rewires the remaining caller at builder.cpp:2883 per Tier 8 spec §5 python#5. Authorization: supervisor 03:44:19Z + 04:14:27Z; theologian 03:33:50Z patch-apply hybrid + 03:54:15Z content-trigger refinement (later attributed to §3.5 trap, not content) + 04:14:27Z fix directive. Cross-link: 8 incidents resolved via b83f084 §3.5 restore-trap fix. Pythia python#105 'fever has name infection still spreads' RESOLVED — fever was self-inflicted instrumentation. W48 spec marked CANCELLED post- this-commit per supervisor 04:14:27Z cascade re-retract.