We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5ae34ba commit ce61a6fCopy full SHA for ce61a6f
src/runtime/pythonexception.cs
@@ -1,4 +1,5 @@
1
using System;
2
+using System.Linq;
3
using System.Runtime.CompilerServices;
4
using System.Text;
5
@@ -44,6 +45,7 @@ public PythonException()
44
45
}
46
_message = type + " : " + message;
47
48
+
49
if (_pyTB != IntPtr.Zero)
50
{
51
using PyObject tb_module = PythonEngine.ImportModule("traceback");
@@ -54,7 +56,9 @@ public PythonException()
54
56
using var tbList = tb_module.InvokeMethod("format_tb", pyTB);
55
57
58
var sb = new StringBuilder();
- foreach (var line in tbList) {
59
+ // Reverse Python's traceback list to match the order used in C#
60
+ // stacktraces
61
+ foreach (var line in tbList.Reverse()) {
62
sb.Append(line.ToString());
63
64
_tb = sb.ToString();
0 commit comments