Message71347
I managed to get a proper traceback:
Exception in Tkinter callback
Traceback (most recent call last):
File "c:\afa\python\py3k\lib\tkinter\__init__.py", line 1405, in __call__
return self.func(*args)
File "c:\afa\python\py3k\lib\idlelib\MultiCall.py", line 165, in handler
r = l[i](event)
File "c:\afa\python\py3k\lib\idlelib\ScriptBinding.py", line 124, in
run_module_event
code = self.checksyntax(filename)
File "c:\afa\python\py3k\lib\idlelib\ScriptBinding.py", line 86, in
checksyntax
source = f.read()
File "C:\afa\python\py3k\lib\io.py", line 1692, in read
decoder.decode(self.buffer.read(), final=True))
File "C:\afa\python\py3k\lib\io.py", line 1267, in decode
output = self.decoder.decode(input, final=final)
File "C:\afa\python\py3k\lib\encodings\cp1252.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x8d in position
34: character maps to <undefined>
This is because the file is opened in text mode, using the default
encoding (cp1252). It should instead open it in binary mode, and look
for a -*-coding-*- directive.
There is an attempt for this in linecache.py, but the logic there is wrong.
Is there already a function to properly open a python source file?
tokenize.detect_encoding could be used, but is there a way to open a
file in binary & universal mode? |
|
Date |
User |
Action |
Args |
2008-08-18 16:16:02 | amaury.forgeotdarc | set | recipients:
+ amaury.forgeotdarc, terry.reedy, orsenthil, sven.siegmund |
2008-08-18 16:16:02 | amaury.forgeotdarc | set | messageid: <1219076162.06.0.494791750327.issue2827@psf.upfronthosting.co.za> |
2008-08-18 16:16:01 | amaury.forgeotdarc | link | issue2827 messages |
2008-08-18 16:16:00 | amaury.forgeotdarc | create | |
|