From 050d64e6ae0f080f71976589f3d27c1984ea15b5 Mon Sep 17 00:00:00 2001 From: "sergey.bugay" Date: Mon, 11 Jan 2016 10:37:43 +0300 Subject: [PATCH 1/3] Resolve hints Resolved hints: * [dcc32 Hint] PythonEngine.pas(5559): H2443 Inline function 'TList.Remove' has not been expanded because unit 'System.Types' is not specified in USES list * [dcc32 Hint] PythonEngine.pas(5561): H2443 Inline function 'TList.Remove' has not been expanded because unit 'System.Types' is not specified in USES list --- PythonForDelphi/Components/Sources/Core/PythonEngine.pas | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/PythonForDelphi/Components/Sources/Core/PythonEngine.pas b/PythonForDelphi/Components/Sources/Core/PythonEngine.pas index 9900134a..3e5e2a4a 100644 --- a/PythonForDelphi/Components/Sources/Core/PythonEngine.pas +++ b/PythonForDelphi/Components/Sources/Core/PythonEngine.pas @@ -3111,9 +3111,11 @@ procedure MaskFPUExceptions(ExceptionsMasked : boolean; implementation +uses {$IFDEF MSWINDOWS} -uses Registry; + Registry, {$ENDIF} + System.Types; (*******************************************************) From 03a9ce835a22d0cd56c718e35473affd23ae7dbc Mon Sep 17 00:00:00 2001 From: "sergey.bugay" Date: Mon, 11 Jan 2016 10:41:04 +0300 Subject: [PATCH 2/3] Change event types --- PythonForDelphi/Components/Sources/Core/PythonEngine.pas | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/PythonForDelphi/Components/Sources/Core/PythonEngine.pas b/PythonForDelphi/Components/Sources/Core/PythonEngine.pas index 3e5e2a4a..f5459f1b 100644 --- a/PythonForDelphi/Components/Sources/Core/PythonEngine.pas +++ b/PythonForDelphi/Components/Sources/Core/PythonEngine.pas @@ -1364,10 +1364,10 @@ EPyWindowsError = class (EPyOSError); kMaxLineLength = 256; type - TSendDataEvent = procedure (Sender: TObject; const Data : AnsiString ) of object; - TReceiveDataEvent = procedure (Sender: TObject; var Data : AnsiString ) of object; - TSendUniDataEvent = procedure (Sender: TObject; const Data : UnicodeString ) of object; - TReceiveUniDataEvent = procedure (Sender: TObject; var Data : UnicodeString ) of object; + TSendDataEvent = reference to procedure (Sender: TObject; const Data : AnsiString ); + TReceiveDataEvent = reference to procedure (Sender: TObject; var Data : AnsiString ); + TSendUniDataEvent = reference to procedure (Sender: TObject; const Data : UnicodeString ); + TReceiveUniDataEvent = reference to procedure (Sender: TObject; var Data : UnicodeString ); IOChar = WideChar; IOString = UnicodeString; TIOStringList = TUnicodeStringList; From 1b37b5c688d20ba9c0889835f17ea225c0afec9d Mon Sep 17 00:00:00 2001 From: Semen Khmelev Date: Wed, 2 Mar 2016 15:37:03 +0300 Subject: [PATCH 3/3] fix: change result of PyObjectAsVariant to null if seq_length(obj) = 0 Otherwise, the work with results of PyObjectAsVariant lead to AV (PyObjectAsVariant.ArrayLowBound -> AV) --- .../Components/Sources/Core/PythonEngine.pas | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/PythonForDelphi/Components/Sources/Core/PythonEngine.pas b/PythonForDelphi/Components/Sources/Core/PythonEngine.pas index f5459f1b..ae5f446a 100644 --- a/PythonForDelphi/Components/Sources/Core/PythonEngine.pas +++ b/PythonForDelphi/Components/Sources/Core/PythonEngine.pas @@ -5968,17 +5968,19 @@ function TPythonEngine.PyObjectAsVariant( obj : PPyObject ) : Variant; seq_length := PySequence_Length( obj ); // if we have at least one object in the sequence, if seq_length > 0 then + begin // we try to get the first one, simply to test if the sequence API // is really implemented. Py_XDecRef( PySequence_GetItem( obj, 0 ) ); // check if the Python object did really implement the sequence API - if PyErr_Occurred = nil then - begin - // Convert a Python sequence into an array of Variant - Result := VarArrayCreate( [0, seq_length-1], varVariant ); - for i := 0 to PySequence_Length( obj )-1 do - Result[i] := GetSequenceItem( obj, i ); - end + if PyErr_Occurred = nil then + begin + // Convert a Python sequence into an array of Variant + Result := VarArrayCreate( [0, seq_length-1], varVariant ); + for i := 0 to PySequence_Length( obj )-1 do + Result[i] := GetSequenceItem( obj, i ); + end + end else // the object didn't implement the sequence API, so we return Null begin PyErr_Clear;