From daff55c80d944d2ae352afc26503f3b89551cfc1 Mon Sep 17 00:00:00 2001 From: helium729 <30749877+helium729@users.noreply.github.com> Date: Thu, 29 Jan 2026 14:34:03 +0000 Subject: [PATCH] Fix migen name extraction for Python 3.14 Python 3.14 introduces a new opcode `LOAD_FAST_BORROW` which breaks `migen`'s bytecode analysis for name extraction. Since `migen` is currently unmaintained upstream, this commit adds a monkey patch in `litex/__init__.py` to add `LOAD_FAST_BORROW` to `migen.fhdl.tracer._load_build_opcodes`. This ensures that `litex` works correctly on Python 3.14+. --- litex/__init__.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/litex/__init__.py b/litex/__init__.py index 41b48dadfa..5a67a38c88 100644 --- a/litex/__init__.py +++ b/litex/__init__.py @@ -1,5 +1,13 @@ import sys +# Migen/Python 3.14+ patch ------------------------------------------------------------------------- +try: + import migen.fhdl.tracer + if "LOAD_FAST_BORROW" not in migen.fhdl.tracer._load_build_opcodes: + migen.fhdl.tracer._load_build_opcodes["LOAD_FAST_BORROW"] = migen.fhdl.tracer._bytecode_length_version_guard(3) +except ImportError: + pass + from litex.tools.litex_client import RemoteClient # Python-Data Import Helper ------------------------------------------------------------------------