https://github.com/python/cpython/commit/a26a301f8b09c1825b288fc8649f8174576361f4
commit: a26a301f8b09c1825b288fc8649f8174576361f4
branch: main
author: Bojun Ren <bj.ren.cod...@outlook.com>
committer: brandtbucher <brandtbuc...@gmail.com>
date: 2025-03-25T16:35:39-07:00
summary:

GH-130673: Gracefully handle missing sections in JIT build (GH-130906)

files:
A Misc/NEWS.d/next/Build/2025-03-06-20-55-34.gh-issue-130673.T3RSCI.rst
M Tools/jit/_targets.py

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 b5a839e07d4daf..b3b065652e0bb0 100644
--- a/Tools/jit/_targets.py
+++ b/Tools/jit/_targets.py
@@ -323,7 +323,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:

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-le...@python.org
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: arch...@mail-archive.com

Reply via email to