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

2005-05-31 Thread Florent Guillaume
E. Frerich <[EMAIL PROTECTED]> 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
> 
> Oh - what is a "non-default system default"? The "naked" Python has 
> 'ascii' as default but you can customize the default for a Python site.

Yes but this is highly unadvised. It's more a band-aid for lazy apps
than anything else.

> So my Python site has the default encoding 'cp1252'. All applications
> - not only Zope 3 - use this encoding.

Which means that all your applications are written with an implicit
assumption about the default system encoding. And they will break on
platforms with a different choice.

> IMO Zope 3 should accept other default encodings.

Zope has to be conservative so that it knows it can run everywhere.

> And then this test is not helpful.

It ensures that Zope works with minimal "standard" python settings.

Florent

-- 
Florent Guillaume, Nuxeo (Paris, France)   CTO, Director of R&D
+33 1 40 33 71 59   http://nuxeo.com   [EMAIL PROTECTED]
___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



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

2005-05-25 Thread E. Frerich
Am 25 May 2005 um 15:52 hat Florent Guillaume geschrieben:

> E. Frerich <[EMAIL PROTECTED]> 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

Oh - what is a "non-default system default"? The "naked" Python has 
'ascii' as default but you can customize the default for a Python site. So 
my Python site has the default encoding 'cp1252'. All applications - not 
only Zope 3 - use this encoding.

IMO Zope 3 should accept other default encodings. And then this test is 
not helpful.

Egon


> encoding. In default systems, you'll get:
> 
> >>> unicode('hello'+chr(200))
> Traceback (most recent call last):
>   File "", 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   [EMAIL PROTECTED]


___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



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

2005-05-25 Thread Florent Guillaume
E. Frerich <[EMAIL PROTECTED]> 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 "", 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   [EMAIL PROTECTED]
___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com