RE: Setting stdout encoding

2007-09-13 Thread Ryan Ginstrom
> On Behalf Of Gabriel Genellina > You should check that obj is an unicode object before calling > encode. > Strings should not be encoded. ... > __getattr__ is only called when the attribute has NOT been > found in the usual way, so checking for "write" is > unnecesary. Just return getattr(se

Re: Setting stdout encoding

2007-09-13 Thread Gabriel Genellina
En Thu, 13 Sep 2007 08:43:11 -0300, Ryan Ginstrom <[EMAIL PROTECTED]> escribi�: >> On Behalf Of Fabio Zadrozny >> Makes sense... Do you think that creating a new object, >> setting it as sys.stdout and overriding its write() method to >> check for a unicode string to do >> original_stdout.write(

Re: Setting stdout encoding

2007-09-13 Thread Gabriel Genellina
En Thu, 13 Sep 2007 08:08:39 -0300, Fabio Zadrozny <[EMAIL PROTECTED]> escribi�: >> >> But I don't think it's a good idea. Changing the default encoding will >> change it for *all* scripts, *all* users, *all* objects. And AFAIK you >> have trouble ONLY with sys.std* - one should fix those object

RE: Setting stdout encoding

2007-09-13 Thread Ryan Ginstrom
> On Behalf Of Fabio Zadrozny > Makes sense... Do you think that creating a new object, > setting it as sys.stdout and overriding its write() method to > check for a unicode string to do > original_stdout.write(unicode_str.encode(my_encoding)) would > do it? Here's an output stream encoder I h

Re: Setting stdout encoding

2007-09-13 Thread Fabio Zadrozny
> > But I don't think it's a good idea. Changing the default encoding will > change it for *all* scripts, *all* users, *all* objects. And AFAIK you > have trouble ONLY with sys.std* - one should fix those objects, not mess > with a global configuration. > Makes sense... Do you think that creating

Re: Setting stdout encoding

2007-09-12 Thread Gabriel Genellina
En Tue, 11 Sep 2007 07:58:03 -0300, Fabio Zadrozny <[EMAIL PROTECTED]> escribi�: >> You could place code like that on sitecustomize.py >> I think this should be fixed on Eclipse/pydev. If they replace >> sys.stdout >> with a different object - they should make sure it has the right >> behavi

Re: Setting stdout encoding

2007-09-11 Thread Fabio Zadrozny
> > You could place code like that on sitecustomize.py > I think this should be fixed on Eclipse/pydev. If they replace sys.stdout > with a different object - they should make sure it has the right behavior. > Same for IDLE if it's broken too. > Thanks for the tip... I wasn't aware of sitecustomiz

Re: Setting stdout encoding

2007-09-10 Thread Gabriel Genellina
En Mon, 10 Sep 2007 10:02:42 -0300, Fabio Zadrozny <[EMAIL PROTECTED]> escribi�: >> Does someone know if there's a way to explicitly set the stdout/stderr/ >> stdin >> encoding that python should use? >> >> The encoding can be set using the C API for file objects - from Python >> code, use ctype

Re: Setting stdout encoding

2007-09-10 Thread Gabriel Genellina
En Sun, 09 Sep 2007 17:49:14 -0300, Fabio Zadrozny <[EMAIL PROTECTED]> escribi�: > Does someone know if there's a way to explicitly set the > stdout/stderr/stdin > encoding that python should use? The encoding can be set using the C API for file objects - from Python code, use ctypes: py>

Re: Setting stdout encoding

2007-09-10 Thread Fabio Zadrozny
> > > Does someone know if there's a way to explicitly set the stdout/stderr/ > stdin > encoding that python should use? > > The encoding can be set using the C API for file objects - from Python > code, use ctypes: > > Yeap, but that would leave me with the original problem: I need to run a script

Re: Setting stdout encoding

2007-09-10 Thread Gabriel Genellina
En Sun, 09 Sep 2007 17:49:14 -0300, Fabio Zadrozny <[EMAIL PROTECTED]> escribi?: Does someone know if there's a way to explicitly set the stdout/stderr/ stdin encoding that python should use? The encoding can be set using the C API for file objects - from Python code, use ctypes: py> from ctypes