Skip to content

Accept dict subclasses as warning module globals - #9062

Merged
youknowone merged 1 commit into
RustPython:mainfrom
youknowdot:fix-warning-globals-dict-subclasses
Oct 13, 2026
Merged

youknowone merged 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

Review in Change Stack →

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Configuration used: Repository: RustPython/RustPython/.coderabbit.yml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2e483995-b728-4f95-9258-c0bf8d4fbeef
📥 Commits

Reviewing files that changed from the base of the PR and between 85d5956 and a9dcb1b.

📒 Files selected for processing (3)
  • crates/vm/src/stdlib/_warnings.rs
  • crates/vm/src/warn.rs
  • extra_tests/snippets/stdlib_warnings.py
 __________________________________________________
< Deploying the charm offensive against your bugs. >
 --------------------------------------------------
  \
   \   (\__/)
       (•ㅅ•)
       /   づ
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • 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
@youknowone
youknowone marked this pull request as ready for review October 13, 2026 01:47
@youknowone
youknowone merged commit 140761e into RustPython:main Oct 13, 2026
20 checks passed
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T01:53:43.728610Z a9dcb1b Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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