Re: [Python-ideas] exception instantiation philosophy and practice [was: Let try-except check the exception instance]

2018-06-01 Thread Greg Ewing
Eric Fahlgren wrote: I don't think it's possible to avoid instantiating the exception at the user level, what would sys.exc_info() do about it's second return value? The exception could be instantiated if and when sys.exc_info() gets called. -- Greg

Re: [Python-ideas] exception instantiation philosophy and practice [was: Let try-except check the exception instance]

2018-06-01 Thread Eric Fahlgren
On Thu, May 31, 2018 at 10:55 PM Greg Ewing wrote: > Ethan Furman wrote: > > > Why is this? Doesn't the exception have to be instantiated at some > > point, even if just to print to stderr? > > If it gets caught by an except clause without an else clause, > in theory there's no need to instantia

Re: [Python-ideas] Let try-except check the exception instance

2018-06-01 Thread Antoine Pitrou
On Thu, 31 May 2018 14:00:24 -0400 Alexander Belopolsky wrote: > > Is this really true? Consider the following simple code > > class E(Exception): > def __init__(self): > print("instantiated") > > try: > raise E > except E: > pass > > Is it truly necessary to instantiate E