Skip to content

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

Open
@carlosperate

Description

@carlosperate

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:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions