python / python/cpython

Add tests for setting and deleting attributes defined in C

Open
#156,106 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

tests
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

CPython defines 375 attributes with PyMemberDef and PyGetSetDef (excluding the _test* modules), but the test suite never assigns to 187 of them and never deletes 332 of them.

Deletion in particular is almost untested, although it is a separate code path: the setter is called with NULL, and an implementation which does not expect this crashes or leaves the object in a broken state.

Three bugs found this way are gh-156099, gh-156100 and gh-156101; gh-152817 is another one.

The following PR adds writing and deleting tests for each writable attribute.

Linked PRs
  • gh-156107
  • gh-156184
  • gh-156191

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the CPython test coverage for attributes defined with PyMemberDef and PyGetSetDef. Review how writable attributes are currently assigned and deleted, then use the reported gaps and existing tests to cover each writable attribute. Done means assignment and deletion are tested for all writable attributes without crashes or broken objects.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, python
Domain
testing-qa
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.