Skip to content

Commit

Permalink
Fix reference counting in ProcessSystemExit. See https://en.delphipra…
Browse files Browse the repository at this point in the history
  • Loading branch information
pyscripter committed Mar 13, 2024
1 parent a6a8b29 commit 46e0bf7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Source/PythonEngine.pas
Original file line number Diff line number Diff line change
Expand Up @@ -6425,15 +6425,19 @@ procedure TPythonEngine.ListToSet( List : PPyObject; data : Pointer; size : Inte
end;

procedure TPythonEngine.CheckError(ACatchStopEx : Boolean = False);

procedure ProcessSystemExit;
var
errtype, errvalue, errtraceback: PPyObject;
SErrValue: string;
begin
// PyErr_Fetch clears the error. The returned python objects are new references
PyErr_Fetch(errtype, errvalue, errtraceback);
Traceback.Refresh(errtraceback);
SErrValue := PyObjectAsString(errvalue);
PyErr_Clear;
Py_XDECREF(errtype);
Py_XDECREF(errvalue);
Py_XDECREF(errtraceback);
raise EPySystemExit.CreateResFmt(@SPyExcSystemError, [SErrValue]);
end;

Expand Down

0 comments on commit 46e0bf7

Please sign in to comment.