On Wed, Jun 7, 2017 at 4:22 AM, Skip Montanaro <skip.montan...@gmail.com> wrote: > On Tue, Jun 6, 2017 at 12:27 PM, Chris Angelico <ros...@gmail.com> wrote: >> Or perhaps showing the repr of the string would be clearer. > > This would definitely be better, I think, and require no special > casing of the empty string. Still, I doubt this would ever be > backported for fear of breaking code might be out there somewhere > which relies on the current behavior. At best, it might be added to > the next 3.x release (3.7?).
Yeah. Unfortunately this exception doesn't make good use of its args, so you can't get programmatic information from it (this is true in 3.7 too actually). So if a change were to be made, I'd recommend putting the actual string into e.args[1] or something, and then the message shouldn't need to be parsed. I'm not sure what the backward compat guarantees on exception messages are, though, so it is possible that this might be changed in 2.7. ChrisA -- https://mail.python.org/mailman/listinfo/python-list