@@ -12,7 +12,13 @@ def test_conversion_between_exception_and_error(self):
12
12
except Exception as e :
13
13
original_exception = e
14
14
error = Error .from_exception (e )
15
- original_traceback = "" .join (traceback .format_exception (original_exception ))
15
+ original_traceback = "" .join (
16
+ traceback .format_exception (
17
+ original_exception .__class__ ,
18
+ original_exception ,
19
+ original_exception .__traceback__ ,
20
+ )
21
+ )
16
22
17
23
# For some reasons traceback.format_exception does not include the caret
18
24
# (^) in the original traceback, but it does in the reconstructed one,
@@ -24,7 +30,13 @@ def strip_caret(s):
24
30
25
31
reconstructed_exception = error .to_exception ()
26
32
reconstructed_traceback = strip_caret (
27
- "" .join (traceback .format_exception (reconstructed_exception ))
33
+ "" .join (
34
+ traceback .format_exception (
35
+ reconstructed_exception .__class__ ,
36
+ reconstructed_exception ,
37
+ reconstructed_exception .__traceback__ ,
38
+ )
39
+ )
28
40
)
29
41
30
42
assert type (reconstructed_exception ) is type (original_exception )
@@ -34,7 +46,13 @@ def strip_caret(s):
34
46
error2 = Error .from_exception (reconstructed_exception )
35
47
reconstructed_exception2 = error2 .to_exception ()
36
48
reconstructed_traceback2 = strip_caret (
37
- "" .join (traceback .format_exception (reconstructed_exception2 ))
49
+ "" .join (
50
+ traceback .format_exception (
51
+ reconstructed_exception2 .__class__ ,
52
+ reconstructed_exception2 ,
53
+ reconstructed_exception2 .__traceback__ ,
54
+ )
55
+ )
38
56
)
39
57
40
58
assert type (reconstructed_exception2 ) is type (original_exception )
0 commit comments