Nick Coghlan added the comment: Attached patch checks the requested encoding is a valid text encoding in TextIOWrapper.__init__.
Two additional test changes were needed: - the one that checks handling of non-text-encodings at runtime now tweaks quopri to lie about being a text encoding when creating the stream - the one that checks the interpreter doesn't crash at shutdown needed to be adjusted to handle the fact that _pyio now also fails in that situation, but with a different error (it can't find the ascii codec because the codec machinery is mostly gone) Currently, this adds a third lookup of the encoding name to the process of creating a TextIOWrapper instance. This could be reduced to just one by changing the retrieval of the encoder and decoder to look in the retrieved codec info tuple, rather than doing the lookup by name again. ---------- components: +IO keywords: +patch nosy: +pitrou Added file: http://bugs.python.org/file33747/issue20404_check_valid_textio_codec.diff _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue20404> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com