Skip to content

gh-162572: Clear stale class source metadata - #162660

Closed
pqminh27 wants to merge 1 commit into
python:mainfrom
pqminh27:gh-162572-firstlineno
Closed

pqminh27 wants to merge 1 commit into
python:mainfrom
pqminh27:gh-162572-firstlineno

Conversation

@pqminh27

@pqminh27 pqminh27 commented Nov 26, 2026 •

Copy link
Copy Markdown

Fixes #162572.

When a custom metaclass uses the default type attribute setter, assigning __module__ clears stale __firstlineno__ metadata. The implementation preserves metaclass descriptor dispatch, preflights comparisons that may execute user code, removes the exact metadata key only after the module write succeeds, and invalidates type caches repopulated during that write.

Validation:

  • Full GIL debug suite on the current base after the cache-invalidation fix: ./python.exe -m test -j2 (52,595 tests run; no failures; expected platform/resource skips)
  • ./python.exe -m test -j2 test_descr test_capi test_inspect (2,199 tests; all three test files passed)
  • make patchcheck

AI disclosure: AI assistance was used to prepare this PR.

@python-cla-bot

python-cla-bot Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@pqminh27
pqminh27 force-pushed the gh-162572-firstlineno branch from a89c11b to bec6f10 Compare November 26, 2026 06:43
@pqminh27
pqminh27 marked this pull request as ready for review November 26, 2026 06:44
@picnixz picnixz added the AI-guidelines-not-met The contribution does not meet our guidelines for using AI tools and is closed automatically. label Nov 26, 2026
@bedevere-app

bedevere-app Bot commented Nov 26, 2026

Copy link
Copy Markdown

Thank you for your interest in contributing to Python. This is a community-driven project, and we want it to be a welcoming place to learn and collaborate.

Contributors are responsible for reviewing and understanding what they submit, checking its claims, and being able to explain changes in their own words. This helps reviewers focus on the contribution and leaves more time to support other contributors.

We believe this contribution does not meet our guidelines for using AI tools, so we're closing it. If you think we've misunderstood your contribution, please let us know. You're welcome to explain your approach or ask questions about the guidelines.

Please read our guidelines for using AI tools.

@bedevere-app bedevere-app Bot closed this Nov 26, 2026
@picnixz

picnixz commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

There are clearly unrelated changes or wrong decisions made by the AI for this patch. Please avoid submitting patches in sensitive-like areas that you do not well-understand. In addition, many comments were changed without good reasons.

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

Labels

AI-guidelines-not-met The contribution does not meet our guidelines for using AI tools and is closed automatically. awaiting review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Setting __module__ doesn't remove __firstlineno__ when the class has a custom metaclass

2 participants