Skip to content

Accept dict subclasses as warning module globals - #9062

Draft
youknowdot wants to merge 1 commit into
RustPython:mainfrom
youknowdot:fix-warning-globals-dict-subclasses
Draft

youknowdot wants to merge 1 commit into
RustPython:mainfrom
youknowdot:fix-warning-globals-dict-subclasses

Conversation

@youknowdot

@youknowdot youknowdot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Current revision

Targets main after #8950, with one logical commit: f9e7dd2f13900012883b8f3a2c583fcaf60f84cf (parent 06007c81fa99e813cbf4583dab326764ba0ef017). The consolidated commit has exactly the same source tree as the prior reviewed head; original author attribution and assistance trailers are retained. No files under Lib/ are changed.

Normal hooks, whitespace checks, and independent tree/history review passed. The temporary [skip ci] marker is removed and normal CI is enabled for this final head. No new local build or runtime test is claimed. Validation recorded below belongs to earlier revisions unless explicitly stated otherwise.

Summary

Extract Python 3.14-compatible dict-subclass support for warn_explicit(module_globals=...) from #8954.

Accept actual dict subclasses, while retaining the current diagnostics for other objects. Read __name__ from stored dictionary data rather than invoking subclass __getitem__ or __missing__. The loader helper still intentionally calls overridable .get for __loader__ and __spec__.

The second change is a necessary correction to the mega implementation: widening the gate alone would expose the wrong lookup behavior. No frozendict dependency, 3.15 error wording, category changes, or warning-state redesign is included.

Reference sources: CPython 3.14.7 warning gate and source lookup, loader blessing helper.

Provenance and overlap

Validation

  • Independent source review and normal commit hooks passed.

  • Native baseline rejects the new dict-subclass regression; the candidate passes.

  • Exact CPython 3.14.7 and native RustPython pass the complete updated warnings snippet. The existing initial warning output is unchanged.

  • Twelve unchanged canonical cases pass: CFilterTests.test_module_globals and all eleven CWarnTests.test_gh86298_* loader cases.

  • The appended regression covers loader access order and present/absent stored names with raising item/missing overrides, using an in-memory loader.

  • Four snippet pytest entries passed (warnings and warning-keywords, both interpreters).

  • VM and CAPI Clippy with -D warnings passed.
    The full workspace suite was not run locally; no existing assertions or markers were weakened.

@coderabbitai

coderabbitai Bot commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

if vm.is_none(&mg) {
None
} else if !mg.class().is(vm.ctx.types.dict_type) {
} else if mg.downcast_ref::<PyDict>().is_none() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this will be affected by frozendict. let's keep it later to 3.15

@youknowdot
youknowdot force-pushed the fix-warning-globals-dict-subclasses branch 2 times, most recently from 9f97fc3 to 68d40a5 Compare October 11, 2026 03:21
@youknowone
youknowone changed the base branch from main to stack/python-3.15-8950 October 11, 2026 03:25
@youknowdot
youknowdot force-pushed the fix-warning-globals-dict-subclasses branch from 68d40a5 to 2820874 Compare October 11, 2026 04:07
@youknowone
youknowone changed the base branch from stack/python-3.15-8950 to main October 11, 2026 04:08
@youknowdot
youknowdot force-pushed the fix-warning-globals-dict-subclasses branch from 2820874 to f9e7dd2 Compare October 11, 2026 04:14
@github-actions

Copy link
Copy Markdown
Contributor

📦 Library Dependencies

The following Lib/ modules were modified. Here are their dependencies:

[ ] test: cpython/Lib/test/test_mmap.py (TODO: 19)

dependencies:

dependent tests: (2 tests)

  • mmap: test_os
    • multiprocessing.shared_memory: test_genericalias

Legend:

  • [+] path exists in CPython
  • [x] up-to-date, [ ] outdated

Preserve overridable loader lookup while reading module names from stored dictionary data.

Assisted-by: OpenAI Codex:model identifier unavailable
@youknowdot
youknowdot force-pushed the fix-warning-globals-dict-subclasses branch from f9e7dd2 to a9dcb1b Compare October 12, 2026 13:49
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.

2 participants