Nikolaus Rath added the comment: 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.« ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue15216> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com