Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#90 Encoding Error Exception

closed
nobody
None
5
2007-04-11
2005-05-14
Stephen Anderson
No

Trying to open attached file, get the following traceback (minorly editted for brevity):

Traceback (most recent call last):
File "drpython.py", line 2727, in OpenFile
oof, e = drEncoding.EncodeText(self, oof, encoding, True)
File "drEncoding.py", line 208, in EncodeText
raise Exception, 'Encoding Error!'
Exception: Encoding Error!

wxPython Version: 2.6.0.0
wxPython Platform: wxMSW, unicode, wx-assertions-on
Python Version: 2.4.1.final
Python Platform: win32
OS Version: WinXP SP2

Discussion

  • Python File which causes exception on opening

     
    Attachments
  • Omar Modesto
    Omar Modesto
    2006-01-24

    Logged In: YES
    user_id=816603

    I get the same error message when using any special
    characters (ñ,®,© and such). It seems DrPython doesn't
    support anything other than the standard ones at the moment.

     
  • Knut
    Knut
    2007-01-05

    Logged In: YES
    user_id=1641170
    Originator: NO

    I could reproduce the error by loading the attached file (nanothreads.py). The error occurs, because the file contains the Character \xa9. This is the Copyright sign (©) in latin-1 (ISO-ISO 8859-1 and variations like Windows cp1252).
    The error can be healed by changing the Default Encoding in DrPython to an appropiate encoding. This can be done under "Options->Preferences->General". I have added this information to the Encoding Error message, so that users will have a hint what to do.

     
  • Knut
    Knut
    2007-01-05

    Logged In: YES
    user_id=1641170
    Originator: NO

    Another possibilty is, to add an encoding cookie like # -*- coding: ISO 8859-1 -*- to line 1 or 2 of the sourcefile. I tested this by adding the line to nanothreads.py (the attachment below) and DrPython recognized the cookie in accordance with PEP 0263 (see http://www.python.org/dev/peps/pep-0263/\). Precondition is that "Auto Detect Encoding" is switched on under "Options->Preferences->General".
    I do believe now that the handling of Decoding/Encoding respectively Unicode in DrPython is correct and that both this request and request "[ 1615463 ] Unhandled exception on syntax check: Unicode" can be closed

     
    • status: open --> closed
     
  • Logged In: YES
    user_id=772872
    Originator: NO

    thanks knuger.