A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2012-January/115734.html below:

[Python-Dev] exception chaining

[Python-Dev] exception chaining [Python-Dev] exception chainingBenjamin Peterson benjamin at python.org
Fri Jan 20 18:47:13 CET 2012
2012/1/20 Ethan Furman <ethan at stoneleaf.us>:
> Summary:
>
> Exception Chaining is cool, unless you are writing libraries that want to
> transform from Exception X to Exception Y as the the previous exception
> context is unnecessary, potentially confusing, and cluttery (yup, just made
> that word up!).
>
> For all the gory details, see http://bugs.python.org/issue6210.
>
> I'm going to attempt a patch implementing MRAB's suggestion:
>
> try:
>    some_op
> except ValueError:
>    raise as OtherError() # `raise` keeps context, `raise as` does not

I dislike this syntax. Raise what as OtherError()? I think the "raise
x from None" idea is preferable, since it indicates you are nulling
the context. The optimal solution would be to have "raise X
nocontext", but that would obviously require another keyword...


-- 
Regards,
Benjamin
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4