Title: Python grandchild of .NET class is not created correctly if "__namespace__" attribute is set · Issue #544 · pythonnet/pythonnet · GitHub
Open Graph Title: Python grandchild of .NET class is not created correctly if "__namespace__" attribute is set · Issue #544 · pythonnet/pythonnet
X Title: Python grandchild of .NET class is not created correctly if "__namespace__" attribute is set · Issue #544 · pythonnet/pythonnet
Description: Environment Pythonnet version: 2.3 with #503 applied Python version: 3.4 64-bit Operating System: Ubuntu 14.04 Details Describe what you were trying to get done. I am trying to use python child of .NET class in python grandchild. What co...
Open Graph Description: Environment Pythonnet version: 2.3 with #503 applied Python version: 3.4 64-bit Operating System: Ubuntu 14.04 Details Describe what you were trying to get done. I am trying to use python child of ...
X Description: Environment Pythonnet version: 2.3 with #503 applied Python version: 3.4 64-bit Operating System: Ubuntu 14.04 Details Describe what you were trying to get done. I am trying to use python child of ...
Opengraph URL: https://github.com/pythonnet/pythonnet/issues/544
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Python grandchild of .NET class is not created correctly if \"__namespace__\" attribute is set","articleBody":"### Environment\r\n\r\n- Pythonnet version: 2.3 with #503 applied\r\n- Python version: 3.4 64-bit\r\n- Operating System: Ubuntu 14.04\r\n\r\n### Details\r\n\r\n- Describe what you were trying to get done.\r\n\r\nI am trying to use python child of .NET class in python grandchild.\r\n\r\n- What commands did you run to trigger this issue? If you can provide a\r\n [Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve)\r\n this will help us understand the issue.\r\nFollowing pure python code \r\n```python\r\nclass A:\r\n def __init__(self):\r\n self.foo()\r\n def foo(self): print('A.foo')\r\n\r\nclass B(A):\r\n def foo(self): print('B.foo')\r\n\r\na = A()\r\nb = B()\r\n```\r\nworks like expected and prints:\r\n\u003e A.foo\r\n\u003e B.foo\r\n\r\nConsider Python classes constructed with pythonnet:\r\n```python\r\nimport clr\r\nimport System.Windows.Forms as WinForms\r\n\r\nclass PythonGroupBox(WinForms.GroupBox):\r\n def __init__(self):\r\n print(\"PythonGroupBox.__init__\")\r\n self.MyInit()\r\n\r\n def MyInit(self):\r\n print(\"PythonGroupBox MyInit\")\r\n\r\nclass PythonGroupBoxDerived(PythonGroupBox):\r\n def MyInit(self):\r\n print(\"PythonGroupBoxDerived MyInit\")\r\n\r\ngrp1 = PythonGroupBox()\r\ngrp2 = PythonGroupBoxDerived()\r\n```\r\nworks fine and prints:\r\n\u003e PythonGroupBox.__init__\r\n\u003e PythonGroupBox MyInit\r\n\u003e PPythonGroupBox.__init__\r\n\u003e PythonGroupBoxDerived MyInit\r\n\r\nNow the same with \"__namespace__\":\r\n```python\r\nimport clr\r\nimport System.Windows.Forms as WinForms\r\n\r\nclass PythonGroupBox(WinForms.GroupBox):\r\n __namespace__ = \"System.Windows.Forms\"\r\n def __init__(self):\r\n print(\"PythonGroupBox.__init__\")\r\n self.MyInit()\r\n\r\n def MyInit(self):\r\n print(\"PythonGroupBox MyInit\")\r\n\r\nclass PythonGroupBoxDerived(PythonGroupBox):\r\n def MyInit(self):\r\n print(\"PythonGroupBoxDerived MyInit\")\r\n\r\ngrp1 = PythonGroupBox()\r\ngrp2 = PythonGroupBoxDerived()\r\n```\r\nThe output is:\r\n\u003e PythonGroupBox.__init__\r\n\u003e PythonGroupBox MyInit\r\n\u003e PythonGroupBox.__init__\r\n\u003e PythonGroupBox MyInit\r\n\r\nError (1), because MyInit Method didn't get overloaded !!!\r\n\r\nOne more try:\r\n```python\r\nimport clr\r\nimport System.Windows.Forms as WinForms\r\n\r\nclass PythonGroupBox(WinForms.GroupBox):\r\n __namespace__ = \"System.Windows.Forms\"\r\n def __init__(self):\r\n print(\"PythonGroupBox.__init__\")\r\n self.MyInit()\r\n\r\n def MyInit(self):\r\n print(\"PythonGroupBox MyInit\")\r\n\r\nclass PythonGroupBoxDerived(PythonGroupBox):\r\n __namespace__ = \"System.Windows.Forms\"\r\n def MyInit(self):\r\n print(\"PythonGroupBoxDerived MyInit\")\r\n\r\ngrp1 = PythonGroupBox()\r\ngrp2 = PythonGroupBoxDerived()\r\n```\r\nOutput gets really weird:\r\n\u003e PythonGroupBox.__init__\r\n\u003e PythonGroupBox MyInit\r\n\r\nError (2): during construction of PythonGroupBoxDerived the __init__() method was not called at all !!!\r\n\r\nImportant: this issue has nothing to do with issue #503: if I undo that fix than constructors get called twice, but errors described here persist.","author":{"url":"https://github.com/testrunner123","@type":"Person","name":"testrunner123"},"datePublished":"2017-09-15T09:51:48.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/544/pythonnet/issues/544"}
| 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:e08d9861-91dd-ce57-820b-3cee70baf4de |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E192:2586AA:1467B95:1A3D38E:69755FCC |
| html-safe-nonce | 87f66fce911e75be340907f92408dc72246666fc2c0e7f0afa2af6980e2001b2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMTkyOjI1ODZBQToxNDY3Qjk1OjFBM0QzOEU6Njk3NTVGQ0MiLCJ2aXNpdG9yX2lkIjoiODk0MTMwMjA4NDM4ODg3MjE0MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 4d803ac7f390c53ff567a90c1f33fc35970d7e36284969c6d91d3fffa31b0472 |
| hovercard-subject-tag | issue:257986023 |
| 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/544/issue_layout |
| twitter:image | https://opengraph.githubassets.com/6303da9b191417d8ee384fac80d8b40cc2227c24bb7e243706e532abf10ec048/pythonnet/pythonnet/issues/544 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/6303da9b191417d8ee384fac80d8b40cc2227c24bb7e243706e532abf10ec048/pythonnet/pythonnet/issues/544 |
| og:image:alt | Environment Pythonnet version: 2.3 with #503 applied Python version: 3.4 64-bit Operating System: Ubuntu 14.04 Details Describe what you were trying to get done. I am trying to use python child of ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | testrunner123 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4a4bf5f4e28041a9d2e5c107d7d20b78b4294ba261cab243b28167c16a623a1f |
| 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 | 488b30e96dfd057fbbe44c6665ccbc030b729dde |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width