[Python-Dev] Re: PEP 654 -- Exception Groups and except* : request for feedback for SC submission

2021年2月26日 07:27:14 -0800

On Fri, Feb 26, 2021 at 2:42 PM Nathaniel Smith <[email protected]> wrote:
> On Fri, Feb 26, 2021 at 5:05 AM Irit Katriel <[email protected]>
> wrote:
> > I'm not sure it's safe to assume that it is necessarily a programming
> error, and that the interpreter can essentially break the program in this
> case.
> > Is this not allowed?
> >
> > try:
> > try:
> > obj.func() # function that raises ExceptionGroups
> > except AttributeError:
> > logger.info("obj doesn't have a func")
> > except *(AttributeError, SyntaxError):
> > logger.info("func had some problems")
>
> I'd be fine with disallowing that. The intuition is that things will
> be simplest if ExceptionGroup is kept as transparent and meaningless
> as possible, i.e. ExceptionGroup(ValueError) and ValueError mean
> exactly the same thing -- "some code inside this block raised
> ValueError" -- and ideally should be processed in exactly the same
> way.
But they don't mean the same thing if this prints hello:
try:
 raise ValueError()
except ValueError:
 print('hello')
and this raises a RuntimeError:
try:
 raise ExceptionGroup("", [ValueError()])
except ValueError:
 print('hello')
What am I missing?
_______________________________________________
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/ZQYMOWWCFBP3TBBNZGD5X45CWJNC4HFF/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to