Author: Armin Rigo <ar...@tunes.org> Branch: py3.6 Changeset: r97350:c0dcb6566060 Date: 2019-08-31 16:16 +0200 http://bitbucket.org/pypy/pypy/changeset/c0dcb6566060/
Log: hg merge default diff --git a/rpython/flowspace/flowcontext.py b/rpython/flowspace/flowcontext.py --- a/rpython/flowspace/flowcontext.py +++ b/rpython/flowspace/flowcontext.py @@ -566,11 +566,12 @@ if not isinstance(w_check_class, Constant): raise FlowingError("Non-constant except guard.") check_class = w_check_class.value - if check_class in (NotImplementedError, AssertionError): - raise FlowingError( - "Catching %s is not valid in RPython" % check_class.__name__) if not isinstance(check_class, tuple): # the simple case + if issubclass(check_class, (NotImplementedError, AssertionError)): + raise FlowingError( + "Catching %s is not valid in RPython" % + check_class.__name__) return self.guessbool(op.issubtype(w_exc_type, w_check_class).eval(self)) # special case for StackOverflow (see rlib/rstackovf.py) if check_class == rstackovf.StackOverflow: diff --git a/rpython/flowspace/test/test_objspace.py b/rpython/flowspace/test/test_objspace.py --- a/rpython/flowspace/test/test_objspace.py +++ b/rpython/flowspace/test/test_objspace.py @@ -1135,6 +1135,23 @@ pass py.test.raises(FlowingError, "self.codetest(f)") + def test_cannot_catch_special_exceptions_2(self): + class MyNIE(NotImplementedError): + pass + def f(): + try: + f() + except MyNIE: + pass + py.test.raises(FlowingError, "self.codetest(f)") + # + def f(): + try: + f() + except (ValueError, MyNIE): + pass + py.test.raises(FlowingError, "self.codetest(f)") + def test_locals_dict(self): def f(): x = 5 diff --git a/rpython/rlib/rawstorage.py b/rpython/rlib/rawstorage.py --- a/rpython/rlib/rawstorage.py +++ b/rpython/rlib/rawstorage.py @@ -55,7 +55,7 @@ misaligned_is_fine = False -class AlignmentError(NotImplementedError): +class AlignmentError(Exception): "Means that raw_storage_{get,set}item was used on unaligned memory" # Tweak? It seems a reasonable value for any system out there: requiring _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit