When using sys.stdout with a pipe or redirection the sys.stdout.encoding value will be set to None instead of what the environment first specified through any locale setting. As such, fall back to locale.getpreferredencoding() before the ultimate fallback to ASCII.
When using sys.stdout with a pipe or redirection the sys.stdout.encoding value
will be set to None instead of what the environment first specified through
any locale setting. As such, fall back to locale.getpreferredencoding() before
the ultimate fallback to ASCII.

OK: cmlenz
closes: #76


nickretallack/babel,st4lk/babel,nandoflorestan/babel,iamshubh22/babel,mbirtwell/babel,prmtl/babel,xen/babel,gutsy/babel,lepistone/babel,mgax/babel,javacruft/babel,jmagnusson/babel,prmtl/babel,mitsuhiko/babel,upman/babel,felixonmars/babel,hanteng/babel,lepistone/babel,upman/babel,python-babel/babel,lepistone/babel,moreati/babel,python-babel/babel,hanteng/babel,nickretallack/babel,julen/babel,st4lk/babel,srisankethu/babel,masklinn/babel,mbirtwell/babel,xlevus/babel,gutsy/babel,jespino/babel,mbirtwell/babel,KIT-XXI/babel,st4lk/babel,srisankethu/babel,hanteng/babel,julen/babel,yoloseem/babel,skybon/babel,jespino/babel,xlevus/babel,jmagnusson/babel,jmagnusson/babel,xen/babel,mitsuhiko/babel,masklinn/babel,xlevus/babel,masklinn/babel,mgax/babel,prmtl/babel,nandoflorestan/babel,skybon/babel,felixonmars/babel,iamshubh22/babel,mitsuhiko/babel,iamshubh22/babel,KIT-XXI/babel,nickretallack/babel,yoloseem/babel,moreati/babel,skybon/babel,julen/babel,javacruft/babel,srisankethu/babel,upman/babel,nandoflorestan/babel,gutsy/babel,felixonmars/babel,moreati/babel,javacruft/babel,KIT-XXI/babel,yoloseem/babel