This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author nikratio
Recipients Arfrever, elixir, ishimoto, jwilk, loewis, methane, mrabarnett, ncoghlan, nikratio, pitrou, rurpy2, serhiy.storchaka, vstinner
Date 2014-02-04.21:50:46
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <52F160B3.600@rath.org>
In-reply-to <1391513295.28.0.832802307878.issue15216@psf.upfronthosting.co.za>
Content
On 02/04/2014 03:28 AM, Nick Coghlan wrote:
> 
> Nick Coghlan added the comment:
> 
> If operating systems always exposed accurate metadata and configuration settings, I'd agree with you. They don't though, so sometimes developers need to be able to override whatever the interpreter figured out automatically.

Where does the operating system come into play? What I'm trying to say
is that any code of the form

fh = some_python_function()
fh.set_encoding(foo)

should really be written as

fh = some_python_function(encoding=foo)

or

fh = TextIOWrapper(some_python_function(raw=True), encoding=foo)

The only exception to this is sys.std{in,out,err}. But this special case
should, in my opinion, be solved with a corresponding special function
in sys.*, rather than a general purpose method in TextIOWrapper.

> In addition, needing to cope with badly designed APIs is an unfortunate fact of life - that's why monkeypatching is only *discouraged*, rather than disallowed :)

Well, yes, but introducing a set_encoding() or reconfigure() function is
actively *encouraging* bad API design. "I'll just return my favorite
encoding from this function, after all, the caller can use set_encoding
afterwards".

Best,
Nikolaus

-- 
Encrypted emails preferred.
PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C

             »Time flies like an arrow, fruit flies like a Banana.«
History
Date User Action Args
2014-02-04 21:50:46nikratiosetrecipients: + nikratio, loewis, ishimoto, ncoghlan, pitrou, vstinner, jwilk, mrabarnett, Arfrever, methane, rurpy2, serhiy.storchaka, elixir
2014-02-04 21:50:46nikratiolinkissue15216 messages
2014-02-04 21:50:46nikratiocreate