Re: Exception for parameter errors
On Wed, 4 Mar 2020 at 12:33, Chris Angelico <rosuav@gmail.com> wrote:
Being able to easily distinguish "that isn't callable" from "the parameters don't line up" from "the function, during execution, raised TypeError" would be useful.
I **completely** agree. And I add that the change can also be non-breaking, if the new ArgumentError is simply a subclass of TypeError. Yes, it's incorrect, but this way no old code will break. PS: if you read the official docs (https://docs.python.org/3/library/exceptions.html#TypeError):
exception TypeError Raised when an operation or function is applied to an object of inappropriate type.
etc. It's never stated that TypeError should be raised when the number of arguments is invalid, for example. It seems that TypeError itself is saying "now I'm used outside my scope" :-)
participants (1)
-
Marco Sulla