"encoding" attribute codecs.getwriter-produced streams

H

Hrvoje Niksic

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top