#1275 Encoding detection on pydevd.py is simply wrong

1.5.1
closed-fixed
debugger (210)
5
2011-01-16
2011-01-15
No

Encoding detection on pydevd.py is simply wrong.

- System
Windows Vista 64bit Home Premium Japanese, but should be any.
- Eclipse version
3.5 and 3.6, but should be any.
- Pydev version
1.6.5.2011010512, but should be any.
- Python version
CPython 3.1.1, should be all Python 3.

Pydev debugger can't start when the all conditions met below:
- Python 3.x
- default encoding changed by some reason.
- target .py file don't have "# coding: encode-name" line.

Here's a patch to
plugins\org.python.pydev.debug_1.6.5.2011010512\pysrc\pydevd.py,
but I don't know 'b' prefixed string is acceptable with
all Python 2.x (2.6.3 simply ignores b-prefix):

918c918
< stream = open(file)
---
> stream = open(file, "rb") # to detect encoding, we must read as binary.
925c925
< if line.strip().startswith('#'):
---
> if line.strip().startswith(b'#'):
927c927
< if 'coding' in line:
---
> if b'coding' in line:
929c929
< p = re.search(r"coding[:=]\s*([-\w.]+)", line)
---
> p = re.search(br"coding[:=]\s*([-\w.]+)", line)

Discussion

  • Fabio Zadrozny

    Fabio Zadrozny - 2011-01-16
    • status: open --> closed-fixed
     
  • Fabio Zadrozny

    Fabio Zadrozny - 2011-01-16

    Fixed for 1.6.5

    Git
    e4957b9
    1295195514
    2011-01-16

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks