Skip to content

Fix disabled stream identity and conditional annotation operand checks - #8960

Merged
youknowone merged 1 commit into
RustPython:mainfrom
youknowdot:python314-runtime-guards
Oct 5, 2026
Merged

youknowone merged 1 commit into
RustPython:mainfrom
youknowdot:python314-runtime-guards

Conversation

@youknowdot

Copy link
Copy Markdown
Contributor

Two existing Python 3.14 paths violate runtime object contracts: disabling standard I/O creates fresh None objects, and conditional-annotation tracking assumes a user-rebindable global is an exact set.

Return the context's None singleton for all six disabled stream attributes, and validate the set operand before adding an annotation name. Include an embedding regression that actually runs without the stdio feature, and the unchanged canonical annotation regression from CPython's 3.14 maintenance backport.

Extracted from #8954 onto main f39b054b9c8cbbf884f53123eef028131789990c, retaining the unchanged Python 3.14 target. The mega PR retains these fixes until they are merged independently. No marshal or Python 3.15 behavior is included.

Fresh standalone validation on 8aeae47903cd431fcb31237597ae216c80512f65:

  • Rust workspace: 1,345 passed /18 ignored; separate C-API: 116 passed /4 ignored
  • Explicit no-stdio feature build: no_stdio_streams_are_none_singleton executed and passed (1 test); default builds compile it out
  • Both Clippy gates pass without warnings, release build passes, and runtime identity confirms Python 3.14 at this head
  • Full test_type_annotations: 49 run /1 skipped; test_setcomps: 2 run; test_site: 43 run /6 skipped. All complete successfully
  • Existing syntax_annotations_locals.py and builtin_set.py pass
  • Normal configured commit hooks pass; no existing assertions or expected-failure markers changed

The official annotation backport commit c21e7c45a9770fba9ea3b8d5abb52c19274a08ef is after CPython 3.14.7. The released 3.14.7 reference still crashes on that exact canonical regression; this is a maintenance fix, not a claim that the vulnerable released tag passes. The corrected native regression passes; the reference crash was not repeated.

AI assistance: prepared, reviewed and tested with Codex at the user's direction. Exact model metadata is unavailable; the commit records Assisted-by: Codex:model-version-unavailable.

Return the context's canonical None singleton when standard streams are
disabled. Check the exact set type before accessing user-rebindable
conditional-annotation tracking objects.

Both fixes apply to the unchanged Python 3.14 target. Include the no-stdio
embedding regression and the unchanged canonical regression from CPython's
3.14 maintenance backport c21e7c45, after the vulnerable 3.14.7 tag.

Extracted from the larger 3.15 migration; no marshal or version changes.

Assisted-by: Codex:model-version-unavailable
@coderabbitai

coderabbitai Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

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: ca0adea2-0369-40aa-a523-f2fb3af3da8a
📥 Commits

Reviewing files that changed from the base of the PR and between 7536730 and 8aeae47.

⛔ Files ignored due to path filters (1)
  • Lib/test/test_type_annotations.py is excluded by !Lib/**
📒 Files selected for processing (2)
  • crates/vm/src/frame.rs
  • crates/vm/src/vm/mod.rs
 _________________________________
< My bunny whiskers are tingling. >
 ---------------------------------
  \
   \   (\__/)
       (•ㅅ•)
       /   づ
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · 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.

@github-actions

github-actions Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

📦 Library Dependencies

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

[x] lib: cpython/Lib/typing.py
[ ] test: cpython/Lib/test/test_typing.py (TODO: 1)
[x] test: cpython/Lib/test/test_type_aliases.py
[ ] test: cpython/Lib/test/test_type_annotations.py
[x] test: cpython/Lib/test/test_type_params.py
[x] test: cpython/Lib/test/test_genericalias.py

dependencies:

  • typing

dependent tests: (19 tests)

  • typing: test_annotationlib test_builtin test_copy test_enum test_fractions test_funcattrs test_functools test_genericalias test_grammar test_inspect test_isinstance test_patma test_peg_generator test_pydoc test_pyrepl test_type_aliases test_type_params test_types test_typing

Legend:

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


class RegressionTests(unittest.TestCase):
# gh-154902
def test_conditional_annotations_rebound(self):

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.

is this test originated from CPython? otherwise do not directly edit Lib/ files

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes. This is copied verbatim from CPython's official 3.14 maintenance backport c21e7c45, including the accompanying import itertools. The test body, input values, and assertions are unchanged. The only difference is placement within RegressionTests: this PR inserts it before the existing tests, while upstream appended it after test_complex_comprehension_inlining.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@youknowone
youknowone merged commit 6903fed into RustPython:main Oct 5, 2026
30 of 31 checks passed
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