Your suggestion is correct.
A side issue is that the line numbers in the traceback are correct but the quoted text lines from iomenu (and only iomenu) are wrong, being from the line previous. I will have to investigate this discrepancy.
After the patch, two weeks ago, for #41158, iomenu line 199 in save is
if self.writefile(self.filename):
line 232 in writefile is
chars = self.encode(text)
line 291 in encode is
enc, _ = tokenize.detect_encoding(io.BytesIO(encoded).readline)
This is only tried if ascii encoding fails and require the addition of 'import io'.
Before I close this, I will try to add a unittest that similarly fails without the import added, as well as some others for other exit points. |