René's URL Explorer Experiment


Title: Improve Testing For Importing Multiple Extension Modules From One File (and Deal With _testimportmultiple.c) · Issue #124978 · python/cpython · GitHub

Open Graph Title: Improve Testing For Importing Multiple Extension Modules From One File (and Deal With _testimportmultiple.c) · Issue #124978 · python/cpython

X Title: Improve Testing For Importing Multiple Extension Modules From One File (and Deal With _testimportmultiple.c) · Issue #124978 · python/cpython

Description: (low priority) The capability of loading multiple extension modules from a single .so file was added over a decade ago. AFAIK the feature wasn't actually tested at all for several years. The PEP 489 implementation added some test coverag...

Open Graph Description: (low priority) The capability of loading multiple extension modules from a single .so file was added over a decade ago. AFAIK the feature wasn't actually tested at all for several years. The PEP 48...

X Description: (low priority) The capability of loading multiple extension modules from a single .so file was added over a decade ago. AFAIK the feature wasn't actually tested at all for several years. The PE...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Improve Testing For Importing Multiple Extension Modules From One File (and Deal With _testimportmultiple.c)","articleBody":"(low priority)\r\n\r\nThe capability of loading multiple extension modules from a single .so file was added over a decade ago.  AFAIK the feature wasn't actually tested at all for several years.  The PEP 489 implementation added some test coverage, but only indirectly, superficially, and (perhaps) unintentionally.  Even then, the feature wasn't tested for single-phase init modules until a couple years ago and, again, only indirectly, superficially, and unintentionally.  (FWIW, I'm not sure the feature is meaningfully documented at all.)\r\n\r\nHere's the related history:\r\n\u003cdetails\u003e\r\n\u003csummary\u003e(expand)\u003c/summary\u003e\r\n\r\n* 2012 (3.4) - `Modules/_testimportmultiple.c` added (6b2cbeba58aeb0755bdefd02fb51a80ec66d6144); not actually used?\r\n* 2015 (3.5) - `Modules/_testmultiphase.c` added for [PEP 489](https://peps.python.org/pep-0489/) (d5cacbb1d9c3edc02bf0ba01702e7c06da5bc318); contained multiple modules (like `_testimportmultiple), but actually used in tests\r\n* 2022 (3.12) - `Modules/_testsinglephase.c` added ([gh-99039](https://github.com/python/cpython/pull/99039)); so we could stop using the `_testcapi` module to exercise singlephase init in tests; contained the impl. of the one module\r\n* 2023 (3.12) - `Modules/_testsinglephase.c` now implements multiple extension modules ([gh-101891](https://github.com/python/cpython/pull/101891))\r\n\r\n\u003c/details\u003e\r\n\r\nAt the time we added the feature originally, we also added an example implementation: `Modules/_testimportmultiple.c`.  However, it looks like it hasn't ever actually been used in any tests.  (Perhaps I'm missing something.)  We should use it and its modules to test the feature, or drop the file.\r\n\r\nWith all that in mind, we should consider improving test coverage of the feature, and use `_testimportmultiple.c` (or drop it).\r\n\r\nTo be clear, sorting this out is fairly **low priority**.  We have *basic* coverage of the feature, I'm not sure it's very widely used, and the status quo isn't causing any problems.\r\n\r\n(Honestly, I've created this issue only because I noticed `_testimportmultiple.c` isn't used anywhere and because of how clunky tests using `_testsinglephae.c` and `_testmultiphase.c` are to both understand and to add.  However, while looking closer, I realized the feature wasn't explicitly tested, nor thoroughly.)\r\n\r\n----\r\n\r\nHere's how I think we should proceed:\r\n\r\n1. determine what aspects of the feature need to be tested (see below)\r\n1. create the new `Modules/_testimportmultiple` directory\r\n1. for each test case:\r\n   a. implement the test (e.g. in `Lib/test/test_import/__init__.py` or `Lib/test/test_import/test_ext_multiple_in_file.py`)\r\n   b. add the new .c file (see [the devguide](https://devguide.python.org/developer-workflow/extension-modules/#adding-an-extension-module-to-cpython)) under `Modules/_testimportmultiple/`\r\n   c. implement the relevant modules there\r\n1. delete `Modules/_testimportmultiple.c`\r\n\r\n----\r\n\r\nWe should be sure the following is tested:\r\n\r\n* multiphase-init\r\n   * 2 modules in the same file (1 direct, 1 indirect)\r\n      * load direct only\r\n      * load indirect only\r\n      * load direct then indirect\r\n      * load indirect then direct\r\n   * 3 modules in the same file (1 direct, 2 indirect)\r\n      * similar permutations, including both indirect-only, indirect-indirect-only, indirect-direct-indirect, etc.\r\n   * 1 indirect module without a direct one (init func name does not match filename\r\n* singlephase-init\r\n   * same as multi-phase init\r\n   * 2 modules in same file that share some non-exported state stored in a global variable\r\n* singlephase-init and multiphase-init modules in the same file\r\n\r\nWe should be sure that the new tests include whatever `_testsinglephase.c` and `_testmultiphase.c` currently cover specific to multiple-modules-in-a-file.\r\n\r\nThe modules for each case could all be in a single file, i.e. the existing `Modules/_testimportmultiple.c`, but it probably makes more sense to implement each case in its own file (in a new `Modules/_testimportmultiple` directory).\r\n\r\n----\r\n\r\nAgain, the feature is actually tested currently, albeit indirectly and only superficially, through `Modules/_testmultiphase.c` and `Modules/_testsinglephase.c`.  However, as far as I know, there isn't any need for the multiple-modules-in-one-file approach in either case.  Once we're directly testing the feature using `_testimportmultiple.c`, we can stop testing it indirectly with the other two.  See [gh-124983](https://github.com/python/cpython/issues/124983).","author":{"url":"https://github.com/ericsnowcurrently","@type":"Person","name":"ericsnowcurrently"},"datePublished":"2024-10-04T18:02:06.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/124978/cpython/issues/124978"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:cf6bb6f4-1a45-a0dc-30b3-cdeebd2892d7
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idAD20:9F1EC:20712:2DCB7:696A0B80
html-safe-noncebb49d064bbcc0bf09fd779c0548ff9e0dedf3dc42bb8cc4e2180d42f598d53ac
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRDIwOjlGMUVDOjIwNzEyOjJEQ0I3OjY5NkEwQjgwIiwidmlzaXRvcl9pZCI6IjY2NDQ5NjA1MzA2NzU2NjU3OTIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac7884233d1dcc83900c015904eef8220bd3c9527786cbdadfe631dfb8c5a6e43b
hovercard-subject-tagissue:2566976315
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/124978/issue_layout
twitter:imagehttps://opengraph.githubassets.com/53e89717b874e4f56cd0141af6f05f5b3741d46c0bede90c0b3f6cc757236eb2/python/cpython/issues/124978
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/53e89717b874e4f56cd0141af6f05f5b3741d46c0bede90c0b3f6cc757236eb2/python/cpython/issues/124978
og:image:alt(low priority) The capability of loading multiple extension modules from a single .so file was added over a decade ago. AFAIK the feature wasn't actually tested at all for several years. The PEP 48...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameericsnowcurrently
hostnamegithub.com
expected-hostnamegithub.com
None699227a00bbb7fe1eec276d2ae1c3a93068bc5ba483bd9dc4b2a27a8f4f2f595
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
release7266b2d935baa1c6474b16dd9feaa5ca30607261
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/issues/124978#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F124978
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%2F124978
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/124978
Reloadhttps://github.com/python/cpython/issues/124978
Reloadhttps://github.com/python/cpython/issues/124978
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/issues/124978
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/124978
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/124978
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/124978
Improve Testing For Importing Multiple Extension Modules From One File (and Deal With _testimportmultiple.c)https://github.com/python/cpython/issues/124978#top
3.14bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.14%22
extension-modulesC modules in the Modules dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22extension-modules%22
testsTests in the Lib/test dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22tests%22
https://github.com/ericsnowcurrently
https://github.com/ericsnowcurrently
ericsnowcurrentlyhttps://github.com/ericsnowcurrently
on Oct 4, 2024https://github.com/python/cpython/issues/124978#issue-2566976315
6b2cbebhttps://github.com/python/cpython/commit/6b2cbeba58aeb0755bdefd02fb51a80ec66d6144
PEP 489https://peps.python.org/pep-0489/
d5cacbbhttps://github.com/python/cpython/commit/d5cacbb1d9c3edc02bf0ba01702e7c06da5bc318
gh-99039https://github.com/python/cpython/pull/99039
gh-101891https://github.com/python/cpython/pull/101891
the devguidehttps://devguide.python.org/developer-workflow/extension-modules/#adding-an-extension-module-to-cpython
gh-124983https://github.com/python/cpython/issues/124983
3.14bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.14%22
extension-modulesC modules in the Modules dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22extension-modules%22
testsTests in the Lib/test dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22tests%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.