@@ -405,11 +405,16 @@ main:5: error: Exception must be derived from BaseException
405405class A: pass
406406class MyError(BaseException): pass
407407def f(): pass
408- raise BaseException
409- raise MyError
410- raise A # E: Exception must be derived from BaseException
411- raise object # E: Exception must be derived from BaseException
412- raise f # E: Exception must be derived from BaseException
408+ if object():
409+ raise BaseException
410+ if object():
411+ raise MyError
412+ if object():
413+ raise A # E: Exception must be derived from BaseException
414+ if object():
415+ raise object # E: Exception must be derived from BaseException
416+ if object():
417+ raise f # E: Exception must be derived from BaseException
413418[builtins fixtures/exception.pyi]
414419
415420[case testRaiseClassObjectCustomInit]
@@ -425,18 +430,30 @@ class MyKwError(Exception):
425430class MyErrorWithDefault(Exception):
426431 def __init__(self, optional=1) -> None:
427432 ...
428- raise BaseException
429- raise Exception
430- raise BaseException(1)
431- raise Exception(2)
432- raise MyBaseError(4)
433- raise MyError(5, 6)
434- raise MyKwError(kwonly=7)
435- raise MyErrorWithDefault(8)
436- raise MyErrorWithDefault
437- raise MyBaseError # E: Too few arguments for "MyBaseError"
438- raise MyError # E: Too few arguments for "MyError"
439- raise MyKwError # E: Missing named argument "kwonly" for "MyKwError"
433+ if object():
434+ raise BaseException
435+ if object():
436+ raise Exception
437+ if object():
438+ raise BaseException(1)
439+ if object():
440+ raise Exception(2)
441+ if object():
442+ raise MyBaseError(4)
443+ if object():
444+ raise MyError(5, 6)
445+ if object():
446+ raise MyKwError(kwonly=7)
447+ if object():
448+ raise MyErrorWithDefault(8)
449+ if object():
450+ raise MyErrorWithDefault
451+ if object():
452+ raise MyBaseError # E: Too few arguments for "MyBaseError"
453+ if object():
454+ raise MyError # E: Too few arguments for "MyError"
455+ if object():
456+ raise MyKwError # E: Missing named argument "kwonly" for "MyKwError"
440457[builtins fixtures/exception.pyi]
441458
442459[case testRaiseExceptionType]
@@ -469,10 +486,14 @@ f = None # type: MyError
469486a = None # type: A
470487x = None # type: BaseException
471488del x
472- raise e from a # E: Exception must be derived from BaseException
473- raise e from e
474- raise e from f
475- raise e from x # E: Trying to read deleted variable "x"
489+ if object():
490+ raise e from a # E: Exception must be derived from BaseException
491+ if object():
492+ raise e from e
493+ if object():
494+ raise e from f
495+ if object():
496+ raise e from x # E: Trying to read deleted variable "x"
476497class A: pass
477498class MyError(BaseException): pass
478499[builtins fixtures/exception.pyi]
@@ -482,11 +503,16 @@ import typing
482503class A: pass
483504class MyError(BaseException): pass
484505def f(): pass
485- raise BaseException from BaseException
486- raise BaseException from MyError
487- raise BaseException from A # E: Exception must be derived from BaseException
488- raise BaseException from object # E: Exception must be derived from BaseException
489- raise BaseException from f # E: Exception must be derived from BaseException
506+ if object():
507+ raise BaseException from BaseException
508+ if object():
509+ raise BaseException from MyError
510+ if object():
511+ raise BaseException from A # E: Exception must be derived from BaseException
512+ if object():
513+ raise BaseException from object # E: Exception must be derived from BaseException
514+ if object():
515+ raise BaseException from f # E: Exception must be derived from BaseException
490516[builtins fixtures/exception.pyi]
491517
492518[case testTryFinallyStatement]
0 commit comments