On Wed, Apr 16, 2008 at 11:21:26PM +1000, Nick Coghlan wrote: > Hmm, the io module along with sys.stdout/err may be a better way to > attack the problem then. Given: > > import sys, io > > class ParseUnicodeEscapes(io.TextIOWrapper): > def write(self, text): > super().write(text.encode('latin-1').decode('unicode_escape')) > > args = (sys.stdout.buffer, sys.stdout.encoding, sys.stdout.errors, > None, sys.stdout.line_buffering) > > sys.stdout = ParseUnicodeEscapes(*args) > > args = (sys.stderr.buffer, sys.stderr.encoding, sys.stderr.errors, > None, sys.stderr.line_buffering) > > sys.stderr = ParseUnicodeEscapes(*args) > > You get: > > >>> "тест" > 'тест' > >>> open("тест") > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > File "/home/ncoghlan/devel/py3k/Lib/io.py", line 212, in __new__ > return open(*args, **kwargs) > File "/home/ncoghlan/devel/py3k/Lib/io.py", line 151, in open > closefd) > IOError: [Errno 2] No such file or directory: 'тест'
Very well, then. Thank you! The code should be put in a cookbook or the wiki, if not in the library. Oleg. -- Oleg Broytmann http://phd.pp.ru/ [EMAIL PROTECTED] Programmers don't die, they just GOSUB without RETURN. _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com