Hum, the problem is that IDLE asks io.open() to detect the charset
whereas open() doesn't know the #coding: header. So if your locale is
ASCII, CP1252 or anything different of UTF-8, read the file will
fails.
I wrote a patch to detect the encoding. Python code (detect_encoding()
function) is based on PyTokenizer_FindEncoding() and get_coding_spec()
(from Parser/tokenizer.c). There is no existing Python function to
detect the encoding of a Python script? (a public function available
in a Python script) |