"encoding" attribute codecs.getwriter-produced streams
Hrvoje Niksic
hniksic at xemacs.org
Mon Dec 20 05:57:43 EST 2010
Try this code:
# foo.py
import sys, codecs
stream = codecs.getwriter('utf-8')(sys.stdout)
print stream.encoding
$ python foo.py | cat
None
I expected the `encoding' attribute to be "UTF-8", since the stream
otherwise correctly functions as a utf-8 encoding stream.
Is this a bug in the stream factory returned by codecs.getwriter(...)?
If not, is there another way to determine a stream's output encoding
that would work for both default and codecs-created streams?
More information about the Python-list
mailing list