On Tue, 21 May 2013 01:39:03 +1000, Steven D'Aprano <st...@pearwood.info> wrote: > On 21/05/13 00:12, Ethan Furman wrote: > > > As a case in point, base64.py is currently getting a bug fix, and also > > contains this code: > > > > def b32decode(s, casefold=False, map01=None): > > . > > . > > . > > for i in range(0, len(s), 8): > > quanta = s[i: i + 8] > > acc = 0 > > try: > > for c in quanta: > > acc = (acc << 5) + b32rev[c] > > except KeyError: > > raise binascii.Error('Non-base32 digit found') > > . > > . > > . > > else: > > raise binascii.Error('Incorrect padding') > > > > Does the KeyError qualify as irrelevant noise?
[...] > In another reply, R.David Murray answered: > > "I don't see that it is of benefit to suppress [the KeyError]." > > Can I suggest that it's obviously been a long, long time since you > were a beginner to the language, and you've forgotten how intimidating > error messages can be? Error messages should be *relevant*. Irrelevant > details don't help, they hinder, and I suggest that the KeyError is > irrelevant. Doubtless you are correct. Now that you mention it I do remember being confused, even as an experienced programmer, by the chained exceptions when I first started dealing with them, but at this point I suppose it has become second nature :). I agree with the subsequent discussion that this error is a good case for 'from None', given that any such conversion should make sure all essential information is contained in the new error message. And I agree with Nick that there are probably many more places where 'raise from' will help clarify things when we *don't* want 'from None'. --David _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com