diff --git a/Misc/NEWS.d/next/Build/2025-03-06-20-55-34.gh-issue-130673.T3RSCI.rst b/Misc/NEWS.d/next/Build/2025-03-06-20-55-34.gh-issue-130673.T3RSCI.rst new file mode 100644 index 00000000000000..20c52c3e3722b2 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2025-03-06-20-55-34.gh-issue-130673.T3RSCI.rst @@ -0,0 +1,2 @@ +Fix potential ``KeyError`` when handling object sections during JIT building +process. diff --git a/Tools/jit/_targets.py b/Tools/jit/_targets.py index aa2b56abf446b1..8da8b1a10cecec 100644 --- a/Tools/jit/_targets.py +++ b/Tools/jit/_targets.py @@ -312,7 +312,11 @@ def _handle_section( if section_type == "SHT_RELA": assert "SHF_INFO_LINK" in flags, flags assert not section["Symbols"] - value, base = group.symbols[section["Info"]] + maybe_symbol = group.symbols.get(section["Info"]) + if maybe_symbol is None: + # These are relocations for a section we're not emitting. Skip: + return + value, base = maybe_symbol if value is _stencils.HoleValue.CODE: stencil = group.code else: