#1504 wrong default encoding for python3 under debugger

open
debugger (210)
5
2012-05-13
2012-05-13
voo42
No

When debugging a script that contains non windows-1252 characters I get an UnicodeDecodeError. Since I'm running Python3 the default encoding when none is specified should be UTF-8 and not the platform default (which amounts to windows-1252 under windows).

The error can be traced to _pydev_exefile:

if encoding:
stream = open(file, encoding=encoding)
else:
stream = open(file) # line 31, should be open(file, encoding="utf8") for python3

OS: Windows 7 x64 SP1
eclipse: Indigo SR2
python interpreter: 3.2 x64
pydev: PyDev for Eclipse 2.5.0.2012040618 org.python.pydev.feature.feature.group Aptana

Trace of included bug
pydev debugger: starting
Traceback (most recent call last):
File "C:\Program Files (x86)\eclipse\plugins\org.python.pydev.debug_2.5.0.2012040618\pysrc\pydevd.py", line 1346, in <module>
debugger.run(setup['file'], None, None)
File "C:\Program Files (x86)\eclipse\plugins\org.python.pydev.debug_2.5.0.2012040618\pysrc\pydevd.py", line 1060, in run
pydev_imports.execfile(file, globals, locals) #execute the script
File "C:\Program Files (x86)\eclipse\plugins\org.python.pydev.debug_2.5.0.2012040618\pysrc\_pydev_execfile.py", line 33, in execfile
contents = stream.read()
File "D:\Python\Python 3.2 x64\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 0x81 in position 4: character maps to <undefined>

Error does only appear when debugging a script, not when running.

Discussion

  • voo42
    voo42
    2012-05-13

    bug example

     
    Attachments