René's URL Explorer Experiment


Title: User encoding is skipped for elements iterated from non-generic .NET containers/enumerators · Issue #2679 · pythonnet/pythonnet · GitHub

Open Graph Title: User encoding is skipped for elements iterated from non-generic .NET containers/enumerators · Issue #2679 · pythonnet/pythonnet

X Title: User encoding is skipped for elements iterated from non-generic .NET containers/enumerators · Issue #2679 · pythonnet/pythonnet

Description: Environment Pythonnet version: 3.0.5 Python version: 3.12.9 Operating System: Linux (6.12.63-1-MANJARO # 1 SMP PREEMPT_DYNAMIC Thu, 18 Dec 2025 13:46:28 +0000 x86_64 GNU/Linux) .NET Runtime: coreclr 10.0.0 Details After creating and regi...

Open Graph Description: Environment Pythonnet version: 3.0.5 Python version: 3.12.9 Operating System: Linux (6.12.63-1-MANJARO # 1 SMP PREEMPT_DYNAMIC Thu, 18 Dec 2025 13:46:28 +0000 x86_64 GNU/Linux) .NET Runtime: corecl...

X Description: Environment Pythonnet version: 3.0.5 Python version: 3.12.9 Operating System: Linux (6.12.63-1-MANJARO # 1 SMP PREEMPT_DYNAMIC Thu, 18 Dec 2025 13:46:28 +0000 x86_64 GNU/Linux) .NET Runtime: corecl...

Opengraph URL: https://github.com/pythonnet/pythonnet/issues/2679

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"User encoding is skipped for elements iterated from non-generic .NET containers/enumerators","articleBody":"### Environment\n\n-   Pythonnet version: 3.0.5\n-   Python version: 3.12.9\n-   Operating System: Linux (6.12.63-1-MANJARO # 1 SMP PREEMPT_DYNAMIC Thu, 18 Dec 2025 13:46:28 +0000 x86_64 GNU/Linux)\n-   .NET Runtime: coreclr 10.0.0\n\n### Details\n\nAfter creating and registering an encoder (subclass of `IPyObjectEncoder`) to convert CLR objects to Python equivalents, iterating over non-generic containers yields CLR proxy objects instead of the converted Python object. However, doing the same for generic containers yields the converted objects as expected. In either case, accessing elements using the indexer produces a converted object.\n\nHere is a minimal test case demonstrating the issue:\n\n```python\nimport pytest\n\nimport System\nfrom Python.Test import CodecResetter\nfrom Python.Runtime import IPyObjectEncoder, PyObjectConversions\n\n@pytest.mark.parametrize('container_type', ['generic', 'non-generic'])\ndef test_iterator_element_conversion(container_type):\n    \"\"\"Test iterator element conversion from Python.\"\"\"\n    from Python.Test import Spam\n\n    try:\n        from Python.Test import IteratorElementEncoder\n    except ImportError:\n        class IteratorElementEncoder(IPyObjectEncoder):\n            __namespace__ = \"Python.Test\"\n            def CanEncode(self, clr_type):\n                return clr_type.Name == \"Spam\" and clr_type.Namespace == \"Python.Test\"\n            def TryEncode(self, clr_object):\n                return clr_object.GetValue()\n\n    spam_encoder = IteratorElementEncoder()\n    PyObjectConversions.RegisterEncoder(spam_encoder)\n\n    values = [\"first\", \"second\", \"third\"]\n    if container_type == 'generic':\n        container = System.Collections.Generic.List[Spam]()\n        for value in values:\n            container.Add(Spam(value))\n    else:\n        container = System.Array[Spam](Spam(v) for v in values)\n\n    assert type(container[0]) is str\n    assert next(iter(container.GetEnumerator())) == container[0]\n    assert list(container.GetEnumerator()) == values\n\n    CodecResetter.Reset()\n```\n\nAnd here are the results of running the test:\n\n```\n================================================================= FAILURES =================================================================\n______________________________________________ test_iterator_element_conversion[non-generic] _______________________________________________\n\n...\n        assert type(container[0]) is str\n\u003e       assert next(iter(container.GetEnumerator())) == container[0]\nE       AssertionError: assert \u003cPython.Test.Spam object at 0x7ee403c447c0\u003e == 'first'\nE        +  where \u003cPython.Test.Spam object at 0x7ee403c447c0\u003e = next(\u003cCLR.Iterator object at 0x7ee403c449c0\u003e)\nE        +    where \u003cCLR.Iterator object at 0x7ee403c449c0\u003e = iter(\u003cSystem.Collections.IEnumerator object at 0x7ee403c46600\u003e)\nE        +      where \u003cSystem.Collections.IEnumerator object at 0x7ee403c46600\u003e = \u003cbound method 'GetEnumerator'\u003e()\nE        +        where \u003cbound method 'GetEnumerator'\u003e = \u003cPython.Test.Spam[] object at 0x7f25379bb540\u003e.GetEnumerator\n\ntests/test_conversion.py:786: AssertionError\n========================================================= short test summary info ==========================================================\nFAILED tests/test_conversion.py::test_iterator_element_conversion[non-generic] - AssertionError: assert \u003cPython.Test.Spam object at 0x7ee403c447c0\u003e == 'first'\n======================================================= 1 failed, 1 passed =======================================================\n\n```\n\nThe first assert passes for each test because the indexers of both generic and non-generic containers properly convert the object. The final two asserts both fail for the non-generic version because conversion is not performed, and the `Spam` proxies are returned instead of being converted to strings.\n\n### Implementation Details\n\nThe issue stems from `src/runtime/Types/ClassBase.cs:ClassBase.tp_iter_impl()`, which determines the generic type of a container, defaulting to `System.Object` for non-generic containers. The element type is then passed to `src/runtime/Types/Iterator.cs:Iterator` where it is used in calls to `Converter.ToPython()`. The problem is that `System.Object` is passed as the element type even though the type is actually something different that could potentially be converted by a user encoder. But `System.Object` types are not passed on to user converters and are returned as CLR proxies instead.\n\nThe solution is to check if the element type is `System.Object`, and query and use the actual value type instead.","author":{"url":"https://github.com/brandon-avantus","@type":"Person","name":"brandon-avantus"},"datePublished":"2026-01-14T18:24:37.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/2679/pythonnet/issues/2679"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:6a6b986f-b4bd-73cf-c0ef-2a36f7bd4238
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idB0AE:37D417:31C5CE8:32764BF:697032EA
html-safe-nonce243662ed0565e409b76e63a2fb3bcda7299a52f78d312c3ceadd169240a551f8
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMEFFOjM3RDQxNzozMUM1Q0U4OjMyNzY0QkY6Njk3MDMyRUEiLCJ2aXNpdG9yX2lkIjoiODIzNDcwNDk3ODM2MjUxMjEwNiIsInJlZ2lvbl9lZGdlIjoic2VhIiwicmVnaW9uX3JlbmRlciI6InNlYSJ9
visitor-hmac749214b3842cf84567bb40d5df2f0f4d184624403157b3ccdbe4a1b15e83c334
hovercard-subject-tagissue:3814360268
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/pythonnet/pythonnet/2679/issue_layout
twitter:imagehttps://opengraph.githubassets.com/dcfe938f4fde2845bf9da7fa6562627502fb63d7d62d2123b62cb9baa6b1e16c/pythonnet/pythonnet/issues/2679
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/dcfe938f4fde2845bf9da7fa6562627502fb63d7d62d2123b62cb9baa6b1e16c/pythonnet/pythonnet/issues/2679
og:image:altEnvironment Pythonnet version: 3.0.5 Python version: 3.12.9 Operating System: Linux (6.12.63-1-MANJARO # 1 SMP PREEMPT_DYNAMIC Thu, 18 Dec 2025 13:46:28 +0000 x86_64 GNU/Linux) .NET Runtime: corecl...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamebrandon-avantus
hostnamegithub.com
expected-hostnamegithub.com
None9920a62ba22d06470388e2904804fb7e5ec51c9e35f81784e9191394c74b2bd2
turbo-cache-controlno-preview
go-importgithub.com/pythonnet/pythonnet git https://github.com/pythonnet/pythonnet.git
octolytics-dimension-user_id6050430
octolytics-dimension-user_loginpythonnet
octolytics-dimension-repository_id14748123
octolytics-dimension-repository_nwopythonnet/pythonnet
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id14748123
octolytics-dimension-repository_network_root_nwopythonnet/pythonnet
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasef643964067a552f02067066d6a910b2f90a5721f
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/pythonnet/pythonnet/issues/2679#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpythonnet%2Fpythonnet%2Fissues%2F2679
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpythonnet%2Fpythonnet%2Fissues%2F2679
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=pythonnet%2Fpythonnet
Reloadhttps://github.com/pythonnet/pythonnet/issues/2679
Reloadhttps://github.com/pythonnet/pythonnet/issues/2679
Reloadhttps://github.com/pythonnet/pythonnet/issues/2679
pythonnet https://github.com/pythonnet
pythonnethttps://github.com/pythonnet/pythonnet
Notifications https://github.com/login?return_to=%2Fpythonnet%2Fpythonnet
Fork 770 https://github.com/login?return_to=%2Fpythonnet%2Fpythonnet
Star 5.4k https://github.com/login?return_to=%2Fpythonnet%2Fpythonnet
Code https://github.com/pythonnet/pythonnet
Issues 155 https://github.com/pythonnet/pythonnet/issues
Pull requests 18 https://github.com/pythonnet/pythonnet/pulls
Discussions https://github.com/pythonnet/pythonnet/discussions
Actions https://github.com/pythonnet/pythonnet/actions
Projects 0 https://github.com/pythonnet/pythonnet/projects
Wiki https://github.com/pythonnet/pythonnet/wiki
Security Uh oh! There was an error while loading. Please reload this page. https://github.com/pythonnet/pythonnet/security
Please reload this pagehttps://github.com/pythonnet/pythonnet/issues/2679
Insights https://github.com/pythonnet/pythonnet/pulse
Code https://github.com/pythonnet/pythonnet
Issues https://github.com/pythonnet/pythonnet/issues
Pull requests https://github.com/pythonnet/pythonnet/pulls
Discussions https://github.com/pythonnet/pythonnet/discussions
Actions https://github.com/pythonnet/pythonnet/actions
Projects https://github.com/pythonnet/pythonnet/projects
Wiki https://github.com/pythonnet/pythonnet/wiki
Security https://github.com/pythonnet/pythonnet/security
Insights https://github.com/pythonnet/pythonnet/pulse
New issuehttps://github.com/login?return_to=https://github.com/pythonnet/pythonnet/issues/2679
New issuehttps://github.com/login?return_to=https://github.com/pythonnet/pythonnet/issues/2679
User encoding is skipped for elements iterated from non-generic .NET containers/enumeratorshttps://github.com/pythonnet/pythonnet/issues/2679#top
https://github.com/brandon-avantus
https://github.com/brandon-avantus
brandon-avantushttps://github.com/brandon-avantus
on Jan 14, 2026https://github.com/pythonnet/pythonnet/issues/2679#issue-3814360268
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.