Skip to content

Add __main__.__cached__ - #6276

Merged
youknowone merged 2 commits into
RustPython:mainfrom
youknowone:main-cached
Nov 15, 2025
Merged

youknowone merged 2 commits into
RustPython:mainfrom
youknowone:main-cached

Conversation

@youknowone

Copy link
Copy Markdown
Member

fix #6274

I also re-organize vm.run_script inner functions to prepare #6273

@coderabbitai

coderabbitai Bot commented Nov 15, 2025 •

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@youknowone has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 14 minutes and 46 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 8968aea and b8f3106.

📒 Files selected for processing (4)
  • crates/vm/src/vm/compile.rs (3 hunks)
  • crates/vm/src/vm/context.rs (2 hunks)
  • extra_tests/snippets/builtin___main__.py (1 hunks)
  • src/lib.rs (2 hunks)
✨ Finishing touches
  • 📝 Generate docstrings
🧪 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.

}

fn run_any_file(&self, scope: Scope, path: &str) -> PyResult<()> {
let path = if path.is_empty() { "???" } else { path };

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Are those ??? is something that CPython is also doing?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, _PyRun_AnyFileObject does

if pyc {
todo!("running pyc is not implemented yet");
} else {
if path != "<stdin>" {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

How feasible doing something like:

enum InputFile {
    StdIn,
    Path(&str),
    Pyc(&str)
}

be?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks, that sounds like a good suggestion.
Currently, I am not sure how stdin can come here in RustPython. I ported a part of CLI run, but not entirely.
I will leave a comment about this to make sure it can be checked later.

@youknowone
youknowone marked this pull request as ready for review November 15, 2025 13:25
@youknowone
youknowone merged commit 6991a80 into RustPython:main Nov 15, 2025
13 checks passed
@youknowone
youknowone deleted the main-cached branch November 15, 2025 14:09
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.

__main__ module doesn't set __cached__

2 participants