diff --git a/Source/PythonEngine.pas b/Source/PythonEngine.pas index 4ce8aba2..64813974 100644 --- a/Source/PythonEngine.pas +++ b/Source/PythonEngine.pas @@ -6066,7 +6066,8 @@ function TPythonEngine.PyUnicodeAsString(obj : PPyObject): UnicodeString; Exit; // The second argument is the size of the destination (Result) including #0 - NewSize := Utf8ToUnicode(PChar(Result), Cardinal(Size + 1), Buffer, Cardinal(Size)); + NewSize := Utf8ToUnicode(PWideChar(Result), Cardinal(Size + 1), Buffer, Cardinal(Size)); + // NewSize includes #0 SetLength(Result, NewSize - 1); end diff --git a/Source/WrapDelphi.pas b/Source/WrapDelphi.pas index a6fdbf05..523f8c8d 100644 --- a/Source/WrapDelphi.pas +++ b/Source/WrapDelphi.pas @@ -2571,12 +2571,14 @@ function TPyDelphiObject.Dir_Wrapper(args: PPyObject): PPyObject; var PyType: PPyTypeObject; + {$IFDEF EXTENDED_RTTI} Context: TRttiContext; RttiType: TRTTIType; {$ELSE} _PropList: PPropList; _propCount : Integer; + i: Integer; {$ENDIF} begin Adjust(@Self); diff --git a/Source/WrapDelphiClasses.pas b/Source/WrapDelphiClasses.pas index 23ca2d56..7c1d8867 100644 --- a/Source/WrapDelphiClasses.pas +++ b/Source/WrapDelphiClasses.pas @@ -5,7 +5,8 @@ interface uses - Classes, SysUtils, PythonEngine, WrapDelphi; + Classes, SysUtils, PythonEngine, WrapDelphi + {$IFDEF FPC}, bufstream{$ENDIF}; type { @@ -367,6 +368,7 @@ implementation uses TypInfo {$IFNDEF FPC}, System.Rtti{$ENDIF}; + {$IFNDEF FPC} type TPyReader = class(TReader) @@ -2223,7 +2225,12 @@ TBufferedFileStreamClass = class of TBufferedFileStream; DelphiObject := TBufferedFileStreamClass(DelphiObjectClass).Create(String(LFileName), LMode, LBufferSize); end else if (LArgCount = 3) then begin if (APythonType.Engine.PyArg_ParseTupleAndKeywords(args, kwds, 'sHI|i:Create', @LKwArgs2[0], @LFileName, @LMode, @LRights, @LBufferSize) <> 0) then - DelphiObject := TBufferedFileStreamClass(DelphiObjectClass).Create(String(LFileName), LMode, LRights, LBufferSize); + {$IFDEF FPC} + DelphiObject := TBufferedFileStreamClass(DelphiObjectClass).Create(String(LFileName), LMode, LRights); + DelphiObject.Size:= LBufferSize; + {$ELSE} + DelphiObject := TBufferedFileStreamClass(DelphiObjectClass).Create(String(LFileName), LMode, LRights, LBufferSize); + {$ENDIF} end; //Maybe it was created on the next attempt... @@ -2385,14 +2392,14 @@ TResourceStreamClass = class of TResourceStream; {$ELSE} if APythonType.Engine.PyArg_ParseTuple(args, 'Iss:Create', @LHandle, @LResName, @LResType) <> 0 then {$ENDIF} - DelphiObject := TResourceStreamClass(DelphiObjectClass).Create(LHandle, String(LResName), PWideChar(String(LResType))) + DelphiObject := TResourceStreamClass(DelphiObjectClass).Create(LHandle, String(LResName), PChar(String(LResType))) else {$IFDEF CPUX64} if APythonType.Engine.PyArg_ParseTuple(args, 'Kis:Create', @LHandle, @LResId, @LResType) <> 0 then {$ELSE} if APythonType.Engine.PyArg_ParseTuple(args, 'Iis:Create', @LHandle, @LResId, @LResType) <> 0 then {$ENDIF} - DelphiObject := TResourceStreamClass(DelphiObjectClass).CreateFromID(LHandle, LResId, PWideChar(String(LResType))); + DelphiObject := TResourceStreamClass(DelphiObjectClass).CreateFromID(LHandle, LResId, PChar(String(LResType))); except on E: Exception do with GetPythonEngine do