GeezerVison is showing github.com — Align GetAwaitable to Python 3.14.2 by youknowone · Pull Request #6895 · RustPython/RustPython
Conversation
youknowone
commented
Jan 29, 2026
•
edited by coderabbitai
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Summary by CodeRabbit
-
New Features
- More explicit awaitable resolution and validation for await/yield operations, improving handling of objects that provide awaitables.
-
Bug Fixes
- Clearer, more specific error messages when non-awaitable objects are used in async contexts (including async with).
- Prevents awaiting the same coroutine more than once, reducing runtime surprises and improving async-with robustness.
✏️ Tip: You can customize this high-level summary in your review settings.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
coderabbitai
Bot
commented
Jan 29, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
📝 Walkthrough
Walkthrough
GetAwaitable was changed from a unit opcode to carry an explicit argument; codegen emits GetAwaitable { arg: N }, VM/frame execution resolves awaitables via a new get_awaitable_iter() helper and uses the arg to contextualize error handling and awaitable validation.
Changes
| Cohort / File(s) |
Summary |
Instruction Definition crates/compiler-core/src/bytecode/instruction.rs |
Changed Instruction::GetAwaitable from a unit variant to GetAwaitable { arg: Arg<u32> }; updated matching, stack effect, and formatting to include the arg. |
Code Generation crates/codegen/src/compile.rs |
Updated emission sites to emit `GetAwaitable { arg: <0 |
Awaitable Resolution Utility crates/vm/src/coroutine.rs |
Added pub fn get_awaitable_iter(obj: PyObjectRef, vm: &VirtualMachine) -> PyResult to obtain/validate an awaitable iterator (checks coroutine, calls __await__, ensures iterator). |
Frame Execution crates/vm/src/frame.rs |
Refactored execution of GetAwaitable { arg } to pop the value, call get_awaitable_iter(), validate the returned iterator (and coroutine reuse), and produce arg-specific TypeError messages for async-with contexts. |
Sequence Diagram(s)
sequenceDiagram
participant Codegen as Codegen/Compile
participant Frame as VM Frame Executor
participant AwaitUtil as get_awaitable_iter()
participant Object as Python Object
Codegen->>Frame: Emit GetAwaitable { arg: context }
Frame->>Object: Pop awaitable-candidate
Frame->>AwaitUtil: get_awaitable_iter(obj, vm)
AwaitUtil->>Object: Is coroutine? / call __await__()
alt Is coroutine
Object-->>AwaitUtil: return coroutine (iterator-like)
else __await__ exists
Object-->>AwaitUtil: return iterator
AwaitUtil->>AwaitUtil: validate iterator (not coroutine reuse)
end
AwaitUtil-->>Frame: awaitable iterator or error
Frame->>Frame: push iterator / raise contextual TypeError
Loading
Estimated code review effort
🎯 4 (Complex) | ⏱️ ~45 minutes
Possibly related PRs
Suggested reviewers
Poem
🐰 Hop, hop—an arg now on the trail,
I fetch the awaitable, swift and hale.
From compile to frame the pathways hum,
Iterators dance; the async work is done. ✨
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
| Check name |
Status |
Explanation |
| Description Check |
✅ Passed |
Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check |
✅ Passed |
The title 'Align GetAwaitable to Python 3.14.2' directly and clearly describes the main change: updating the GetAwaitable instruction to align with Python 3.14.2, which is the primary objective evident from the file modifications. |
| Docstring Coverage |
✅ Passed |
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing touches
🧪 Generate unit tests (beta)
- Create PR with unit tests
- Post copyable unit tests in a comment
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 and usage tips.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
📦 Library Dependencies
The following Lib/ modules were modified. Here are their dependencies:
[ ] lib: cpython/Lib/fractions.py
[ ] test: cpython/Lib/test/test_fractions.py (TODO: 1)
dependencies:
- fractions (native: math, sys)
- functools, numbers, operator, re
dependent tests: (13 tests)
- fractions: test_buffer test_builtin test_compare test_float test_fractions test_itertools test_math test_numeric_tower test_operator test_os test_random test_statistics
[ ] lib: cpython/Lib/asyncio
[ ] test: cpython/Lib/test/test_asyncio (TODO: 17)
dependencies:
- asyncio (native: _overlapped, _pyrepl.console, _remote_debugging, _winapi, asyncio.tools, collections.abc, concurrent.futures, errno, itertools, math, msvcrt, sys, time)
- ast (native: _ast, sys)
- collections (native: _weakref, itertools, sys)
- dataclasses (native: itertools, sys)
- enum (native: builtins, sys)
- io (native: _io, _thread, errno, sys)
- logging (native: atexit, errno, logging.handlers, sys, time)
- os (native: os.path, sys)
- site (native: _io, builtins, errno, sys)
- socket (native: _socket, sys)
- subprocess (native: builtins, errno, sys, time)
- tempfile (native: _thread, errno, sys)
- traceback (native: collections.abc, itertools, sys)
- weakref (native: _weakref, itertools, sys)
- _colorize, argparse, contextlib, contextvars, functools, heapq, inspect, linecache, reprlib, selectors, signal, stat, struct, threading, types, warnings
dependent tests: (8 tests)
- asyncio: test_asyncio test_builtin test_contextlib_async test_inspect test_logging test_os test_sys_settrace test_unittest
Legend:
[+] path exists in CPython
[x] up-to-date, [ ] outdated
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|