Re: [Python-Dev] PEP 409 and the stdlib

2013-06-21 Thread Hrvoje Niksic
On 05/21/2013 10:36 AM, Serhiy Storchaka wrote: 21.05.13 10:17, Hrvoje Niksic написав(ла): On 05/20/2013 05:15 PM, Ethan Furman wrote: 1) Do nothing and be happy I use 'raise ... from None' in my own libraries 2) Change the wording of 'During handling of the above exception, another

Re: [Python-Dev] PEP 409 and the stdlib

2013-05-28 Thread Serhiy Storchaka
20.05.13 18:46, Antoine Pitrou написав(ла): I think it is a legitimate case where to silence the original exception. However, the binascii.Error would be more informative if it said *which* non-base32 digit was encountered. Please open a new issue for this request (note that no other binascii

Re: [Python-Dev] PEP 409 and the stdlib

2013-05-28 Thread Glenn Linderman
On 5/28/2013 6:02 AM, Serhiy Storchaka wrote: 20.05.13 18:46, Antoine Pitrou написав(ла): I think it is a legitimate case where to silence the original exception. However, the binascii.Error would be more informative if it said *which* non-base32 digit was encountered. Please open a new issue

Re: [Python-Dev] PEP 409 and the stdlib

2013-05-28 Thread Antoine Pitrou
On Tue, 28 May 2013 16:02:00 +0300 Serhiy Storchaka storch...@gmail.com wrote: 20.05.13 18:46, Antoine Pitrou написав(ла): I think it is a legitimate case where to silence the original exception. However, the binascii.Error would be more informative if it said *which* non-base32 digit was

Re: [Python-Dev] PEP 409 and the stdlib

2013-05-28 Thread Steven D'Aprano
On 29/05/13 04:00, Antoine Pitrou wrote: On Tue, 28 May 2013 16:02:00 +0300 Serhiy Storchaka storch...@gmail.com wrote: 20.05.13 18:46, Antoine Pitrou написав(ла): I think it is a legitimate case where to silence the original exception. However, the binascii.Error would be more informative if

Re: [Python-Dev] PEP 409 and the stdlib

2013-05-23 Thread Martin v. Löwis
Am 21.05.13 18:03, schrieb Ethan Furman: And, of course, we only make these changes when we're already modifying the module for some other reason. In the specific case, the KeyError has indeed useful information that the TypeError does not, namely the specific character that is the culprit. So

Re: [Python-Dev] PEP 409 and the stdlib

2013-05-23 Thread Ethan Furman
On 05/23/2013 04:36 AM, Martin v. Löwis wrote: Am 21.05.13 18:03, schrieb Ethan Furman: And, of course, we only make these changes when we're already modifying the module for some other reason. In the specific case, the KeyError has indeed useful information that the TypeError does not,

Re: [Python-Dev] PEP 409 and the stdlib

2013-05-23 Thread Steven D'Aprano
On 24/05/13 00:24, Ethan Furman wrote: Here's the code that existed at one point: for c in s: val = _b32rev.get(c) if val is None: raise TypeError('Non-base32 digit found') Even though there is no KeyError to convert in this incarnation, providing the

Re: [Python-Dev] PEP 409 and the stdlib

2013-05-21 Thread Serhiy Storchaka
21.05.13 10:17, Hrvoje Niksic написав(ла): On 05/20/2013 05:15 PM, Ethan Furman wrote: 1) Do nothing and be happy I use 'raise ... from None' in my own libraries 2) Change the wording of 'During handling of the above exception, another exception occurred' (no ideas as to what at the moment)

Re: [Python-Dev] PEP 409 and the stdlib

2013-05-21 Thread Hrvoje Niksic
On 05/21/2013 10:36 AM, Serhiy Storchaka wrote: The above exception was converted to the following exception: ... That makes it clear that the conversion was explicit and (hopefully) intentional, and that the latter exception supersedes the former. How do you distinguish intentional

Re: [Python-Dev] PEP 409 and the stdlib

2013-05-21 Thread Serhiy Storchaka
21.05.13 12:28, Hrvoje Niksic написав(ла): On 05/21/2013 10:36 AM, Serhiy Storchaka wrote: The above exception was converted to the following exception: ... That makes it clear that the conversion was explicit and (hopefully) intentional, and that the latter exception supersedes the

Re: [Python-Dev] PEP 409 and the stdlib

2013-05-21 Thread Hrvoje Niksic
On 05/21/2013 11:56 AM, Serhiy Storchaka wrote: try: x = d['key'] except KeyError: x = fallback('key') def fallback(key): if key not in a: raise BusinessError(...) return 1 / a[key] # possible TypeError, ZeroDivisionError, etc Yes, in that case the exception

Re: [Python-Dev] PEP 409 and the stdlib

2013-05-21 Thread Nick Coghlan
On Tue, May 21, 2013 at 5:17 PM, Hrvoje Niksic hrvoje.nik...@avl.com wrote: On 05/20/2013 05:15 PM, Ethan Furman wrote: 1) Do nothing and be happy I use 'raise ... from None' in my own libraries 2) Change the wording of 'During handling of the above exception, another exception occurred'

Re: [Python-Dev] PEP 409 and the stdlib

2013-05-21 Thread Serhiy Storchaka
21.05.13 13:05, Hrvoje Niksic написав(ла): On 05/21/2013 11:56 AM, Serhiy Storchaka wrote: try: x = d['key'] except KeyError: x = fallback('key') def fallback(key): if key not in a: raise BusinessError(...) return 1 / a[key] # possible TypeError,

Re: [Python-Dev] PEP 409 and the stdlib

2013-05-21 Thread Hrvoje Niksic
On 05/21/2013 02:57 PM, Serhiy Storchaka wrote: 21.05.13 13:05, Hrvoje Niksic написав(ла): On 05/21/2013 11:56 AM, Serhiy Storchaka wrote: try: x = d['key'] except KeyError: x = fallback('key') def fallback(key): if key not in a: raise BusinessError(...)

Re: [Python-Dev] PEP 409 and the stdlib

2013-05-21 Thread Nick Coghlan
On Tue, May 21, 2013 at 11:23 PM, Hrvoje Niksic hrvoje.nik...@avl.com wrote: In my example code the raise keyword appears lexically inside the except clause. The compiler would automatically emit a different raise opcode in that case. Hrvoje, can we drop this subthread please. The topic was

Re: [Python-Dev] PEP 409 and the stdlib

2013-05-21 Thread R. David Murray
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): . . .

Re: [Python-Dev] PEP 409 and the stdlib

2013-05-21 Thread Ethan Furman
On 05/21/2013 04:23 AM, Nick Coghlan wrote: On Tue, May 21, 2013 at 5:17 PM, Hrvoje Niksic hrvoje.nik...@avl.com wrote: On 05/20/2013 05:15 PM, Ethan Furman wrote: 1) Do nothing and be happy I use 'raise ... from None' in my own libraries 2) Change the wording of 'During handling of the

Re: [Python-Dev] PEP 409 and the stdlib

2013-05-20 Thread Nick Coghlan
On 20 May 2013 23:38, Ethan Furman et...@stoneleaf.us wrote: As a quick reminder, PEP 409 allows this: try: ... except AnError: raise SomeOtherError from None so that if the exception is not caught, we get the traditional single exception traceback, instead of the

Re: [Python-Dev] PEP 409 and the stdlib

2013-05-20 Thread R. David Murray
On Mon, 20 May 2013 06:12:41 -0700, Ethan Furman et...@stoneleaf.us wrote: As a quick reminder, PEP 409 allows this: try: ... except AnError: raise SomeOtherError from None so that if the exception is not caught, we get the traditional single exception

Re: [Python-Dev] PEP 409 and the stdlib

2013-05-20 Thread Ethan Furman
On 05/20/2013 06:47 AM, Nick Coghlan wrote: On 20 May 2013 23:38, Ethan Furman wrote: As a quick reminder, PEP 409 allows this: try: ... except AnError: raise SomeOtherError from None so that if the exception is not caught, we get the traditional single exception

Re: [Python-Dev] PEP 409 and the stdlib

2013-05-20 Thread R. David Murray
On Mon, 20 May 2013 07:12:07 -0700, Ethan Furman et...@stoneleaf.us 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 =

Re: [Python-Dev] PEP 409 and the stdlib

2013-05-20 Thread Ethan Furman
On 05/20/2013 07:50 AM, R. David Murray wrote: On Mon, 20 May 2013 07:12:07 -0700, 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,

Re: [Python-Dev] PEP 409 and the stdlib

2013-05-20 Thread Steven D'Aprano
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:

Re: [Python-Dev] PEP 409 and the stdlib

2013-05-20 Thread Antoine Pitrou
On Mon, 20 May 2013 07:12:07 -0700 Ethan Furman et...@stoneleaf.us 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 =

Re: [Python-Dev] PEP 409 and the stdlib

2013-05-20 Thread Georg Brandl
Am 20.05.2013 17:39, schrieb Steven D'Aprano: 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

Re: [Python-Dev] PEP 409 and the stdlib

2013-05-20 Thread Serhiy Storchaka
20.05.13 16:12, Ethan Furman написав(ла): As a quick reminder, PEP 409 allows this: try: ... except AnError: raise SomeOtherError from None so that if the exception is not caught, we get the traditional single exception traceback, instead of the new: During

Re: [Python-Dev] PEP 409 and the stdlib

2013-05-20 Thread Terry Jan Reedy
On 5/20/2013 11:39 AM, Steven D'Aprano 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):

Re: [Python-Dev] PEP 409 and the stdlib

2013-05-20 Thread Ethan Furman
On 05/20/2013 11:32 AM, Terry Jan Reedy wrote: On 5/20/2013 11:39 AM, Steven D'Aprano 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): . . .

Re: [Python-Dev] PEP 409 and the stdlib

2013-05-20 Thread Eric V. Smith
On May 20, 2013, at 11:46 AM, Antoine Pitrou solip...@pitrou.net wrote: On Mon, 20 May 2013 07:12:07 -0700 Ethan Furman et...@stoneleaf.us 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):

Re: [Python-Dev] PEP 409 and the stdlib

2013-05-20 Thread Nick Coghlan
On 21 May 2013 05:01, Ethan Furman et...@stoneleaf.us wrote: On 05/20/2013 11:32 AM, Terry Jan Reedy wrote: On 5/20/2013 11:39 AM, Steven D'Aprano 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: