Nadeem Vawda added the comment: [terry.reedy] | Arfrever's point about the order of characters makes me wonder why mode | strings (as opposed to characters in the strings) are being checked. | The following tests that exactly one of w, a, x appear in mode. | if len({'w', 'a', 'x'} & set(mode)) == 1: | If mode is eventually passed to open(), the latter would do what ever | it does with junk chars in mode (such as 'q').
There are two separate questions here - how rigid we are about modes containing only valid characters, and how we handle invalid characters. I don't think there's any point in passing through unrecognized chars to builtins.open(), since it results in a ValueError either way. On the first point, the code only accepts modes like 'r' and 'rb' (but not 'br') for the sake of simplicity. There doesn't seem to be much practical value in accepting arbitrarily-ordered modes, but if someone has a compelling use-case (or a patch that's no more complex than the status quo), please bring it up in a separate issue. ---------- resolution: -> fixed stage: patch review -> committed/rejected status: open -> closed _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue19201> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com