Skip to content

Commit d0fcdfe

Browse files
committed
1 parent 242c63b commit d0fcdfe

File tree

2 files changed

+8
-16
lines changed

2 files changed

+8
-16
lines changed

PythonForDelphi/Components/Sources/Core/PythonEngine.pas

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1517,7 +1517,6 @@ TPythonInterface=class(TDynamicDll)
15171517
FMajorVersion: integer;
15181518
FMinorVersion: integer;
15191519
FBuiltInModuleName: string;
1520-
function GetInitialized: Boolean;
15211520

15221521
procedure AfterLoad; override;
15231522
function GetQuitMessage : string; override;
@@ -2067,13 +2066,12 @@ TPythonInterface=class(TDynamicDll)
20672066
procedure MapDll;
20682067

20692068
// Public properties
2070-
property Initialized : Boolean read GetInitialized;
2069+
property Initialized : Boolean read FInitialized;
20712070
property Finalizing : Boolean read FFinalizing;
20722071
property IsPython3000 : Boolean read FIsPython3000;
20732072
property MajorVersion : integer read FMajorVersion;
20742073
property MinorVersion : integer read FMinorVersion;
20752074
property BuiltInModuleName: string read FBuiltInModuleName write FBuiltInModuleName;
2076-
20772075
end;
20782076

20792077
//--------------------------------------------------------
@@ -3516,6 +3514,7 @@ constructor TPythonInterface.Create(AOwner: TComponent);
35163514
i : Integer;
35173515
begin
35183516
inherited;
3517+
FInitialized := False;
35193518
i := COMPILED_FOR_PYTHON_VERSION_INDEX;
35203519
DllName := PYTHON_KNOWN_VERSIONS[i].DllName;
35213520
FAPIVersion := PYTHON_KNOWN_VERSIONS[i].APIVersion;
@@ -3556,14 +3555,6 @@ function TPythonInterface.GetQuitMessage : string;
35563555
Result := Format( 'Python could not be properly initialized. We must quit.', [DllName]);
35573556
end;
35583557

3559-
function TPythonInterface.GetInitialized: Boolean;
3560-
begin
3561-
if Assigned(Py_IsInitialized) then
3562-
Result := Py_IsInitialized() <> 0
3563-
else
3564-
Result := FInitialized;
3565-
end;
3566-
35673558
procedure TPythonInterface.CheckPython;
35683559
begin
35693560
if not Initialized then
@@ -4589,7 +4580,6 @@ constructor TPythonEngine.Create(AOwner: TComponent);
45894580
begin
45904581
inherited;
45914582
FLock := TCriticalSection.Create;
4592-
FInitialized := False;
45934583
FInitScript := TstringList.Create;
45944584
FClients := TList.Create;
45954585
FRedirectIO := True;
@@ -4660,6 +4650,7 @@ procedure TPythonEngine.Finalize;
46604650
Py_Finalize;
46614651
finally
46624652
FFinalizing := False;
4653+
FInitialized := False;
46634654
end;
46644655
except
46654656
end;
@@ -4873,7 +4864,10 @@ procedure TPythonEngine.Initialize;
48734864
Py_SetPythonHome(PAnsiChar(FPythonHome));
48744865
end;
48754866
Py_Initialize;
4876-
FInitialized := True;
4867+
if Assigned(Py_IsInitialized) then
4868+
FInitialized := Py_IsInitialized() <> 0
4869+
else
4870+
FInitialized := True;
48774871
FIORedirected := False;
48784872
InitSysPath;
48794873
SetProgramArgs;

PythonForDelphi/Components/Sources/Core/VarPyth.pas

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ function iter(const AValue : Variant ) : Variant; // return an iterator for the
116116
implementation
117117

118118
uses
119-
VarUtils, SysUtils, SysConst, TypInfo, Classes;
119+
VarUtils, SysUtils, TypInfo, Classes;
120120

121121
type
122122
TNamedParamDesc = record
@@ -262,7 +262,6 @@ TPythonData = class(TObject)
262262
resourcestring
263263
SMultiDimensionalPropsNotSupported = 'Multi-dimensional sequences or mappings are not supported in Python';
264264
SCantConvertArg = 'Can''t convert argument #%d of %s into a Python object';
265-
SBothOperandsOfIntDivideMustBeIntegers = 'Both operands of an integer division must be of type integer';
266265
SCantConvertKeyToPythonObject = 'Can''t convert Key into a Python object';
267266
SCantConvertValueToPythonObject = 'Can''t convert Value into a Python object';
268267
SCantCreateNewSequenceObject = 'Can''t create a new sequence object';
@@ -876,7 +875,6 @@ procedure TPythonVariantType.VarDataCastTo(var Dest: TVarData; const Source: TVa
876875
begin
877876
VarCast(Variant(Dest), Variant(Source), AVarType);
878877
end;
879-
880878
{$ENDIF}
881879

882880
procedure TPythonVariantType.Clear(var V: TVarData);

0 commit comments

Comments
 (0)