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

CircuitPython's code.py ends up in Mu installation folder and crashes Mu #2453

Open
carlosperate opened this issue Jul 28, 2023 · 1 comment

Comments

@carlosperate
Copy link
Member

carlosperate commented Jul 28, 2023

Because Python's standard library pdb module does import code:

❯ echo "this file in the Mu installation folder should not be imported" > code.py

❯ python run.py
Traceback (most recent call last):
  File "/Users/microbit-carlos/workspace/carlos/mu/run.py", line 2, in <module>
    from mu.app import run
  File "/Users/microbit-carlos/workspace/carlos/mu/mu/app.py", line 47, in <module>
    from .logic import Editor, LOG_FILE, LOG_DIR, ENCODING
  File "/Users/microbit-carlos/workspace/carlos/mu/mu/logic.py", line 36, in <module>
    from pyflakes.api import check
  File "/Users/microbit-carlos/workspace/carlos/mu/.venv-qt6/lib/python3.10/site-packages/pyflakes/api.py", line 10, in <module>
    from pyflakes import checker, __version__
  File "/Users/microbit-carlos/workspace/carlos/mu/.venv-qt6/lib/python3.10/site-packages/pyflakes/checker.py", line 11, in <module>
    import doctest
  File "/Users/microbit-carlos/.pyenv/versions/3.10.8/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/doctest.py", line 100, in <module>
    import pdb
  File "/Users/microbit-carlos/.pyenv/versions/3.10.8/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/pdb.py", line 77, in <module>
    import code
  File "/Users/microbit-carlos/workspace/carlos/mu/code.py", line 1
    this file in the Mu installation folder should not be imported
         ^^^^
SyntaxError: invalid syntax

The bug here is that somehow the CircuitPython mode must be saving the code.py file in the Mu's cwd instead of the CIRCUITPY drive.

Crash reports:

These other crash reports are from having the cope.py file in other directories, that are likely added to the path as well, like the "Desktop", "Downloads" or other folders:

@carlosperate carlosperate added this to the 1.2.1 milestone Jul 28, 2023
@carlosperate
Copy link
Member Author

carlosperate commented Jul 28, 2023

It's very interesting that this has only happened with Mu v1.2.0, not a single crash report from earlier versions. So maybe something we accidentally introduced in the last release?

v1.1.1...v1.2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant