On Fri, Sep 25, 2020 at 7:19 PM Sergio Fenoll <ser...@fenoll.be> wrote:
>
> O 25/09/20 ás 10:56, Chris Angelico escribiu:
>
> > There's the shallow "exceptions that I expect to raise", which is
> > those explicitly listed within the function as raise statements; but
> > that's not the whole story, since exceptions can be raised by anything
> > that the function calls. So, no, I don't think the callee should have
> > a notion of "exceptions that I or anyone I call might raise".
> >
> > ChrisA
>
> I don't understand the need of talking about "exceptions that something
> I call might raise" (from the POV of the callee) though, to me they are
> irrelevant in this discussion. When you implement a function, you are
> handling all/some/none exceptions and letting all/some/nonebubble up and
> be handled by whatever called you, right? Somewhere, be it in a
> docstring, some manual, external documentation, ... you write down what
> exceptions you expect to raise, be it explicit or implicit (e.g. by
> letting a known exception bubble up without explicitly raising it
> yourself).

Look at your own code. Do you know what EVERY function you call could
raise? If not, then your code could raise those exceptions. It's not
about "letting a known exception bubble up". It's the *normal
behaviour* of letting all exceptions bubble up unless explicitly
caught. Don't think in terms of knowing every exception that could be
raised. That simply doesn't work, and it leads to faulty logic like
this.

ChrisA
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/EYYRYYOUDWDMXSXH2MKKJ45XL7HG4G2F/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to