-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
IDLE: edit/save files created by Windows Explorer #85545
Comments
bpo-41300 fixed one bug in the patch for bpo-41158. A user reported another on on idle-dev list. Create a file in Windows Explorer. Leave as .txt or rename to .py. Right click and Edit with IDLE 3.8 (.4/.5 or 3.9.0b4 or 5). Edit works, Save (or Run) does not. Open the same file from Command Prompt, change it, and trying to save produces Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Programs\Python38\lib\tkinter\__init__.py", line 1883, in __call__
return self.func(*args)
File "C:\Programs\Python38\lib\idlelib\multicall.py", line 176, in handler
r = l[i](event)
File "C:\Programs\Python38\lib\idlelib\iomenu.py", line 200, in save
if self.writefile(self.filename):
File "C:\Programs\Python38\lib\idlelib\iomenu.py", line 232, in writefile
text = self.fixnewlines()
File "C:\Programs\Python38\lib\idlelib\iomenu.py", line 252, in fixnewlines
text = text.replace("\n", self.eol_convention)
TypeError: replace() argument 2 must be str, not None The replacement line is guarded with |
I missed that the file's attribute newlines can be None if no line separators were read. It can also be a tuple if mixed newlines are used. I think that eol_convention should be set to the default value os.linesep in these cases. I am currently not able to test this since IDLE does not work on my computer after upgrading to Ubuntu 20.04. |
So loading an externally created blank file (on any system) results in None. File=>New must set eol_convention, I presume to the same default. Before I got the traceback, I though it might be an issue with the Windows utf-8 BOM being added. 3.9.0rc1 is due August 10. It should have fix and new tests. |
Bumping-up the priority. Today, I and a (virtual) room full of engineers simultaneously hit this problem and we all lost work. See bpo-41378 |
Raymond, I tested patch today and expect to apply it (without unittests yet) tomorrow, so will be in 3.9.0rc1 abd 3.8.6. In the meanwhile, either create new files within IDLE (File=>NEW) or add "isinstance(self.eol_convention, str) and " after 'if' on line 251 of idlelib/iomenu.py, just before the line in the traceback. The added check will be put elsewhere by the patch, but it should work on 251. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: