René's URL Explorer Experiment


Title: Add tests to prevent regressions with the combination of `ctypes` and metaclasses. · Issue #125783 · python/cpython · GitHub

Open Graph Title: Add tests to prevent regressions with the combination of `ctypes` and metaclasses. · Issue #125783 · python/cpython

X Title: Add tests to prevent regressions with the combination of `ctypes` and metaclasses. · Issue #125783 · python/cpython

Description: Feature or enhancement Proposal: There were breaking changes to ctypes in Python 3.13. Projects like comtypes and pyglet, which implement functionality by combining ctypes and metaclasses, no longer work unless their codebases are update...

Open Graph Description: Feature or enhancement Proposal: There were breaking changes to ctypes in Python 3.13. Projects like comtypes and pyglet, which implement functionality by combining ctypes and metaclasses, no longe...

X Description: Feature or enhancement Proposal: There were breaking changes to ctypes in Python 3.13. Projects like comtypes and pyglet, which implement functionality by combining ctypes and metaclasses, no longe...

Opengraph URL: https://github.com/python/cpython/issues/125783

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Add tests to prevent regressions with the combination of `ctypes` and metaclasses.","articleBody":"# Feature or enhancement\n\n### Proposal:\n\nThere were [breaking changes to `ctypes` in Python 3.13](https://docs.python.org/3.13/whatsnew/3.13.html#ctypes).  \nProjects like [`comtypes`](https://github.com/enthought/comtypes/) and [`pyglet`](https://github.com/pyglet/pyglet), which implement functionality by combining `ctypes` and metaclasses, no longer work unless their codebases are updated.\nWe discussed what changes such projects need to make to their codebases in gh-124520.\n\nI believe the easiest and most effective way to prevent regressions from happening again is to add tests on the `cpython` side.\n\nI wrote a simple test like the one below.\n\n```py\n# Lib/test/test_ctypes/test_c_simple_type_meta.py?\nimport unittest\nimport ctypes\nfrom ctypes import POINTER, c_void_p\n\nfrom ._support import PyCSimpleType, _CData, _SimpleCData\n\n\nclass PyCSimpleTypeAsMetaclassTest(unittest.TestCase):\n    def tearDown(self):\n        # to not leak references, we must clean _pointer_type_cache\n        ctypes._reset_cache()\n\n    def test_early_return_in_dunder_new_1(self):\n        # this implementation is used in `IUnknown` of comtypes.\n\n        class _ct_meta(type):\n            def __new__(cls, name, bases, namespace):\n                self = super().__new__(cls, name, bases, namespace)\n                if bases == (c_void_p,):\n                    return self\n                if issubclass(self, _PtrBase):\n                    return self\n                if bases == (object,):\n                    _ptr_bases = (self, _PtrBase)\n                else:\n                    _ptr_bases = (self, POINTER(bases[0]))\n                p = _p_meta(f\"POINTER({self.__name__})\", _ptr_bases, {})\n                ctypes._pointer_type_cache[self] = p\n                return self\n\n        class _p_meta(PyCSimpleType, _ct_meta):\n            pass\n\n        class _PtrBase(c_void_p, metaclass=_p_meta):\n            pass\n\n        class _CtBase(object, metaclass=_ct_meta):\n            pass\n\n        class _Sub(_CtBase):\n            pass\n\n        class _Sub2(_Sub):\n            pass\n\n\n    def test_early_return_in_dunder_new_2(self):\n        # this implementation is used in `CoClass` of comtypes.\n\n        class _ct_meta(type):\n            def __new__(cls, name, bases, namespace):\n                self = super().__new__(cls, name, bases, namespace)\n                if isinstance(self, _p_meta):\n                    return self\n                p = _p_meta(\n                    f\"POINTER({self.__name__})\", (self, c_void_p), {}\n                )\n                ctypes._pointer_type_cache[self] = p\n                return self\n\n        class _p_meta(PyCSimpleType, _ct_meta):\n            pass\n\n        class _Base(object):\n            pass\n\n        class _Sub(_Base, metaclass=_ct_meta):\n            pass\n\n        class _Sub2(_Sub):\n            pass\n\n```\n\nIf no errors occur when this test is executed, we can assume that no regressions have occurred with the combination of `ctypes` and metaclasses.\nHowever, I feel that this may not be enough. What should we specify as the target for the `assert`?\n\n### Has this already been discussed elsewhere?\n\nNo response given\n\n### Links to previous discussion of this feature:\n\nhttps://github.com/python/cpython/issues/124520\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-125881\n* gh-125987\n* gh-125988\n* gh-126126\n* gh-126275\n* gh-126276\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/junkmd","@type":"Person","name":"junkmd"},"datePublished":"2024-10-21T11:33:32.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":7},"url":"https://github.com/125783/cpython/issues/125783"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:6bbf7e94-5ccd-2b8d-61db-6952a6a44405
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id92F8:2AC946:2BF21D:3BA799:6969AA0A
html-safe-noncecd331a050f53869ce9bf9b54b044e196164c16fb9500fae0b3603bc0f0a6e5b8
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MkY4OjJBQzk0NjoyQkYyMUQ6M0JBNzk5OjY5NjlBQTBBIiwidmlzaXRvcl9pZCI6IjcwMjQ5MTQzMjcxODQ5NzYzOTQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmace4b978b8420fa7e6455d456eaa89b16a81a242c148a0cd36b86a8ee192e1d39a
hovercard-subject-tagissue:2602262301
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/python/cpython/125783/issue_layout
twitter:imagehttps://opengraph.githubassets.com/7c51b776969d52343e4ed42d871050d16dbadb32374d7d5b7362ae161574780f/python/cpython/issues/125783
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/7c51b776969d52343e4ed42d871050d16dbadb32374d7d5b7362ae161574780f/python/cpython/issues/125783
og:image:altFeature or enhancement Proposal: There were breaking changes to ctypes in Python 3.13. Projects like comtypes and pyglet, which implement functionality by combining ctypes and metaclasses, no longe...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamejunkmd
hostnamegithub.com
expected-hostnamegithub.com
None24c4c97a2d520cb286b35e1a4c22d7a4df3c26a2fa28dd7cdf0e65db327b4de7
turbo-cache-controlno-preview
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
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
release124667f43168afb6c9c03b7c02eb5b1d2e1be3d9
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/issues/125783#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F125783
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%2Fpython%2Fcpython%2Fissues%2F125783
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=python%2Fcpython
Reloadhttps://github.com/python/cpython/issues/125783
Reloadhttps://github.com/python/cpython/issues/125783
Reloadhttps://github.com/python/cpython/issues/125783
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/issues/125783
Notifications https://github.com/login?return_to=%2Fpython%2Fcpython
Fork 33.9k https://github.com/login?return_to=%2Fpython%2Fcpython
Star 71.1k https://github.com/login?return_to=%2Fpython%2Fcpython
Code https://github.com/python/cpython
Issues 5k+ https://github.com/python/cpython/issues
Pull requests 2.1k https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects 31 https://github.com/python/cpython/projects
Security Uh oh! There was an error while loading. Please reload this page. https://github.com/python/cpython/security
Please reload this pagehttps://github.com/python/cpython/issues/125783
Insights https://github.com/python/cpython/pulse
Code https://github.com/python/cpython
Issues https://github.com/python/cpython/issues
Pull requests https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects https://github.com/python/cpython/projects
Security https://github.com/python/cpython/security
Insights https://github.com/python/cpython/pulse
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/125783
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/125783
Add tests to prevent regressions with the combination of ctypes and metaclasses.https://github.com/python/cpython/issues/125783#top
testsTests in the Lib/test dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22tests%22
topic-ctypeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-ctypes%22
type-featureA feature request or enhancementhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-feature%22
https://github.com/junkmd
https://github.com/junkmd
junkmdhttps://github.com/junkmd
on Oct 21, 2024https://github.com/python/cpython/issues/125783#issue-2602262301
breaking changes to ctypes in Python 3.13https://docs.python.org/3.13/whatsnew/3.13.html#ctypes
comtypeshttps://github.com/enthought/comtypes/
pyglethttps://github.com/pyglet/pyglet
gh-124520https://github.com/python/cpython/issues/124520
#124520https://github.com/python/cpython/issues/124520
gh-125783: Add tests to prevent regressions with the combination of ctypes and metaclasses. #125881https://github.com/python/cpython/pull/125881
[3.13] gh-125783: Add tests to prevent regressions with the combination of ctypes and metaclasses. (GH-125881) #125987https://github.com/python/cpython/pull/125987
[3.12] gh-125783: Add tests to prevent regressions with the combination of ctypes and metaclasses. (GH-125881) #125988https://github.com/python/cpython/pull/125988
gh-125783: Add more tests to prevent regressions with the combination of ctypes and metaclasses. #126126https://github.com/python/cpython/pull/126126
[3.13] gh-125783: Add more tests to prevent regressions with the combination of ctypes and metaclasses. (GH-126126) #126275https://github.com/python/cpython/pull/126275
[3.12] gh-125783: Add more tests to prevent regressions with the combination of ctypes and metaclasses. (GH-126126) #126276https://github.com/python/cpython/pull/126276
testsTests in the Lib/test dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22tests%22
topic-ctypeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-ctypes%22
type-featureA feature request or enhancementhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-feature%22
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.