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

Ensure, if no file extension provided, a .py one is used. #1572

Merged
merged 2 commits into from
Jun 19, 2021

Conversation

ntoll
Copy link
Member

@ntoll ntoll commented May 17, 2021

Fixes #1571.

@@ -420,6 +420,12 @@ def get_save_path(self, folder):
"Python (*.py)",
)
self.previous_folder = os.path.dirname(path)
# Ensure there's a .py extension if none is provided by the user.
# See issue #1571.
name, ext = os.path.splitext(os.path.basename(path))
Copy link
Member

Choose a reason for hiding this comment

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

Just a warning that this does not work with dot files, so something like .gitignore will be renamed to .gitignore.py. We can probably consider this out of scope, but I thought it was worth pointing out.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point. For safety we should probably wrap the code in a conditional like if not name.startswith("."):

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, sounds good 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

OK... fixed and tested in latest commit on this branch. Will merge once the CI turns green. 👍 Thanks for the heads-up @carlosperate

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.

Mu Editor 1.1.0b4 does not add the file extension .py when saving a new file for the first time on Linux
2 participants