if data is a bytestring with non-ascii, you need to decode it before
you can re-encode it:
data = data.decode('utf-8','ignore')On Sat, Jan 9, 2010 at 4:06 AM, Paul Molodowitch <[email protected]> wrote: > Odd... I took a look at it, and the line that's apparently erroring is: > > data = data.encode( 'utf-8', 'ignore') > > The weird part is that the error handling is set to 'ignore' - which, > according to the docs (unless I misinterpreted it, somehow) is supposed to > mean that any characters which can't be converted are silently ignored. > Clearly, this isn't what's happening. > > - Paul > > On Sat, Jan 9, 2010 at 1:01 AM, Chad Dombrova <[email protected]> wrote: >> >> that's a tricky one. perhaps somewhere in mel2pyStr an `encode` or >> `decode` before getting parsed would do the trick. unf, don't have time to >> look this over atm, but a patch would be gladly accepted! :) >> -chad >> >> >> >> >> On Jan 9, 2010, at 12:51 AM, David Shaw wrote: >> >> Hey Chad, >> >> Another question that I am a little puzzled by when using mel2py >> >> I have a bunch of scripts that are throwing the following error: >> >> # Error: UnicodeDecodeError: file >> ..\site-packages\pymel10\pymel\tools\mel2py\melparse.py line 2580: ascii # >> (Note I have removed the longer part of the path just in the error) >> >> However I have some other scripts that are parsing just fine. >> >> It would seem the culprit is the © symbol in the scipts >> >> is there a modification I can make to the melparse.py to account for that? >> >> I tried setting the default to UTF-8 in jEdit and resaving, however that >> didn't seem to work. >> >> thanks >> Dave >> >> >> On Sat, Jan 9, 2010 at 4:54 PM, David Shaw <[email protected]> wrote: >>> >>> Ok thanks Chad. >>> >>> >>> On Sat, Jan 9, 2010 at 2:21 AM, Chad Dombrova <[email protected]> wrote: >>>> >>>> your second attempt was correct. the warnings are normal. >>>> >>>> -chad >>>> >>>> >>>> On Jan 8, 2010, at 8:10 AM, [email protected] wrote: >>>> >>>> > Hey guys, >>>> > >>>> > I've not tried to use mel2py until today. >>>> > >>>> > I am running pymel 1.0b2 (think thats right) under Maya 2010 (32bit) >>>> > >>>> > I do the following: >>>> > >>>> > import pymel.all as pm >>>> > # pymel.core : Updating pymel with pre-loaded plugins: Fur, >>>> > VectorRender, DirectConnect, studioImport, ikSpringSolver, Mayatomr, >>>> > rotateHelper, MayaMuscle, ModelPipelineExportMaya, fbxmaya, >>>> > ik2Bsolver, ModelPipelineMaterialMaya # >>>> > >>>> > Then: >>>> > import pymel.mel2py >>>> > # Error: ImportError: file <maya console> line 1: No module named >>>> > mel2py # >>>> > >>>> > So then did: >>>> > import pymel.tools.mel2py >>>> > >>>> > And got: >>>> > # WARNING: No t_error rule is defined >>>> > # WARNING: Token 'COMMENT_BLOCK' defined, but not used >>>> > # WARNING: Token 'COMMENT' defined, but not used >>>> > # WARNING: There are 2 unused tokens >>>> > # WARNING: no p_error() function is defined >>>> > # WARNING: Symbol 'element_list' is unreachable >>>> > >>>> > Am I doing something wrong? >>>> > >>>> > Thanks >>>> > Dave >>>> > -- >>>> > http://groups.google.com/group/python_inside_maya >>>> >>>> >>>> -- >>>> http://groups.google.com/group/python_inside_maya >>> >> >> -- >> http://groups.google.com/group/python_inside_maya >> >> -- >> http://groups.google.com/group/python_inside_maya > > > -- > http://groups.google.com/group/python_inside_maya >
-- http://groups.google.com/group/python_inside_maya
