File tree 3 files changed +14
-5
lines changed 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):
624
624
def test_none_type (self ):
625
625
self .assertIsInstance (None , types .NoneType )
626
626
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
+
627
635
628
636
class UnionTests (unittest .TestCase ):
629
637
Original file line number Diff line number Diff line change @@ -52,11 +52,9 @@ def _m(self): pass
52
52
53
53
try :
54
54
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 )
60
58
61
59
# For Jython, the following two types are identical
62
60
GetSetDescriptorType = 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