Message239958
> 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. |
|
Date |
User |
Action |
Args |
2015-04-03 08:48:40 | vstinner | set | recipients:
+ vstinner, ethan.furman, python-dev, serhiy.storchaka |
2015-04-03 08:48:40 | vstinner | set | messageid: <1428050920.88.0.0515749300504.issue23466@psf.upfronthosting.co.za> |
2015-04-03 08:48:40 | vstinner | link | issue23466 messages |
2015-04-03 08:48:40 | vstinner | create | |
|