Re: [Cheetahtemplate-discuss] unicode: I lost...
Brought to you by:
rtyler,
tavis_rudd
From: Tavis R. <ta...@da...> - 2007-03-28 16:35:37
|
Hi Sandro, Sorry for not replying earlier. I've been very busy with some client work= =20 so far this year and haven't had time to keep up with the Cheetah list=20 emails until now. The bug you found is related to the way Cheetah pretty-prints the python=20 code it generates. I've just fixed it in the cvs repository and will be=20 cutting a new release soon. Tavis On Thu, 8 Mar 2007, Sandro Dentella wrote: > Hi all, > > I'm still stuck with this problem. Since the following code is *really > simple*, can sombody tell me if: > > 1. I'm doing something the wrong way > 2. This code doen *not* raise error to you > 3. This is a bug (of cheetah?) > 4. there is a workaround > > > Thanks > sandro > > Previous message: > ----------------------------------------------------------------- > > I lost the battle.... or I'm lost, as you prefere... > Trying to debug a UnicodeEncodeError I wrote these lines. Just a '\n' mak= es > the difference between a smooth compile and a UnicodeEncodeError. > > Do you have any explanation? > > > > # coding: latin-1 > from Cheetah.Template import Template > > tmpl =3D unicode('\n\nCiao =F9 $a', 'latin-1') ### works > #tmpl =3D unicode('\n\n\nCiao =F9 $a', 'latin-1') ### doesn't com= pile! > > context =3D {'a': u'lettera A \xf9', } > t =3D Template.compile(tmpl) > ret =3D t(namespaces=3D[context]) > print ret.respond().encode('latin-1') > > > > > > This is the traceback: > > Traceback (most recent call last): > File "cheetah-test2.py", line 7, in ? > t =3D Template.compile(tmpl) > File "/var/lib/python-support/python2.4/Cheetah/Template.py", line 716, = in compile > generatedModuleCode =3D compiler.getModuleCode() > File "/var/lib/python-support/python2.4/Cheetah/Compiler.py", line 1849,= in getModuleCode > return self.wrapModuleDef() > File "/var/lib/python-support/python2.4/Cheetah/Compiler.py", line 1867,= in wrapModuleDef > moduleDef =3D """%(header)s > File "/var/lib/python-support/python2.4/Cheetah/Compiler.py", line 1951,= in classDefs > classDefs =3D [str(klass) for klass in self._finishedClasses() ] > File "/var/lib/python-support/python2.4/Cheetah/Compiler.py", line 1422,= in classDef > return self.wrapClassDef() > File "/var/lib/python-support/python2.4/Cheetah/Compiler.py", line 1446,= in wrapClassDef > addMethods() > File "/var/lib/python-support/python2.4/Cheetah/Compiler.py", line 1432,= in addMethods > classDefChunks.extend([ > File "/var/lib/python-support/python2.4/Cheetah/Compiler.py", line 1471,= in methodDefs > methodDefs =3D [str(methGen) for methGen in self._finishedMethods() ] > UnicodeEncodeError: 'ascii' codec can't encode character u'\xf9' in posit= ion 655: ordinal not in range(128) > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share y= our > opinions on IT & business topics through brief surveys-and earn cash > http://www.techsay.com/default.php?page=3Djoin.php&p=3Dsourceforge&CID=3D= DEVDEV > _______________________________________________ > Cheetahtemplate-discuss mailing list > Che...@li... > https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss > |