STINNER Victor added the comment: > b'%c' is still raising a TypeError. The error message is fine ("%c requires > an integer in range(256) or a single byte") but it should be an OverflowError > for backwards compatibility.
I don't understand why you care so much on the exact exception. It doesn't look right to me to rely on the *exact* exception raised by "%c" % arg. It's an obvious bug in the application. Sometimes, you may want to be extra safe and catch exception while formating a message. The logging module does this. But the logging doesn't care of the exact exception, it uses a generic "except Except:" in StreamHandler.emit(): def emit(self, record): try: msg = self.format(record) stream = self.stream stream.write(msg) stream.write(self.terminator) self.flush() except Exception: self.handleError(record) IMO b"%c" % int must raise ValueError, not OverflowError, if the value is not in the range 0..255. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue23466> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com