◐ Shell
clean mode source ↗

bpo-29453: Remove reference to undefined dictionary ordering in Tutorial by DimitrisJim · Pull Request #140 · python/cpython

SonicField added a commit to SonicField/cpython that referenced this pull request

@SonicField

Per supervisor 21:23:07Z + theologian 21:23:08Z + theologian P7 audit
20:53:51Z. Moves emitAnyCall from PARTIAL Cat-B to PURE-CONVERTED
(Phase 3D 98/100 → 99/100). One PARTIAL Cat-B remains: emitLoadMethodStatic
(blocked on VTableByteOffset wrapper, landed in push 58).

CHANGES:

C body (Python/jit/hir/builder_emit_c.c hir_builder_emit_any_call_c):
- New signature: drop call_kind/is_kw_arg/is_awaited/const_arg params;
  add opcode (raw int) and BcByteOffset base_offset (P5 wrapper).
- Move opcode→PhxCallKind switch into C body. CALL/CALL_FUNCTION_EX
  from Include/opcode.h; CALL_FUNCTION/_KW/CALL_KW/CALL_METHOD from
  Python/jit_common/opcode_stubs.h (stubbed >255 in 3.12 but kept for
  forward compat).
- INVOKE_FUNCTION/NATIVE/METHOD opcode constants local-#define'd in C
  body (209/216/185 from Python/jit_interp/3.12/cinder_opcode_ids.h).
  Local-define avoids pulling cinder_opcode.h which would shadow
  Include/opcode.h's BINARY_OP_ADD_INT and break BINARY_OP
  specialization #ifdef (per existing comment at builder_emit_c.c:30).
  Guarded with #ifndef so future direct cinder_opcode_ids.h include
  doesn't conflict.
- is_awaited hardcoded 0 for 3.12 with #if PY_VERSION_HEX guard +
  #error fallback for older Python (Phoenix targets 3.12 exclusively).
  Older-Python path would need C-side bc_it/bc_instr accessors (out-
  of-scope; covered by existing C++ stub history in git log).
- const_arg = PyTuple_GET_ITEM(code->co_consts, oparg) for INVOKE_*.
  Per HIRBuilder::constArg @ builder.cpp pre-conversion: borrowed ref,
  no GC trigger, no refcount. Lifetime = code object = compile duration.
  Theologian 20:53:51Z P7 audit confirmed safe to extract on C side.
- base_offset.v unwrap at the one boundary
  (hir_builder_emit_call_method_exception_handler_inline_c, raw-int API).

C++ stub (Python/jit/hir/builder.cpp HIRBuilder::emitAnyCall):
- Shrinks from 67 lines to 12 lines: pure type marshaling delegation.
- Wraps base_offset via bc_byte_offset_from_int factory (Phase A.5).
- Added bytecode_c.h include for BcByteOffset visibility.

P6 EXECUTION-PATH COVERAGE:
- PHX_CALL_KIND_CALL_METHOD (CALL/CALL_METHOD/CALL_KW): EXERCISED by
  test_exc_raise_catch (CALL ValueError(...)) + 4 W-2A-DISPATCH-COVERAGE
  sentinels (try/else, try/finally with raise, nested try, raise-in-handler)
  + 4 W-2B-RECONVERT sentinels (raise/catch, BINARY_SUBSCR_DICT-in-try,
  continue-in-loop, multi-except-in-loop) + test_multiple_exceptions_in_loop.
- PHX_CALL_KIND_CALL_EX (CALL_FUNCTION_EX): EXERCISED indirectly by any
  test using *args/**kwargs unpacking; covered by Phoenix CPython suite.
- PHX_CALL_KIND_VECTOR_CALL (CALL_FUNCTION/_KW): DEAD in 3.12 (stubbed
  >255). Switch case kept for forward compat with older Python builds.
- PHX_CALL_KIND_INVOKE_FUNCTION/NATIVE/METHOD: COVERAGE GAP. INVOKE_*
  opcodes are Cinder static-Python only; vanilla CPython 3.12 compiler
  does NOT emit them. Pure Python sentinel cannot exercise these
  branches without Cinder static-Python infrastructure (not available
  in this build per theologian 21:32:27Z + supervisor 21:32:42Z
  fallback). Conversion is mechanical (PyTuple_GET_ITEM extraction +
  delegate to existing emit functions); structural test exists at
  Lib/test/test_phoenix_partial_conversions.py:52. Execution-level
  coverage queued as W-CINDERX-INVOKE-COVERAGE workstream
  (cinderx_dev integration post-Phoenix-integration).

Phase 0' HIR-DIFF planned (theologian step 4): test_exc_raise_catch +
4 W-2A sentinels + Phoenix suite — pre/post conversion HIR comparison
to detect any divergence.

Verification pending: testkeeper rebuild + 30x all 8 W-2A+W-2B-RECONVERT
sentinels + 30x test_multiple_exceptions_in_loop + Phoenix suite +
ABBA + dual-arch.

Per supervisor 21:32:42Z (post pythia python#140 python#2): full 24-bench ABBA
between push 59 (this) and push 60 (emitLoadMethodStatic conversion)
— single-commit bisect window for cap-clock at 73 commits since last
24-bench (cbb9453 2026-04-23).