Always os.chdir("/") when reloading#9224
Merged
Merged
Conversation
|
I'm sure I wrote a patch for this already. |
Author
|
Oh I was remembering the old behavior hadn't retested in a good bit.. Still the cwd when only using REPL isn't reset. Adafruit CircuitPython 9.1.0-beta.1-17-g9ab8831d38 on 2024-05-02; DFRobot FireBeetle 2 ESP32-S3 with ESP32S3
>>> import os;os.getcwd();os.chdir("/Beryllium");os.getcwd()
'/'
'/Beryllium'
>>>
soft reboot
Auto-reload is off.
Running in safe mode! Not running saved code.
You are in safe mode because:
You pressed the BOOT button at start up
Press reset to exit safe mode.
Press any key to enter the REPL. Use CTRL-D to reload.
Adafruit CircuitPython 9.1.0-beta.1-17-g9ab8831d38 on 2024-05-02; DFRobot FireBeetle 2 ESP32-S3 with ESP32S3
>>> import os;os.getcwd();os.chdir("/Beryllium");os.getcwd()
'/Beryllium'
'/Beryllium'
>>>Meanwhile with my patch: Adafruit CircuitPython 9.1.0-beta.1-18-g77a4e429fd on 2024-05-04; DFRobot FireBeetle 2 ESP32-S3 with ESP32S3
>>> import os;os.getcwd();os.chdir("/Beryllium");os.getcwd()
'/'
'/Beryllium'
>>>
soft reboot
Auto-reload is off.
Running in safe mode! Not running saved code.
You are in safe mode because:
The `microcontroller` module was used to boot into safe mode.
Press reset to exit safe mode.
Press any key to enter the REPL. Use CTRL-D to reload.
Adafruit CircuitPython 9.1.0-beta.1-18-g77a4e429fd on 2024-05-04; DFRobot FireBeetle 2 ESP32-S3 with ESP32S3
>>> import os;os.getcwd();os.chdir("/Beryllium");os.getcwd()
'/'
'/Beryllium' |
tannewt
approved these changes
May 13, 2024
Member
tannewt
left a comment
There was a problem hiding this comment.
Ok, this makes sense. Thanks!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With this PR, after every reload the current working directory will always change back to root.With this, if the code exited while in a different directory (or autoreload was run, interrupting the code), reloading will run the code again.
Up until now, if the code had changed the working directory, CircuitPython would try to find acode.pyin the working directory in the next reload.This is exceptionally problematic for when autoreload is enabled, since the code may be interrupted without being given the chance to change back to root.
This would mean, the code would stop, and CircuitPython would find no
code.pyto run.This PR just make CircuitPython always reset current working directory to root upon reload.