Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions PythonForDelphi/Components/Sources/Core/PythonEngine.pas
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -3111,9 +3111,11 @@ procedure MaskFPUExceptions(ExceptionsMasked : boolean;

implementation

uses
{$IFDEF MSWINDOWS}
uses Registry;
Registry,
{$ENDIF}
System.Types;


(*******************************************************)
Expand Down Expand Up @@ -5966,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;
Expand Down