Skip to content

Commit 7fc375d

Browse files
committed
Added Runtime.Incref before using statements and removed uncessary semicolon
1 parent c1a9d94 commit 7fc375d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/runtime/pythonexception.cs

+4-3
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,24 @@ public PythonException() : base()
3636
{
3737
string type;
3838
string message;
39+
Runtime.Incref(_pyType);
3940
using (PyObject pyType = new PyObject(_pyType))
4041
using (PyObject pyTypeName = pyType.GetAttr("__name__"))
4142
{
4243
type = pyTypeName.ToString();
4344
}
44-
45+
46+
Runtime.Incref(_pyValue);
4547
using (PyObject pyValue = new PyObject(_pyValue))
4648
{
4749
message = pyValue.ToString();
4850
}
49-
;
50-
5151
_message = type + " : " + message;
5252
}
5353
if (_pyTB != IntPtr.Zero)
5454
{
5555
PyObject tb_module = PythonEngine.ImportModule("traceback");
56+
Runtime.Incref(_pyTB);
5657
using (PyObject pyTB = new PyObject(_pyTB)) {
5758
_tb = tb_module.InvokeMethod("format_tb", pyTB).ToString();
5859
}

0 commit comments

Comments
 (0)