From b58eb932430444829c785193040e4b5a6831d1fc Mon Sep 17 00:00:00 2001 From: George Sittas Date: Wed, 20 May 2026 20:50:24 +0300 Subject: [PATCH 1/2] [mypyc] Add test for incremental builtin_base class construction across groups --- mypyc/test-data/run-multimodule.test | 44 ++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/mypyc/test-data/run-multimodule.test b/mypyc/test-data/run-multimodule.test index 92b9fa6623fc..11527808c628 100644 --- a/mypyc/test-data/run-multimodule.test +++ b/mypyc/test-data/run-multimodule.test @@ -1734,3 +1734,47 @@ class Base: from native import make_child assert make_child(7) == "child(7)" assert make_child(-1) == "child(-1)" + +[case testIncrementalBuiltinBaseClassConstruction] +# Regression: builtin_base classes (Exception subclasses) were unconditionally +# added to func_to_decl in load_type_map, causing cross-group call sites to +# emit CPyDef instead of CPyType for the constructor. +from myerrors import MyError +from myutil import process + +def run(value: str) -> None: + if not value: + raise MyError("empty") + +def compute(x: str) -> str: + result = process(x) + if not result: + raise MyError("no result") + return result + +[file myerrors.py] +class MyError(Exception): + pass + +[file myutil.py] +def process(x: str) -> str: + return x + +[file myutil.py.2] +def process(x: str, flag: bool = False) -> str: + return x.strip() + +[file driver.py] +from native import run, compute +try: + run("") +except Exception as e: + print(str(e)) +print(compute("hello")) + +[out] +empty +hello +[out2] +empty +hello From 024120556c5d51e8c427983bc662d833c72f38c2 Mon Sep 17 00:00:00 2001 From: George Sittas Date: Thu, 21 May 2026 19:18:46 +0300 Subject: [PATCH 2/2] Fixed test --- mypyc/test-data/run-multimodule.test | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mypyc/test-data/run-multimodule.test b/mypyc/test-data/run-multimodule.test index 11527808c628..6ae6c0f2cab9 100644 --- a/mypyc/test-data/run-multimodule.test +++ b/mypyc/test-data/run-multimodule.test @@ -1739,8 +1739,8 @@ assert make_child(-1) == "child(-1)" # Regression: builtin_base classes (Exception subclasses) were unconditionally # added to func_to_decl in load_type_map, causing cross-group call sites to # emit CPyDef instead of CPyType for the constructor. -from myerrors import MyError -from myutil import process +from other_errors import MyError +from other_util import process def run(value: str) -> None: if not value: @@ -1752,15 +1752,15 @@ def compute(x: str) -> str: raise MyError("no result") return result -[file myerrors.py] +[file other_errors.py] class MyError(Exception): pass -[file myutil.py] +[file other_util.py] def process(x: str) -> str: return x -[file myutil.py.2] +[file other_util.py.2] def process(x: str, flag: bool = False) -> str: return x.strip()