Skip to content

default filename does not strip invalid characters on windows #9056

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

Open
1kastner opened this issue Aug 18, 2017 · 9 comments
Open

default filename does not strip invalid characters on windows #9056

1kastner opened this issue Aug 18, 2017 · 9 comments
Labels
OS: Microsoft status: has patch patch suggested, PR still needed

Comments

@1kastner
Copy link

Bug report

Clicking of "save" keeps colons in window title.

Bug summary

Code for reproduction

fig = plt.figure()
fig.canvas.set_window_title("2016-06-01T13:00 start")
plt.show()

When you then press, the suggested file name is 2016-06-01t13:00_start.png. I would prefer 2016-06-01t13-00_start.png or a similar string replacement which is acceptable by the operating system.

Matplotlib version

  • Operating System: Windows 10
  • Matplotlib Version: 2.0.0
  • Python Version: 3.6.0

Installed via conda.

@1kastner 1kastner changed the title fig.canvas.set_window_title(title) fig.canvas.set_window_title(title) and save button do not work in harmony Aug 18, 2017
@tacaswell tacaswell added this to the 2.2 (next next feature release) milestone Aug 18, 2017
@tacaswell
Copy link
Member

The default filename is computed in FigureCanvasBase.get_default_filename. We already relpace ' ' with '_' because spaces in filename is just a bad idea, but do not do any other validation / cleanup

The exact work

  • add a conditional block to on windows do some extra clean up (check sys.platform)
  • add a windows-only test of this (using skipif on the test)

@tacaswell tacaswell changed the title fig.canvas.set_window_title(title) and save button do not work in harmony default filename does not strip invalid characters on windows Aug 18, 2017
@tacaswell
Copy link
Member

@1kastner Thanks for reporting this, the fix is pretty strait forward, but probably should be done by someone with a windows machine. Want to take a crack at it?

@1kastner
Copy link
Author

I will have a look!

@anntzer
Copy link
Contributor

anntzer commented Aug 18, 2017

just made a PR :p

@1kastner
Copy link
Author

Wow, that was quick!

@tacaswell tacaswell added the Good first issue Open a pull request against these issues if there are no active ones! label Oct 16, 2017
@jat255
Copy link
Contributor

jat255 commented Mar 27, 2018

I'll add that if the window title somehow ends up with a \n character in it, clicking the "Save figure" button will fail silently (at least in the Windows qt4 backend - see hyperspy/hyperspy#1880 and hyperspy/hyperspy#1885). IMO this needs a fix; I'm not sure why the corresponding PR #9057 was closed.

@francisco-dlp
Copy link

Is there any agreement on how to fix this?

@tacaswell tacaswell modified the milestones: needs sorting, v3.0 Mar 28, 2018
@tacaswell tacaswell modified the milestones: v3.0, v3.1 Aug 11, 2018
@tacaswell tacaswell modified the milestones: v3.1.0, v3.2.0 Mar 18, 2019
@tacaswell tacaswell modified the milestones: v3.2.0, needs sorting Sep 10, 2019
@anntzer anntzer removed the Good first issue Open a pull request against these issues if there are no active ones! label Sep 16, 2019
Copy link

This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

@github-actions github-actions bot added the status: inactive Marked by the “Stale” Github Action label May 22, 2024
@tacaswell tacaswell added the status: has patch patch suggested, PR still needed label May 22, 2024
@tacaswell
Copy link
Member

The patch in #9057 should probably be revived.

@github-actions github-actions bot removed the status: inactive Marked by the “Stale” Github Action label May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OS: Microsoft status: has patch patch suggested, PR still needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants