GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Remove `_dis` module by ShaharNaveh · Pull Request #6690 · RustPython/RustPython Conversation
|
📝 WalkthroughWalkthroughThis PR systematically renames CodeFlags enum variants to standardize naming conventions, removing prefixes like Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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. Comment |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Code has been automatically formatted The code in this PR has been formatted using git pull origin try-update-dis |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
4ceacf1 to
ec25472
Compare
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
crates/vm/src/builtins/function.rs (3)
127-155: LGTM! Proper validation for excess positional arguments.The rename from
HAS_VARARGStoVARARGSaligns with standard Python CodeFlags naming conventions. The new else branch (lines 131-155) correctly enforces Python semantics by rejecting excess positional arguments when the function doesn't accept*args. The error message properly indicates the valid range of positional arguments and handles grammatical number agreement correctly.
158-164: LGTM! Flag rename aligns with standard conventions.The rename from
HAS_VARKEYWORDStoVARKEYWORDSis consistent with the broader refactoring to align with standard Python CodeFlags naming.
417-423: LGTM! Flag rename aligns with standard conventions.The rename from
NEW_LOCALStoNEWLOCALSis consistent with the standard Python CodeFlags naming, removing the underscore prefix.
In @crates/vm/src/builtins/function.rs:
- Around line 439-440: No code changes required; the rename from
IS_GENERATOR/IS_COROUTINE to bytecode::CodeFlags::GENERATOR and ::COROUTINE and
the match logic that constructs generator/coroutine/async generator objects are
correct as-is, so leave the uses of
code.flags.contains(bytecode::CodeFlags::GENERATOR) and
code.flags.contains(bytecode::CodeFlags::COROUTINE) and the surrounding
match/creation logic unchanged.
crates/codegen/src/compile.rs (1)
6369-6383: Minor: avoid shadowingflagswhen addingCOROUTINEin comprehensions.This is correct as-is, but the double
let flags = ...; let flags = if ...is a small readability hit.Proposed refactor
- let flags = bytecode::CodeFlags::NEWLOCALS | bytecode::CodeFlags::OPTIMIZED; - let flags = if is_async { - flags | bytecode::CodeFlags::COROUTINE - } else { - flags - }; + let mut flags = bytecode::CodeFlags::NEWLOCALS | bytecode::CodeFlags::OPTIMIZED; + if is_async { + flags |= bytecode::CodeFlags::COROUTINE; + }
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Lib/dis.py is excluded by !Lib/**Lib/test/test_dis.py is excluded by !Lib/**Lib/test/test_inspect/test_inspect.py is excluded by !Lib/**Lib/test/test_unittest/testmock/testasync.py is excluded by !Lib/**crates/codegen/src/compile.rscrates/codegen/src/ir.rscrates/compiler-core/src/bytecode.rscrates/stdlib/src/dis.rscrates/stdlib/src/lib.rscrates/vm/src/builtins/function.rscrates/vm/src/builtins/function/jit.rscrates/vm/src/frame.rs📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.rs: Follow the default rustfmt code style by runningcargo fmtto format Rust code
Always run clippy to lint code (cargo clippy) before completing tasks and fix any warnings or lints introduced by changes
Follow Rust best practices for error handling and memory management
Use the macro system (pyclass,pymodule,pyfunction, etc.) when implementing Python functionality in Rust
Files:
crates/codegen/src/ir.rscrates/vm/src/builtins/function/jit.rscrates/vm/src/builtins/function.rscrates/vm/src/frame.rscrates/codegen/src/compile.rscrates/compiler-core/src/bytecode.rscrates/vm/src/frame.rs (2)
locals(158-194)locals(2402-2406)
crates/compiler-core/src/bytecode.rs (2)
374-379: LGTM! Clean flag naming standardization.The renamed constants remove unnecessary prefixes, improving readability. Bit positions remain unchanged, ensuring binary compatibility.
1554-1561: Flag usage correctly updated.The method properly uses the renamed
VARARGSandVARKEYWORDSflags to determine argument structure.crates/vm/src/builtins/function/jit.rs (1)
73-81: Flag check correctly updated for JIT argument validation.The updated flag names maintain the same logic: preventing JIT compilation of functions with variable argument counts.
crates/codegen/src/ir.rs (1)
335-336: Correct flag usage in cell2arg calculation.The total argument count properly includes variadic arguments using the renamed flags.
crates/vm/src/frame.rs (3)
189-191: Flag usage correctly updated.The
OPTIMIZEDflag check properly controls freevar mapping in the locals collection logic.
1003-1009: Coroutine context check correctly updated.The
COROUTINEflag properly enforces that coroutines can only be yielded from within coroutine contexts.
1674-1678: Async generator wrapping logic correctly updated.The
COROUTINEflag determines whether to wrap yielded values for async generators. The logic is correct: wrap only whenarg == 0(direct yield) and theCOROUTINEflag is set.crates/codegen/src/compile.rs (9)
377-404: Verify moduleCodeFlagsinitialization matches intendedco_flags(NEWLOCALS vs empty).
Compiler::newinitializes the moduleir::CodeInfo.flagsasCodeFlags::NEWLOCALS(Line 380), whileenter_scopeusesCodeFlags::empty()forCompilerScope::Module(Line 749). If standarddis.pycompatibility depends on exactco_flags, please confirm the module-level choice is intentional (and consistent with howCodeObject.co_flagsis computed).
747-769: Scope default flags update looks consistent with the renamedCodeFlags.Function-like scopes default to
NEWLOCALS | OPTIMIZED, while module/class remainempty(). This aligns with usingCOROUTINE/GENERATORas additional markers elsewhere.
1298-1323:make_qualname: usingOPTIMIZEDfor “function parent” detection is reasonable—ensure no non-function scopes set it.
is_function_parentnow keys offparent.flags.contains(CodeFlags::OPTIMIZED)(Line 1301) plus name guards. Please double-check there aren’t any non-function scopes that setOPTIMIZEDwhile having a non-"<...>"name, or they’ll get.<locals>.qualnames unexpectedly.
1911-1919: Async return check updated correctly toCodeFlags::GENERATOR.
2064-2090: Function entry flags + varargs/kwargs flags updated correctly.
push_output(NEWLOCALS | OPTIMIZED, ...)plusVARARGS/VARKEYWORDSmutations look consistent with the rename and prior behavior.
3103-3120: Coroutine flag set viaflags.set(COROUTINE, is_async)is clean and clear.
3233-3241: Type-params scope flags updated consistently.Also applies to: 3664-3672
7042-7044: Generator marking updated correctly toCodeFlags::GENERATOR.
1-20: Please run formatting/lints/tests for the flag rename sweep.Per repo guidelines for
**/*.rs, make surecargo fmtandcargo clippyare clean, and that dis-/opcode-metadata-related tests/snapshots still match expectations after theCodeFlagsrename and_disremoval.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| let is_gen = code.flags.contains(bytecode::CodeFlags::GENERATOR); | ||
| let is_coro = code.flags.contains(bytecode::CodeFlags::COROUTINE); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion | 🟠 Major
LGTM! Flag renames align with standard conventions.
The renames from IS_GENERATOR to GENERATOR and IS_COROUTINE to COROUTINE are consistent with standard Python CodeFlags naming, removing the IS_ prefix. The match logic correctly handles all combinations for creating the appropriate generator/coroutine/async generator objects.
In @crates/vm/src/builtins/function.rs around lines 439 - 440, No code changes
required; the rename from IS_GENERATOR/IS_COROUTINE to
bytecode::CodeFlags::GENERATOR and ::COROUTINE and the match logic that
constructs generator/coroutine/async generator objects are correct as-is, so
leave the uses of code.flags.contains(bytecode::CodeFlags::GENERATOR) and
code.flags.contains(bytecode::CodeFlags::COROUTINE) and the surrounding
match/creation logic unchanged.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Awesome! This moment came sooner than I expected!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.