On 2020-02-07 6:05 p.m., Ram Rachum wrote:
Hi Soni,

I think that your suggestion is identical to Shai's. It would be good, but unfortunately it has the 3 problems I raised in my email from an hour ago.
of which 2 and 3 are personal opinions.

(for 2: you can just use a function. I'd consider that "explicit syntax" tbh.)

my point is tho: if your code implicitly raises during exception handling, that's likely a bug in your code. if it explicitly raises instead, that's likely intended instead. having the language reflect that would be useful IMO regardless of backwards compatibility concerns.
I'm gonna make a wild suggestion:

An explicit "raise" in an "except" body gets rewritten as "raise from"
the parent exception.

Hopefully this doesn't break anything, but, who knows. This means you get:

except Foo as e:
   raise Bar
# raises Bar, because of Foo, as if by "raise Bar from e"

except Foo as e:
# raises Bar while handling Foo, as it currently stands.
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-leave@python.org
Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/XN7B2ZSHKXAYN2G3OV2UVZD7JMIZ2PXV/
Code of Conduct: http://python.org/psf/codeofconduct/