GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-116417: Add _testlimitedcapi C extension by vstinner · Pull Request #116419 · python/cpython

Conversation

@vstinner

@vstinner vstinner commented Mar 6, 2024 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Add a new C extension "_testlimitedcapi" which is only built with the limited C API.

Move heaptype_relative.c and vectorcall_limited.c from Modules/_testcapi/ to Modules/_testlimitedcapi/.

  • Issue: C API: Move limited C API tests from _testcapi to a new _testlimitedcapi extension #116417

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ericsnowcurrently reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@vstinner
pythongh-116417: Add _testlimitedcapi C extension
af160ec
Add a new C extension "_testlimitedcapi" which is only built with the
limited C API.

Move heaptype_relative.c and vectorcall_limited.c from
Modules/_testcapi/ to Modules/_testlimitedcapi/.
@vstinner
vstinner requested review from a team, corona10, erlend-aasland, gvanrossum and markshannon as code owners March 6, 2024 14:48
@bedevere-app bedevere-app Bot added the awaiting core review label Mar 6, 2024
@bedevere-app bedevere-app Bot mentioned this pull request Mar 6, 2024
C API: Move limited C API tests from _testcapi to a new _testlimitedcapi extension #116417
Closed
@vstinner

vstinner commented Mar 6, 2024

Copy link
Copy Markdown
Member Author

@erlend-aasland @encukou @sobolevn @colesbury: What do you think of this change? (See the issue for the rationale.)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented Mar 6, 2024

Copy link
Copy Markdown
Member Author

If we land this change, should we move tests which don't use the non-limited C API (tests only using the limited C API) to _testlimitedapi?

This change should be backported to 3.11 and 3.12 branches to ease backport of future changes.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner vstinner added the skip news label Mar 6, 2024
vstinner added 2 commits March 6, 2024 16:00
@vstinner
Update generate_stdlib_module_names.py
29d70e7
@vstinner
Fix Free Threading build
0378781
colesbury
colesbury reviewed Mar 6, 2024
View reviewed changes

@colesbury colesbury left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a good idea to me.

  • The #include "pyconfig.h" can be removed from vectorcall_limited.c and heaptype_relative.c now that it's part of parts.h
  • heaptype_relative.c can also remove the Py_LIMITED_API define now that it's defined in parts.h.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Modules/_testlimitedcapi/vectorcall_limited.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

@zooba

zooba commented Mar 6, 2024

Copy link
Copy Markdown
Member

Can we remove xxlimited.c then? I'm pretty sure that's only in there to test the limited API, so if we have another module doing it, there isn't a need for that one.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

vstinner added 2 commits March 6, 2024 23:17
@vstinner
Remove now redundant code
2158b2f
@vstinner
Remove redundant code
116b7a6
@vstinner

vstinner commented Mar 6, 2024

Copy link
Copy Markdown
Member Author

@colesbury:

This seems like a good idea to me. (...)

Fixed: nicely spotted for remaining code in heaptype_relative.c.

I had a lot of build issues to build the new C extension properly on Linux and Windows, and then I forgot these lines.

@zooba:

Can we remove xxlimited.c then? I'm pretty sure that's only in there to test the limited API, so if we have another module doing it, there isn't a need for that one.

I don't think that it's a test, but more an example to write code using the limited C API. I started with the comment:

/* Use this file as a template to start implementing a module that
   also declares object types. All occurrences of 'Xxo' should be changed

cc @encukou

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner
Fix make check-c-globals
b173670
@vstinner
vstinner requested a review from ericsnowcurrently as a code owner March 6, 2024 22:58
@vstinner

vstinner commented Mar 7, 2024

Copy link
Copy Markdown
Member Author

@colesbury: I addressed your remarks and tests now pass. You can review the updated PR ;-)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

colesbury
colesbury approved these changes Mar 7, 2024
View reviewed changes

@colesbury colesbury left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels Mar 7, 2024
corona10
corona10 approved these changes Mar 7, 2024
View reviewed changes
sobolevn
sobolevn approved these changes Mar 7, 2024
View reviewed changes

@sobolevn sobolevn left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a good idea, thank you!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
erlend-aasland
erlend-aasland reviewed Mar 7, 2024
View reviewed changes

@erlend-aasland erlend-aasland left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like it if you could create an entry for this module in configure.ac; that way it is easier to see if this module is enabled or not. Relevant output from sample ./configure and make invocations:

The following modules are *disabled* in configure script:
_ctypes_test              _testbuffer               _testcapi              
_testclinic               _testclinic_limited       _testexternalinspection
_testimportmultiple       _testinternalcapi         _testmultiphase        
_testsinglephase          _xxtestfuzz               xxsubtype              
checking for stdlib extension module _testcapi... disabled
checking for stdlib extension module _testclinic... disabled
checking for stdlib extension module _testclinic_limited... disabled
checking for stdlib extension module _testinternalcapi... disabled
checking for stdlib extension module _testbuffer... disabled
checking for stdlib extension module _testimportmultiple... disabled
checking for stdlib extension module _testmultiphase... disabled
checking for stdlib extension module _testsinglephase... disabled
checking for stdlib extension module _testexternalinspection... disabled

If you "hide" this new extension module behind the _testcapi module, it will not show up in these outputs.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@vstinner
configure: add _testlimitedcapi test extension
7fe437f
@vstinner

vstinner commented Mar 7, 2024

Copy link
Copy Markdown
Member Author

I'd like it if you could create an entry for this module in configure.ac; that way it is easier to see if this module is enabled or not.

Sure! It's done.

Example:

$ ./configure --disable-test-modules|grep testlimited
checking for stdlib extension module _testlimitedcapi... disabled

The test extension is now disabled as expected.

erlend-aasland reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

erlend-aasland
erlend-aasland approved these changes Mar 7, 2024
View reviewed changes
Comment thread Modules/Setup.stdlib.in Resolved

Uh oh!

There was an error while loading. Please reload this page.

@vstinner @erlend-aasland
Update Modules/Setup.stdlib.in
838e7dd
Co-authored-by: Erlend E. Aasland <[email protected]>
@erlend-aasland

erlend-aasland commented Mar 7, 2024

Copy link
Copy Markdown
Contributor

Thanks! On more nit :)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@erlend-aasland

erlend-aasland commented Mar 7, 2024

Copy link
Copy Markdown
Contributor

It's a nice change; it makes sense to have this as a separate test module IMO.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner
vstinner enabled auto-merge (squash) March 7, 2024 17:57
@vstinner
vstinner merged commit d9bcdda into python:main Mar 7, 2024
@vstinner
vstinner deleted the testlimitedcapi branch March 7, 2024 18:31
@bedevere-app bedevere-app Bot removed the awaiting merge label Mar 7, 2024
@vstinner

vstinner commented Mar 7, 2024

Copy link
Copy Markdown
Member Author

Thanks for your helpful reviews! I merged my PR.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented Mar 7, 2024

Copy link
Copy Markdown
Member Author

Backporting this change to Python 3.12 looks non trivial, I get many conflicts:

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   Lib/test/support/__init__.py
	both modified:   Lib/test/test_capi/test_misc.py
	both modified:   Modules/Setup.stdlib.in
	both modified:   Modules/_testcapi/parts.h
	both modified:   Modules/_testcapimodule.c
	both modified:   Modules/_testlimitedcapi/heaptype_relative.c
	both modified:   Modules/_testlimitedcapi/vectorcall_limited.c
	both modified:   PCbuild/pcbuild.proj
	both modified:   PCbuild/pcbuild.sln
	both modified:   PCbuild/readme.txt
	both modified:   Tools/c-analyzer/c_parser/preprocessor/gcc.py
	both modified:   Tools/msi/test/test_files.wxs
	both modified:   configure
	both modified:   configure.ac

The split of Modules/_testinternalcapi.c was not backported. Maybe we should not backport these changes to 3.11 and 3.12.

encukou reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

adorilson pushed a commit to adorilson/cpython that referenced this pull request Mar 25, 2024
@vstinner @erlend-aasland @adorilson
pythongh-116417: Add _testlimitedcapi C extension (python#116419)
79af108
Add a new C extension "_testlimitedcapi" which is only built with the
limited C API.

Move heaptype_relative.c and vectorcall_limited.c from
Modules/_testcapi/ to Modules/_testlimitedcapi/.

* configure: add _testlimitedcapi test extension.
* Update generate_stdlib_module_names.py.
* Update make check-c-globals.

Co-authored-by: Erlend E. Aasland <[email protected]>
diegorusso pushed a commit to diegorusso/cpython that referenced this pull request Apr 17, 2024
@vstinner @erlend-aasland @diegorusso
pythongh-116417: Add _testlimitedcapi C extension (python#116419)
98642ca
Add a new C extension "_testlimitedcapi" which is only built with the
limited C API.

Move heaptype_relative.c and vectorcall_limited.c from
Modules/_testcapi/ to Modules/_testlimitedcapi/.

* configure: add _testlimitedcapi test extension.
* Update generate_stdlib_module_names.py.
* Update make check-c-globals.

Co-authored-by: Erlend E. Aasland <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@colesbury colesbury colesbury approved these changes
@sobolevn sobolevn sobolevn approved these changes
@corona10 corona10 corona10 approved these changes
@erlend-aasland erlend-aasland erlend-aasland approved these changes
@markshannon markshannon Awaiting requested review from markshannon markshannon is a code owner
@gvanrossum gvanrossum Awaiting requested review from gvanrossum
@ericsnowcurrently ericsnowcurrently Awaiting requested review from ericsnowcurrently ericsnowcurrently is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@vstinner @zooba @erlend-aasland @colesbury @sobolevn @corona10
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.