pywin32 icon indicating copy to clipboard operation
pywin32 copied to clipboard

CheckFile raises UnicodeDecodeError

Open ghost opened this issue 11 years ago • 2 comments

latest build, python 3.3.3, windows 8.1 Pressing Ctrl+Shift+C invokes CheckFile. When the file being checked contains 0x90 UnicodeDecodeError: ... can't decode byte 0x90 ... is raised.

In the traceback I see: File "C:\Python33\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 467, in CheckFile code = f.read() + "\n"

Reported by: ramrom

Original Ticket: pywin32/bugs/667

ghost avatar Mar 31 '14 02:03 ghost

I added encoding='utf-8' to the open for that file. The program now runs without error.

How do I submit a patch for it?

Original comment by: ramrom

ghost avatar Mar 31 '14 20:03 ghost

That's only going to work for files that actually are utf-8. If you open it in binary mode, the compile function should decode it acccording to the encoding declaration at the top of the file.

To create a patch, you'll need a program that can produce a unified diff. (http://gnuwin32.sourceforge.net/packages/diffutils.htm is one such)

Original comment by: rupole

ghost avatar Apr 03 '14 11:04 ghost

This would probably end up fixing itself in Python 3.15+ due to PEP 686 – Make UTF-8 mode default

Avasam avatar Dec 31 '24 01:12 Avasam