Skip to content

Raise RuntimeError for a non-type zero-argument super class cell - #9524

Draft
youknowdot wants to merge 1 commit into
RustPython:mainfrom
youknowdot:upgrade/super-classcell-runtime-error-20261101
Draft

youknowdot wants to merge 1 commit into
RustPython:mainfrom
youknowdot:upgrade/super-classcell-runtime-error-20261101

Conversation

@youknowdot

Copy link
Copy Markdown
Contributor

Summary

Change one exception constructor in zero-argument super(): a non-type value in the __class__ closure cell raises RuntimeError, not TypeError. Keep the error text and every other path unchanged. No Lib files or tests are modified.

This matches CPython 3.15's check at pinned commit d220409. It is a small native prerequisite for the ongoing Python 3.15 library upgrade: the upstream race test catches this RuntimeError, but this PR does not import or enable that test file.

Validation

Validated on base cc5191338ca2ae1b2e13b8d2d2de69e86118554f:

  • Normal repository hooks: merge-conflict check, rustfmt, cspell (unrelated hooks had no matching files).
  • cargo check --offline --locked -j1 --target x86_64-unknown-linux-gnu -p rustpython-vm --lib --features threading, with VM defaults enabled.
  • Matching strict Clippy with -- -D warnings.
  • Lean CLI build using --no-default-features --features threading,stdlib,stdio,importlib,host_env,doc,ucd_3_2_0; actual VM opt-level 3 verified.
  • External sequential probe replacing the class cell with 99 and None: exact RuntimeError class and messages, restoration in finally, and normal super() binding afterward.
  • Exactly two unchanged canonical tests passed normally, without skips or expected failures:
    • test.test_super.TestSuper.test_obscure_super_errors
    • test.test_super.TestSuper.test_super_argtype

The runtime used the exact built interpreter and a read-only candidate Lib snapshot with an isolated import path. Input closures stayed unchanged; each phase ended naturally with one process/thread and no descendants.

Limits

No full test_super, free-threading/test_races, workspace, or C-API suite was run. No CPython 3.15 differential execution was performed; the expected behavior is backed by pinned CPython source. The sequential probe establishes the error contract, not free-threading safety.

OpenAI Codex assisted investigation, implementation, independent review, and bounded validation. The commit includes an Assisted-by trailer.

Match CPython's exception class when the __class__ closure cell contains
something other than a type. Preserve the existing diagnostic and all
other super argument handling.

Validated threaded VM check and strict Clippy, a lean CLI build, an
external deterministic int/None class-cell probe with restoration, and
two unchanged canonical super error tests. Full workspace/C-API and
free-threading suites and a CPython 3.15 differential run were not run.

Assisted-by: OpenAI Codex:model version not exposed
@coderabbitai

coderabbitai Bot commented Nov 1, 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

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