Title: Cannot convert to managed type · Issue #1900 · pythonnet/pythonnet · GitHub
Open Graph Title: Cannot convert to managed type · Issue #1900 · pythonnet/pythonnet
X Title: Cannot convert to managed type · Issue #1900 · pythonnet/pythonnet
Description: Environment Pythonnet version: 3.0.0-rc4 Python version: 3.8 Operating System: Windows11 .NET Runtime: .NET Framework 4.8 Details With the following code in C#, when a Python class has getitem() defined, it will be converted to an array ...
Open Graph Description: Environment Pythonnet version: 3.0.0-rc4 Python version: 3.8 Operating System: Windows11 .NET Runtime: .NET Framework 4.8 Details With the following code in C#, when a Python class has getitem() de...
X Description: Environment Pythonnet version: 3.0.0-rc4 Python version: 3.8 Operating System: Windows11 .NET Runtime: .NET Framework 4.8 Details With the following code in C#, when a Python class has getitem() de...
Opengraph URL: https://github.com/pythonnet/pythonnet/issues/1900
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Cannot convert to managed type","articleBody":"### Environment\r\n\r\n- Pythonnet version: 3.0.0-rc4\r\n- Python version: 3.8\r\n- Operating System: Windows11\r\n- .NET Runtime: .NET Framework 4.8\r\n\r\n### Details\r\n\r\nWith the following code in C#, when a Python class has __getitem__() defined, it will be converted to an array (System.Object[]) in managed code:\r\n\r\nList\u003cobject\u003e lst = new List\u003cobject\u003e();\r\n using (Py.GIL())\r\n {\r\n using (var scope = Py.CreateScope())\r\n {\r\n scope.Set(\"lst\", lst);\r\n string text = @\"\r\nclass DBRow:\r\n def __init__(self, row, col_names):\r\n self.row = row\r\n self.col_names = col_names \r\n \r\n def __getitem__(self, key): \r\n if isinstance(key, int):\r\n return self.row[key]\r\n\r\n if key in self.col_names:\r\n index = self.col_names.index(key)\r\n return self.row[index]\r\n else:\r\n return None \r\n \r\ncol_names=['col1', 'col2', 'col3']\r\nrow=[1, '2', 3]\r\n\r\nr = DBRow(row, col_names)\r\nlst.Add(r)\r\n\";\r\n\r\n var code = PythonEngine.Compile(text);\r\n scope.Execute(code);\r\n }\r\n }\r\n string str = lst[0].GetType().ToString();\r\n","author":{"url":"https://github.com/Tiehong","@type":"Person","name":"Tiehong"},"datePublished":"2022-08-08T18:36:01.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/1900/pythonnet/issues/1900"}
| 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:9d95076b-ff41-2472-16ca-66accbd398b6 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9524:3D113A:707EAD:9E6ED6:6970B005 |
| html-safe-nonce | 801f45d287039625c8181d8b2560fed45b881e021c2d5da6dc8a1b2be999c9fc |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NTI0OjNEMTEzQTo3MDdFQUQ6OUU2RUQ2OjY5NzBCMDA1IiwidmlzaXRvcl9pZCI6IjU3MDY2NTY2NDM0NzQ4MjkzMTciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 36153ebac4f5f3253720b8726c2d1223937eead1aa6aad03a6c55aa843544116 |
| hovercard-subject-tag | issue:1332243951 |
| 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/1900/issue_layout |
| twitter:image | https://opengraph.githubassets.com/02dc860ed073d6f59be95c575c3616b07487df19fa1c0d172cb67a3e8c055041/pythonnet/pythonnet/issues/1900 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/02dc860ed073d6f59be95c575c3616b07487df19fa1c0d172cb67a3e8c055041/pythonnet/pythonnet/issues/1900 |
| og:image:alt | Environment Pythonnet version: 3.0.0-rc4 Python version: 3.8 Operating System: Windows11 .NET Runtime: .NET Framework 4.8 Details With the following code in C#, when a Python class has getitem() de... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Tiehong |
| hostname | github.com |
| expected-hostname | github.com |
| None | 8e0be80373b724b033cdf8a7b1f78bf5fb6a5d7a2182a9a403aa30894606e390 |
| 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 | b8714db0002cf78dc2d2566571807e404d6cb817 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width