Lines Matching defs:exc
224 except Exception as exc:
225 raise RuntimeError('issue29692:Chained') from exc
441 exc = None
448 def __exit__(self, *exc):
449 self.exc = exc
468 self.assertEqual(context.exc, (None, None, None))
477 self.assertIsNotNone(context.exc)
478 self.assertIs(context.exc[0], NameError)
484 self.assertIsNotNone(context.exc)
485 self.assertIs(context.exc[0], NameError)
493 self.assertIsNone(context.exc)
496 self.assertEqual(context.exc, (None, None, None))
504 self.assertIsNone(context.exc)
510 self.assertIsNotNone(context.exc)
511 self.assertIs(context.exc[0], NameError)
548 def __exit__(self, *exc):
560 def __uxit__(self, *exc):
571 exc = None
577 def __exit__(self, *exc):
578 self.exc = exc
586 self.assertIsNone(context.exc)
589 self.assertEqual(context.exc, (None, None, None))
670 def _expect_exc(exc_type, exc, exc_tb):
674 def _expect_ok(exc_type, exc, exc_tb):
676 self.assertIsNone(exc)
767 stack.push(lambda *exc: False)
772 stack.push(lambda *exc: True)
781 def raise_exc(exc):
782 raise exc
789 exc = e
791 self.assertIsInstance(exc, ValueError)
792 ve_frames = traceback.extract_tb(exc.__traceback__)
797 ('raise_exc', 'raise exc')]
802 self.assertIsInstance(exc.__context__, ZeroDivisionError)
803 zde_frames = traceback.extract_tb(exc.__context__.__traceback__)
811 def __init__(self, exc):
812 self.exc = exc
816 raise self.exc
843 except IndexError as exc:
844 self.assertIsInstance(exc.__context__, KeyError)
845 self.assertIsInstance(exc.__context__.__context__, AttributeError)
847 self.assertIsNone(exc.__context__.__context__.__context__)
857 def raise_exc(exc):
858 raise exc
874 except IndexError as exc:
875 self.assertIsInstance(exc.__context__, KeyError)
876 self.assertIsInstance(exc.__context__.__context__, AttributeError)
878 self.assertIsNone(exc.__context__.__context__.__context__)
898 exc = MyException()
900 raise exc
902 exc.__context__ = None
915 except MyException as exc:
916 self.assertIsNone(exc.__context__)
922 def raise_exc(exc):
923 raise exc
932 except Exception as exc:
933 self.assertIsInstance(exc, IndexError)
942 except Exception as exc:
943 self.assertIsInstance(exc, KeyError)
950 def gets_the_context_right(exc):
954 raise exc
970 except Exception as exc:
971 self.assertIs(exc, exc4)
972 self.assertIs(exc.__context__, exc3)
973 self.assertIs(exc.__context__.__context__, exc2)
974 self.assertIs(exc.__context__.__context__.__context__, exc1)
976 exc.__context__.__context__.__context__.__context__)
996 except Exception as exc:
997 self.assertIs(exc, exc5)
998 self.assertIs(exc.__context__, exc4)
999 self.assertIs(exc.__context__.__context__, exc3)
1000 self.assertIs(exc.__context__.__context__.__context__, exc2)
1002 exc.__context__.__context__.__context__.__context__, exc1)
1004 exc.__context__.__context__.__context__.__context__.__context__)
1013 except IndexError as exc:
1018 stack.push(lambda *exc: True)
1019 stack.push(lambda *exc: 1/0)
1020 stack.push(lambda *exc: {}[1])
1048 except Exception as exc:
1049 raise UniqueException("new exception") from exc
1055 except Exception as exc:
1056 raise exc
1066 exc = err_ctx.exception
1067 self.assertIsInstance(exc, UniqueException)
1068 self.assertIsInstance(exc.__context__, UniqueRuntimeError)
1069 self.assertIsNone(exc.__context__.__context__)
1070 self.assertIsNone(exc.__context__.__cause__)
1071 self.assertIs(exc.__cause__, exc.__context__)