问题
Edit : adding "import io" in iomenu.py fixed the problem indeed. Thanks a lot Terry!
Original: Like the title said : I'm using IDLE (Windows) to write scripts in python, but it won't save (ctrl+s, manual save, or the save at exit). It doesn't freeze or crash, it just doesn't save (I can tell by the * before the name of the file on the windows title). After some tries I realized that it happens only when I'm using letters with diacritics in the text (I'm French so it will be éèêàç...). As soon as I change the letters, I can save again, and therefore run the script. Notepad or the python shell still work fine.
Things that don't work :
- putting any coding in
# -*- coding: UTF-8 -*-
- reinstalling python (done twice)
- restarting
I started coding only ten days ago so I'm still a newb but I guess this has something to do with encoding? It might be related to the new 3.8.4 update as it worked fine until today. I'm working on Windows 10 64 bit.
Thanks!
回答1:
Either a) add import io
to the top of <pythondir>/idlelib/iomenu.py
, or b) get 3.8.5, released today with hot fixes to multiple problems in 3.8.4, including this one. Same answer applies to 3.9.0b4 versus 3.9.0b5, also released today.
EDIT: In 3.8.5 and 3.9.0b5 there remains another issue with respect to save failing and line endings when editing files created outside of IDLE. iomenu.py, line 251, is currently
if self.eol_convention != "\n":
Change it to
if isinstance(self.eol_convention, str) and self.eol_convention != "\n":
EDIT 2: 3.8.6, and 3.9.0, both recently released, fix both issues.
来源:https://stackoverflow.com/questions/63000314/idle-3-8-4-and-3-9-0b4-wont-save-files-with-non-ascii-characters