Skip to content

Commit ccb9dbb

Browse files
committed
sync RichCompare with pyscripter
1 parent df70ff8 commit ccb9dbb

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

python4lazarus/Sources/Core/PythonEngine.pas

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7867,9 +7867,25 @@ function TPyObject.Clear: integer;
78677867
Result := 0;
78687868
end;
78697869

7870+
78707871
function TPyObject.RichCompare( obj : PPyObject; Op : TRichComparisonOpcode) : PPyObject;
7871-
begin
7872-
Result := nil;
7872+
Var
7873+
Res : Boolean;
7874+
begin
7875+
Res := False;
7876+
case Op of
7877+
pyLT: Res := Compare(obj) < 0;
7878+
pyLE: Res := Compare(obj) <= 0;
7879+
pyEQ: Res := Compare(obj) = 0;
7880+
pyNE: Res := Compare(obj) <> 0;
7881+
pyGT: Res := Compare(obj) > 0;
7882+
pyGE: Res := Compare(obj) >= 0;
7883+
end;
7884+
if Res then
7885+
Result := PPyObject(GetPythonEngine.Py_True)
7886+
else
7887+
Result := PPyObject(GetPythonEngine.Py_False);
7888+
GetPythonEngine.Py_INCREF( Result );
78737889
end;
78747890

78757891
function TPyObject.Iter : PPyObject;

0 commit comments

Comments
 (0)