@@ -409,11 +409,16 @@ main:5: error: Exception must be derived from BaseException
409409class A: pass
410410class MyError(BaseException): pass
411411def f(): pass
412- raise BaseException
413- raise MyError
414- raise A # E: Exception must be derived from BaseException
415- raise object # E: Exception must be derived from BaseException
416- raise f # E: Exception must be derived from BaseException
412+ if object():
413+ raise BaseException
414+ if object():
415+ raise MyError
416+ if object():
417+ raise A # E: Exception must be derived from BaseException
418+ if object():
419+ raise object # E: Exception must be derived from BaseException
420+ if object():
421+ raise f # E: Exception must be derived from BaseException
417422[builtins fixtures/exception.pyi]
418423
419424[case testRaiseClassObjectCustomInit]
@@ -429,18 +434,30 @@ class MyKwError(Exception):
429434class MyErrorWithDefault(Exception):
430435 def __init__(self, optional=1) -> None:
431436 ...
432- raise BaseException
433- raise Exception
434- raise BaseException(1)
435- raise Exception(2)
436- raise MyBaseError(4)
437- raise MyError(5, 6)
438- raise MyKwError(kwonly=7)
439- raise MyErrorWithDefault(8)
440- raise MyErrorWithDefault
441- raise MyBaseError # E: Too few arguments for "MyBaseError"
442- raise MyError # E: Too few arguments for "MyError"
443- raise MyKwError # E: Missing named argument "kwonly" for "MyKwError"
437+ if object():
438+ raise BaseException
439+ if object():
440+ raise Exception
441+ if object():
442+ raise BaseException(1)
443+ if object():
444+ raise Exception(2)
445+ if object():
446+ raise MyBaseError(4)
447+ if object():
448+ raise MyError(5, 6)
449+ if object():
450+ raise MyKwError(kwonly=7)
451+ if object():
452+ raise MyErrorWithDefault(8)
453+ if object():
454+ raise MyErrorWithDefault
455+ if object():
456+ raise MyBaseError # E: Too few arguments for "MyBaseError"
457+ if object():
458+ raise MyError # E: Too few arguments for "MyError"
459+ if object():
460+ raise MyKwError # E: Missing named argument "kwonly" for "MyKwError"
444461[builtins fixtures/exception.pyi]
445462
446463[case testRaiseExceptionType]
@@ -473,10 +490,14 @@ f: MyError
473490a: A
474491x: BaseException
475492del x
476- raise e from a # E: Exception must be derived from BaseException
477- raise e from e
478- raise e from f
479- raise e from x # E: Trying to read deleted variable "x"
493+ if object():
494+ raise e from a # E: Exception must be derived from BaseException
495+ if object():
496+ raise e from e
497+ if object():
498+ raise e from f
499+ if object():
500+ raise e from x # E: Trying to read deleted variable "x"
480501class A: pass
481502class MyError(BaseException): pass
482503[builtins fixtures/exception.pyi]
@@ -486,11 +507,16 @@ import typing
486507class A: pass
487508class MyError(BaseException): pass
488509def f(): pass
489- raise BaseException from BaseException
490- raise BaseException from MyError
491- raise BaseException from A # E: Exception must be derived from BaseException
492- raise BaseException from object # E: Exception must be derived from BaseException
493- raise BaseException from f # E: Exception must be derived from BaseException
510+ if object():
511+ raise BaseException from BaseException
512+ if object():
513+ raise BaseException from MyError
514+ if object():
515+ raise BaseException from A # E: Exception must be derived from BaseException
516+ if object():
517+ raise BaseException from object # E: Exception must be derived from BaseException
518+ if object():
519+ raise BaseException from f # E: Exception must be derived from BaseException
494520[builtins fixtures/exception.pyi]
495521
496522[case testTryFinallyStatement]
0 commit comments