LeoRochael wrote:
> There is a relatively simple fix for this problem.
>
> The last segment in the traceback above is caused by this small
> zope.tales.expressions.StringExpr.__call__() method on
> zope.tales-3.4.0-py2.6.egg/zope/tales/expressions.py:
>
> 258 def __call__(self, econtext):
> 259 vvals = []
> 260 for var in self._vars:
> 261 v = var(econtext)
> 262 vvals.append(v)
> 263 return self._expr % tuple(vvals)
>
>
> The problem is that self._expr is always a unicode string on recent versions of Zope2, whereas "self._vars" is a list of PathExpr objects, and "v = var(econtext)" will return whatever type of objects the path expressions resolve, even 8-bit strings. Which means the line "return self._expr % tuple(vvals)" will always cause a UnicodeDecodingError if any of the values is a string with 8-bit chars (save for Python default encoding tricks).
>
> If line 261 above is replaced by:
>
> v = econtext.evaluateText(var)
>
> In Zope2 this will return a Unicode object using the unicode conflict
> resolver registered with Zope2. In plain zope.tales, the
> zope.tales.tales.Context.evaluateText() method converts the object to
> unicode directly unless it is already a text-ish object (like a i18n
> message), which I believe is what makes sense in the context of String
> Expressions.
>
> I can commit a fix with tests based on this solution.
Can you upload a patch showing those tests? I'm afraid my seritonin
level is too low to figure out what you are fixing without seeing the tests.
Tres.
- --
===================================================================
Tres Seaver +1 540-429-0999 <email address hidden>
Palladion Software "Excellence by Design" http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
LeoRochael wrote: expressions. StringExpr. __call_ _() method on 3.4.0-py2. 6.egg/zope/ tales/expressio ns.py: Error if any of the values is a string with 8-bit chars (save for Python default encoding tricks). evaluateText( var) tales.Context. evaluateText( ) method converts the object to
> There is a relatively simple fix for this problem.
>
> The last segment in the traceback above is caused by this small
> zope.tales.
> zope.tales-
>
> 258 def __call__(self, econtext):
> 259 vvals = []
> 260 for var in self._vars:
> 261 v = var(econtext)
> 262 vvals.append(v)
> 263 return self._expr % tuple(vvals)
>
>
> The problem is that self._expr is always a unicode string on recent versions of Zope2, whereas "self._vars" is a list of PathExpr objects, and "v = var(econtext)" will return whatever type of objects the path expressions resolve, even 8-bit strings. Which means the line "return self._expr % tuple(vvals)" will always cause a UnicodeDecoding
>
> If line 261 above is replaced by:
>
> v = econtext.
>
> In Zope2 this will return a Unicode object using the unicode conflict
> resolver registered with Zope2. In plain zope.tales, the
> zope.tales.
> unicode directly unless it is already a text-ish object (like a i18n
> message), which I believe is what makes sense in the context of String
> Expressions.
>
> I can commit a fix with tests based on this solution.
Can you upload a patch showing those tests? I'm afraid my seritonin
level is too low to figure out what you are fixing without seeing the tests.
Tres. ======= ======= ======= ======= ======= ======= ======= ======= ==== palladion. com enigmail. mozdev. org
- --
=======
Tres Seaver +1 540-429-0999 <email address hidden>
Palladion Software "Excellence by Design" http://
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://
iEYEARECAAYFAks 9E8QACgkQ+ gerLs4ltQ75ggCf S5KEFzqcRoZDdFw gp+HenZKp eTWnDsI4kG0xrB3 SMTu
yl8AoJZi1OCG/
=IM2x
-----END PGP SIGNATURE-----