Title: StackOverflowException on calling super().method() · Issue #2574 · pythonnet/pythonnet · GitHub
Open Graph Title: StackOverflowException on calling super().method() · Issue #2574 · pythonnet/pythonnet
X Title: StackOverflowException on calling super().method() · Issue #2574 · pythonnet/pythonnet
Description: Environment Python.NET version: 3.0.5 Tested on two configurations: Windows 10, Python 3.12.4, .NET Framework Windows 10, Python 3.12.4, .NET 9.0.201 Details Code to reproduce the issue is below. .NET library code: namespace TestLib { pu...
Open Graph Description: Environment Python.NET version: 3.0.5 Tested on two configurations: Windows 10, Python 3.12.4, .NET Framework Windows 10, Python 3.12.4, .NET 9.0.201 Details Code to reproduce the issue is below. ....
X Description: Environment Python.NET version: 3.0.5 Tested on two configurations: Windows 10, Python 3.12.4, .NET Framework Windows 10, Python 3.12.4, .NET 9.0.201 Details Code to reproduce the issue is below. ....
Opengraph URL: https://github.com/pythonnet/pythonnet/issues/2574
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"StackOverflowException on calling super().method()","articleBody":"### Environment\n* Python.NET version: 3.0.5\n* Tested on two configurations:\n * Windows 10, Python 3.12.4, .NET Framework\n * Windows 10, Python 3.12.4, .NET 9.0.201\n\n### Details\n\nCode to reproduce the issue is below.\n\n.NET library code:\n```csharp\nnamespace TestLib\n{\n public class BaseClass\n {\n public virtual string Foo()\n {\n return \"Foo\";\n }\n\n public virtual string Bar()\n {\n return \"Bar\";\n }\n }\n\n public class DerivedClass : BaseClass\n {\n public override string Foo()\n {\n return \"DerivedFoo\";\n }\n }\n}\n```\n\nPython code:\n```python\nfrom pathlib import Path\n\nimport clr\n\nclr.AddReference(str(Path(__file__).parent / 'TestLib.dll'))\n\nfrom TestLib import BaseClass, DerivedClass\n\n\nclass TestClass(DerivedClass):\n __namespace__ = 'CrlTest'\n\n def Foo(self):\n return 'Test' + super().Foo()\n\n def Bar(self):\n # This work fine\n # return 'Test' + DerivedClass.Bar(self)\n # This calls TestClass::Bar for some reason\n return 'Test' + super().Bar()\n\n\nif __name__ == '__main__':\n stc = TestClass()\n print('Foo() -\u003e ' + stc.Foo())\n print('Bar() -\u003e ' + stc.Bar())\n```\n\nPython script output:\n```\nFoo() -\u003e TestDerivedFoo\n\nProcess is terminated due to StackOverflowException.\n```\n\nFor some reason calling `super().Bar()` results in calling `TestClass.Bar(self)` instead of `DerivedClass.Bar(self)`, which in the end results in infinite recursion. Calling `DerivedClass.Bar(self)` directly works as expected.\n\nIt seem to be related to the fact that the method you try to override in Python is not defined in the immediate parent class, since `Foo` in the example works fine.","author":{"url":"https://github.com/Eswcvlad","@type":"Person","name":"Eswcvlad"},"datePublished":"2025-04-09T16:43:00.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/2574/pythonnet/issues/2574"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:497520a6-3c3e-49ad-6b62-5e177c3eeabd |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E8AC:112DEB:117C051:188D830:696FC692 |
| html-safe-nonce | 46f1819a2c7c11cb57788ae4a27c0c43306728773c60c68e3804046eb7137926 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFOEFDOjExMkRFQjoxMTdDMDUxOjE4OEQ4MzA6Njk2RkM2OTIiLCJ2aXNpdG9yX2lkIjoiMTc0NTk1OTc0MTUyMDA3MDI5MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | fa9a9174b57c3df6fda9744b80947994362738574fd0a524529538558644cc21 |
| hovercard-subject-tag | issue:2983357224 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/pythonnet/pythonnet/2574/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1f077a5811d9a07682486e9db776e63a5ec673946e96a09e820aa1b526cc270e/pythonnet/pythonnet/issues/2574 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1f077a5811d9a07682486e9db776e63a5ec673946e96a09e820aa1b526cc270e/pythonnet/pythonnet/issues/2574 |
| og:image:alt | Environment Python.NET version: 3.0.5 Tested on two configurations: Windows 10, Python 3.12.4, .NET Framework Windows 10, Python 3.12.4, .NET 9.0.201 Details Code to reproduce the issue is below. .... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Eswcvlad |
| hostname | github.com |
| expected-hostname | github.com |
| None | 330ca0f04ee8ecef1da04306a0dd49293f64679ee9a4bd5eaf2e1272bfdcf145 |
| turbo-cache-control | no-preview |
| go-import | github.com/pythonnet/pythonnet git https://github.com/pythonnet/pythonnet.git |
| octolytics-dimension-user_id | 6050430 |
| octolytics-dimension-user_login | pythonnet |
| octolytics-dimension-repository_id | 14748123 |
| octolytics-dimension-repository_nwo | pythonnet/pythonnet |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 14748123 |
| octolytics-dimension-repository_network_root_nwo | pythonnet/pythonnet |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 816ad575e27a390de2e2089ebe75261d12de9b37 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width