File tree Expand file tree Collapse file tree 3 files changed +14
-5
lines changed Expand file tree Collapse file tree 3 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -624,6 +624,14 @@ def test_notimplemented_type(self):
624624 def test_none_type (self ):
625625 self .assertIsInstance (None , types .NoneType )
626626
627+ def test_traceback_and_frame_types (self ):
628+ try :
629+ raise OSError
630+ except OSError as e :
631+ exc = e
632+ self .assertIsInstance (exc .__traceback__ , types .TracebackType )
633+ self .assertIsInstance (exc .__traceback__ .tb_frame , types .FrameType )
634+
627635
628636class UnionTests (unittest .TestCase ):
629637
Original file line number Diff line number Diff line change @@ -52,11 +52,9 @@ def _m(self): pass
5252
5353try :
5454 raise TypeError
55- except TypeError :
56- tb = sys .exc_info ()[2 ]
57- TracebackType = type (tb )
58- FrameType = type (tb .tb_frame )
59- tb = None ; del tb
55+ except TypeError as exc :
56+ TracebackType = type (exc .__traceback__ )
57+ FrameType = type (exc .__traceback__ .tb_frame )
6058
6159# For Jython, the following two types are identical
6260GetSetDescriptorType = type (FunctionType .__code__ )
Original file line number Diff line number Diff line change 1+ Add missing test for :class: `types.TracebackType ` and
2+ :class: `types.FrameType `. Calculate them directly from the caught exception
3+ without calling :func: `sys.exc_info `.
You can’t perform that action at this time.
0 commit comments