Skip to content

Include subclass instances in get_all searches - #560

Closed
xiehuanyi wants to merge 1 commit into
mahmoud:masterfrom
xiehuanyi:fix/find-subtype-gc-instances
Closed

xiehuanyi wants to merge 1 commit into
mahmoud:masterfrom
xiehuanyi:fix/find-subtype-gc-instances

Conversation

@xiehuanyi

Copy link
Copy Markdown

The change

get_all(Base) uses only objects that directly reference Base, so it misses instances of subclasses even with include_subtypes=True (the default). Search GC-tracked objects when subtypes are requested. Retain the direct-reference optimization for exact-type searches and document the performance distinction.

Validation: the base/child/grandchild regression fails on master and passes after the fix; full suite passes with 679 tests and 12 subtests.

The backstory

Earlier contribution from this account: #555. Found while checking that the documented subtype option returns instances across an ordinary three-level class hierarchy. No separate issue was filed.

AI assistance

  • Harness/tooling: Codex
  • Model(s): GPT-6
  • Original prompt(s): “再改30个10分钟之内可以验证,改正然后提交的issue,提交pr哈。可以多叫几个subagent帮你搞” (Find and fix another 30 issues that can be verified within 10 minutes, and submit PRs; subagents may help.)

Copilot AI balanced review requested due to automatic review settings October 7, 2026 16:44

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Saadia751 Saadia751 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I checked a three-generation class hierarchy with live instances of each class. The default search includes the base, child and grandchild; include_subtypes=False returns only the exact base type. An instance passed instead of a type still raises TypeError.

Checked 5775a037770b with standalone Python 3.12.14 checks (3 passing assertions). I haven't run the full upstream suite.

mahmoud added a commit that referenced this pull request Oct 25, 2026
…ate, support metaclasses, fix suppressed raise (#560, #559, #505, #584)
@mahmoud

mahmoud commented Oct 25, 2026

Copy link
Copy Markdown
Owner

Folded into #609 (see the PR description for credit). Thanks for the report and the repro.

@mahmoud mahmoud closed this Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants