On May 2, 2016 11:18 AM, "Random832" <random832@fastmail.com> wrote:
>
> On Mon, May 2, 2016, at 11:14, Guido van Rossum wrote:
> > On Mon, May 2, 2016 at 8:01 AM, Ryan Gonzalez <rymg19@gmail.com> wrote:
> >
> > > Other than the fact that this would completely fail when run with -O...
> > >
> > But maybe that's fine, or intended.
> >
> > I can see a fair number of uses for this, including subclasses of
> > AssertionError.
>
> I think this would be an attractive nuisance, and if it's implemented at
> all it should forbid types that are *not* subclasses of AssertionError
> in order to mitigate that.
What about wrapping the error in an AssertionError? The error being raised is really an assertion error, since it came from an assert.
A wrapped ValueError isn't going to be caught by an `except ValueError:` clause. That might be a good thing: failed asserts usually shouldn't be caught, since they indicate a bug. Even if they are caught (e.g. for logging), they shouldn't be caught by something expecting a non-AssertionError.