Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Cannot import last-used main module on REPL #745

Closed
laurensvalk opened this issue Oct 20, 2022 · 2 comments
Closed

[Bug] Cannot import last-used main module on REPL #745

laurensvalk opened this issue Oct 20, 2022 · 2 comments
Labels
bug Something isn't working software: pybricks-micropython Issues with Pybricks MicroPython firmware (or EV3 runtime)

Comments

@laurensvalk
Copy link
Member

This is somewhat of a minor issue, but while we are looking at the REPL:

Since we started using the __main__ name to search for the entry point (as opposed to using the first or last script), the last-used main script cannot be imported by its original name. It also can't be imported as __main__ because that is now the REPL itself.

The use case isn't entirely far-fetched though. You could think of using the REPL to prepare test conditions, and then try to import your script to see how it behaves.

@laurensvalk laurensvalk added bug Something isn't working software: pybricks-micropython Issues with Pybricks MicroPython firmware (or EV3 runtime) labels Oct 20, 2022
@dlech
Copy link
Member

dlech commented Oct 21, 2022

Note for when we work on this: in pybricksdev, we would need to replace finder.run_script(path) to finder.load_file(path) to get the actual module name instead of __main__. (of course, there is more to it than only this)

@laurensvalk
Copy link
Member Author

I suppose the behavior that we have now is technically correct.

Since you can enter the REPL from a main script with raise KeyboardInterrupt, the use case described here becomes a bit of an edge case anyway.

So I think we can close this.

@laurensvalk laurensvalk closed this as not planned Won't fix, can't repro, duplicate, stale Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working software: pybricks-micropython Issues with Pybricks MicroPython firmware (or EV3 runtime)
Projects
None yet
Development

No branches or pull requests

2 participants