Skip to content

test :- Add more PyType C API tests - #158669

Closed
Amankumar-10012004 wants to merge 1 commit into
python:mainfrom
Amankumar-10012004:add-pytype-tests
Closed

Amankumar-10012004 wants to merge 1 commit into
python:mainfrom
Amankumar-10012004:add-pytype-tests

Conversation

@Amankumar-10012004

Copy link
Copy Markdown

Summary

This PR adds missing tests for several PyType C‑API functions that were identified in issue #155503. The new tests verify the behavior of:

  • PyType_GenericAlloc
  • PyType_SUPPORTS_WEAKREFS

All added tests pass on Windows and Linux using the CPython test suite.

Motivation

The original issue highlighted that the following functions were not exercised by the existing test suite:

  • PyType_ClearCache
  • PyType_GetFlags
  • PyType_IsSubtype
  • PyType_Ready
  • PyType_GenericAlloc
  • PyType_SUPPORTS_WEAKREFS

Four of these were already covered by previous patches. This PR completes the coverage by adding tests for the remaining two functions, ensuring that future changes to these APIs are caught by the test harness.

Changes

File Change
Modules/_testcapi/type.c Added type_supports_weakrefs wrapper and registration in test_methods[].
Modules/_testlimitedcapi/type.c Added type_genericalloc wrapper and registration in test_methods[].
Lib/test/test_capi/test_type.py Added test_type_genericalloc and test_type_supports_weakrefs methods to the TypeTests class.

Testing

  1. Build CPython from the repository:

    cd PCbuild
    .\build.bat -c Release -p x64

@python-cla-bot

python-cla-bot Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app

bedevere-app Bot commented Oct 3, 2026

Copy link
Copy Markdown

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

Add tests on functions:

* PyType_GenericAlloc()
* PyType_SUPPORTS_WEAKREFS()
@bedevere-app

bedevere-app Bot commented Oct 3, 2026

Copy link
Copy Markdown

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@StanFromIreland

Copy link
Copy Markdown
Member

Since Victor has noted he is working on this, I'm sorry but I'm going to close.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants