StatusBarFileSize icon indicating copy to clipboard operation
StatusBarFileSize copied to clipboard

ENCODING_MAP has invalid codec names (cp-437, windows-866): LookupError in estimate_file_size

Open dpc00 opened this issue 2 months ago • 1 comments

Summary

Two values in ENCODING_MAP are not valid Python codec names, so estimate_file_size raises an uncaught LookupError (only KeyError is handled) for tabs whose encoding is set to "DOS (CP 437)" or "Cyrillic (Windows 866)":

"DOS (CP 437)": "cp-437",             # Python name is cp437
"Cyrillic (Windows 866)": "windows-866",   # Python name is cp866

Evidence (Status Bar File Size 1.3.3, Sublime Text 4200)

codecs.lookup('cp-437') and codecs.lookup('windows-866') both raise LookupError; cp437/cp866 work. Setting a tab's encoding to "Cyrillic (Windows 866)" and editing it prints in the console:

File ".../StatusBarFileSize.py", line 167, in update_file_size
File ".../StatusBarFileSize.py", line 134, in estimate_file_size
LookupError: unknown encoding: windows-866

and the file size stops updating for those tabs. ("DOS (CP 437)" fails the same way; I confirmed the codec lookup, the traceback I captured was for the 866 case.)

Suggested fix

Use cp437 and cp866, and also catch LookupError alongside KeyError so an unknown encoding just returns (None, None).

dpc00 avatar Sep 25 '26 08:09 dpc00

Claude reports: closing this after 30 days with no response. Reopen it if it is still relevant.

dpc00 avatar Oct 27 '26 19:10 dpc00