[Zope3-dev] test errors due to ascii defaultencoding assumption

Stefan Rank e9725431 at student.tuwien.ac.at
Thu Oct 20 02:10:56 EDT 2005


on 19.10.2005 21:15 Tim Peters said the following:
> [Stephan Richter]
> 
>>I am pretty sure that it is strongly discouraged to change the default
>>encoding in site.py. Can anyone confirm this? I think based on this
>>discouragement we always assume that noone changes their site.pp.
> 
> If you're running a personal Python, and are willing to deal with all
> the problems it _might_ cause yourself, there's nothing wrong with
> changing the default encoding (or, at least, nobody from the PSF will
> arrest you).
> 
> Anyone else shouldn't touch the default encoding, period -- the
> intended, industrial-strength way to deal with encodings is to use
> Unicode and explicit encode/decode operations. 

Thanks for the clarification, sounds very reasonable.
I'm now trying to think of my incentive for changing it in the first 
place, and my notes say that it was necessary to get some file 
operations to behave.
Unfortunately I did not note which ones they were, but I think it was 
something like shutil.copytree() on Windows failing.

The problem was that it *internally* did not deal correctly with unicode 
filenames, i.e. there was no way to influence it from the calling side.
Then I found site.py, enabled the platform dependent default encoding, 
and did not give it another thought...

(I think at that time it was py2.3, but if come across a repeatable test 
case I'll post a bug report.)

> I'm sure sys.setdefaultencoding will vanish in a future Python
> release, since it wasn't intended to persist beyond initial
> development to begin with.

In that case may I suggest changing the default to utf-8.
( I think it's about time this ascii thing died ;-)

cheers,
stefan


More information about the Zope3-dev mailing list