From e7e51b9fcd71b5ce70fce13c7b53e9452d57b4ec Mon Sep 17 00:00:00 2001 From: Pavel Koneski Date: Tue, 27 Oct 2026 17:46:05 -0700 Subject: [PATCH 1/2] Test for jumps out of exception handler; update DLR --- src/dlr | 2 +- .../Cases/CPythonCasesManifest.ini | 8 -- .../Cases/IronPythonCasesManifest.ini | 4 - tests/suite/test_regressions.py | 73 +++++++++++++++++++ 4 files changed, 74 insertions(+), 13 deletions(-) diff --git a/src/dlr b/src/dlr index 922753f8c..6f0a52a07 160000 --- a/src/dlr +++ b/src/dlr @@ -1 +1 @@ -Subproject commit 922753f8ccbf5186c15899116d5a407b6b1723fb +Subproject commit 6f0a52a07fdc83bb6f0c8c50ee77985b3694ac9a diff --git a/tests/IronPython.Tests/Cases/CPythonCasesManifest.ini b/tests/IronPython.Tests/Cases/CPythonCasesManifest.ini index 41ddd9a4c..002ca673c 100644 --- a/tests/IronPython.Tests/Cases/CPythonCasesManifest.ini +++ b/tests/IronPython.Tests/Cases/CPythonCasesManifest.ini @@ -744,10 +744,6 @@ Ignore=true [CPython.test_resource] RunCondition=$(IS_POSIX) # Module resource is Posix-specific -[CPython.test_robotparser] -Ignore=true -Reason=StackOverflowException - https://github.com/IronLanguages/ironpython2/issues/182 - [CPython.test_runpy] Ignore=true Reason=NotImplementedError: sys.implementation.cache_tag is None @@ -1031,10 +1027,6 @@ RunCondition=$(IS_WINDOWS) [CPython.test_with] Ignore=true -[CPython.test_wsgiref] -Ignore=true -Reason=StackOverflowException - https://github.com/IronLanguages/ironpython2/issues/182 - [CPython.test_xml_etree] Ignore=true diff --git a/tests/IronPython.Tests/Cases/IronPythonCasesManifest.ini b/tests/IronPython.Tests/Cases/IronPythonCasesManifest.ini index 90cf362e5..35dd07e63 100644 --- a/tests/IronPython.Tests/Cases/IronPythonCasesManifest.ini +++ b/tests/IronPython.Tests/Cases/IronPythonCasesManifest.ini @@ -98,10 +98,6 @@ Reason=Uses MAUI framework, which was MS internal? Ignore=true Reason=Unstable - https://github.com/IronLanguages/ironpython3/issues/1037 -[IronPython.test_tcf] -Ignore=true -Reason=StackOverflowException - https://github.com/IronLanguages/ironpython2/issues/182 - [IronPython.test_threadsafety] Ignore=true diff --git a/tests/suite/test_regressions.py b/tests/suite/test_regressions.py index 9c6868c35..901b20278 100644 --- a/tests/suite/test_regressions.py +++ b/tests/suite/test_regressions.py @@ -1757,4 +1757,77 @@ def test_ipy3_gh1977(self): else: self.assertTrue(isinstance(res, t)) + @skipUnlessIronPython() + def test_ipy3_gh1182(self): + # https://github.com/IronLanguages/ironpython3/issues/1182 + import System + from System.Diagnostics import StackTrace + + # leaving an except or finally clause with a jump, or raising an exception from a finally clause that + # is handled in the same function, must not grow the CLR stack + def except_continue(n): + depths = [] + for _ in range(n): + try: + int('x') + except ValueError: + depths.append(StackTrace().FrameCount) + continue + return depths + + def except_break(n): + depths = [] + for _ in range(n): + for _ in range(1): + try: + int('x') + except ValueError: + depths.append(StackTrace().FrameCount) + break + return depths + + def finally_break(n): + depths = [] + for _ in range(n): + for _ in range(1): + try: + int('x') + finally: + depths.append(StackTrace().FrameCount) + break + return depths + + def finally_raise(n): + depths = [] + for _ in range(n): + try: + try: + int('x') + finally: + depths.append(StackTrace().FrameCount) + raise KeyError() + except KeyError: + pass + return depths + + for f in (except_continue, except_break, finally_break, finally_raise): + # fewer iterations than the default compilation threshold, so that the loops stay interpreted + depths = f(25) + # the stack grew by a frame per iteration; call sites being set up account for small differences + self.assertLess(depths[-1] - depths[5], 5, f.__name__) + + # an exception rethrown by interpreted code keeps its .NET stack trace + def parse(): + try: + System.Int32.Parse('x') + finally: + pass + + def call(): + parse() + + with self.assertRaises(System.FormatException) as cm: + call() + self.assertIn('Int32.Parse', cm.exception.StackTrace) + run_test(__name__) From 868fb83639ee9b97e82584d521e7a7d5b76ceeb7 Mon Sep 17 00:00:00 2001 From: Pavel Koneski Date: Wed, 28 Oct 2026 12:45:22 -0700 Subject: [PATCH 2/2] Fix test failing on .NET Framework --- tests/suite/test_regressions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/suite/test_regressions.py b/tests/suite/test_regressions.py index 901b20278..97b699385 100644 --- a/tests/suite/test_regressions.py +++ b/tests/suite/test_regressions.py @@ -1828,6 +1828,6 @@ def call(): with self.assertRaises(System.FormatException) as cm: call() - self.assertIn('Int32.Parse', cm.exception.StackTrace) + self.assertTrue(any(name in cm.exception.StackTrace for name in ('Int32.Parse', 'ParseInt32'))) run_test(__name__)