[Zope3-dev] zope\app\container\contained.py

Florent Guillaume fg at nuxeo.com
Wed May 25 09:52:30 EDT 2005


E. Frerich <e.frerich at nord-com.net> wrote:
> line 545 of zope\app\container\contained.py contains a testcase
> ">>> setitem(container, container.__setitem__, 'hello ' + chr(200), item)"
> which should give back a traceback:
> "    Traceback (most recent call last):
>     ...
>     TypeError: name not unicode or ascii string
> "
> but the name parameter is correct:
> "
> >>> max=unicode('hello ' + chr(200))

That shouldn't work. You're running with a non-default system default
encoding. In default systems, you'll get:

>>> unicode('hello'+chr(200))
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc8 in position 5: ordinal not in range(128)

Which is the correct answer, because chr(200) is a byte and not a
character per se, and cannot be converted to unicode with additional
information (its encoding).

Florent

-- 
Florent Guillaume, Nuxeo (Paris, France)   CTO, Director of R&D
+33 1 40 33 71 59   http://nuxeo.com   fg at nuxeo.com


More information about the Zope3-dev mailing list