Title: Can not call inherited method on nested class, when another nested class inherits from it and defines an override. · Issue #1787 · pythonnet/pythonnet · GitHub
Open Graph Title: Can not call inherited method on nested class, when another nested class inherits from it and defines an override. · Issue #1787 · pythonnet/pythonnet
X Title: Can not call inherited method on nested class, when another nested class inherits from it and defines an override. · Issue #1787 · pythonnet/pythonnet
Description: This is a very specific setup with classes and inheritance, but is exactly what happened to us and where pythonnet does not do the right thing. It is closely related to #1420 but a slightly different configuration. Here is code to reprod...
Open Graph Description: This is a very specific setup with classes and inheritance, but is exactly what happened to us and where pythonnet does not do the right thing. It is closely related to #1420 but a slightly differe...
X Description: This is a very specific setup with classes and inheritance, but is exactly what happened to us and where pythonnet does not do the right thing. It is closely related to #1420 but a slightly differe...
Opengraph URL: https://github.com/pythonnet/pythonnet/issues/1787
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Can not call inherited method on nested class, when another nested class inherits from it and defines an override.","articleBody":"This is a very specific setup with classes and inheritance, but is exactly what happened to us and where pythonnet does not do the right thing.\r\n\r\nIt is closely related to #1420 but a slightly different configuration.\r\n\r\nHere is code to reproduce the issue:\r\n\r\n```cs\r\nnamespace pythonnet_testing {\r\n public class Creator {\r\n public static object CreateObject() =\u003e\r\n new BaseClass.NestedClass();\r\n }\r\n\r\n public class BaseClass {\r\n\r\n\r\n public virtual string GetSignal() =\u003e\r\n \"hello\";\r\n\r\n public class NestedClass : BaseClass {\r\n // NOTE: This is using the default `GetSignal` implementation\r\n }\r\n\r\n // NOTE: This class inherits from the nested class, and overrides the method in the base class\r\n // When this class is defined, we can no longer call `GetSignal` on instances of `NestedClass`\r\n // ==\u003e `Unhandled exception. Python.Runtime.PythonException: 'NestedClass' object has no attribute 'GetSignal'`\r\n public class InheritFromNested : BaseClass.NestedClass {\r\n public override string GetSignal() =\u003e\r\n \"override\";\r\n }\r\n }\r\n\r\n\r\n class Program {\r\n static void Main(string[] args) {\r\n var pyCode = @\"\r\nimport pythonnet_testing\r\no = pythonnet_testing.Creator.CreateObject()\r\nprint(f'Method call: {o.GetSignal()}')\r\n \";\r\n Runtime.PythonDLL = \"libpython3.9.dylib\";\r\n PythonEngine.Initialize();\r\n\r\n using (Py.GIL()) {\r\n PythonEngine.Exec(pyCode);\r\n }\r\n\r\n PythonEngine.Shutdown();\r\n }\r\n }\r\n}\r\n```\r\n\r\nNOTE: If I remove the `InheritFromNested` class, then the call to `o.GetSignal` will resolve the proper inherited virtual base method.","author":{"url":"https://github.com/Algoryx-NilsHjelte","@type":"Person","name":"Algoryx-NilsHjelte"},"datePublished":"2022-05-09T12:01:14.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/1787/pythonnet/issues/1787"}
| 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:3b219490-b08f-9453-1a0b-701c04184aa0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9D7A:10D6B7:20A146A:2B61B6E:69705F61 |
| html-safe-nonce | b1e6ff4a4b25c32a3737de864a54b6be49a3738f5002a61bbcfbef8ad2e2f557 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RDdBOjEwRDZCNzoyMEExNDZBOjJCNjFCNkU6Njk3MDVGNjEiLCJ2aXNpdG9yX2lkIjoiMjgyODI4Njc3NTY0ODA4MzgwOSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 444746f77194fe723c5b12a067ef042edf598afb4dcfb19f06a1841e74878b74 |
| hovercard-subject-tag | issue:1229600456 |
| 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/1787/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5889ef11deffb8095b91834ac65819643bb9e9c3c54994a6ed71136e94f42fbf/pythonnet/pythonnet/issues/1787 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5889ef11deffb8095b91834ac65819643bb9e9c3c54994a6ed71136e94f42fbf/pythonnet/pythonnet/issues/1787 |
| og:image:alt | This is a very specific setup with classes and inheritance, but is exactly what happened to us and where pythonnet does not do the right thing. It is closely related to #1420 but a slightly differe... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Algoryx-NilsHjelte |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9920a62ba22d06470388e2904804fb7e5ec51c9e35f81784e9191394c74b2bd2 |
| 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 | 7d6181066430cc06553c8396ca201e194ae33cb9 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width