Skip to content

Commit 1392e97

Browse files
committed
again fix PythonVersionFromDLLName
1 parent ad1bc99 commit 1392e97

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

python4lazarus/PythonEngine.pas

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8837,24 +8837,26 @@ function IsPythonVersionRegistered(PythonVersion : AnsiString;
88378837

88388838
procedure PythonVersionFromDLLName(LibName: string; out MajorVersion, MinorVersion: integer);
88398839
//Windows: 'c:\some\path\python310.dll'
8840-
//Linux: '/some/path/libpython3.10.so'
8840+
//Linux: '/some/path/libpython3.10m.so'
88418841
const
88428842
cPython = 'python';
8843+
DefaultMajor = 3;
8844+
DefaultMinor = 4;
88438845
var
88448846
NPos: integer;
88458847
ch: char;
88468848
begin
8847-
MajorVersion:= 0;
8848-
MinorVersion:= 0;
8849+
MajorVersion:= DefaultMajor;
8850+
MinorVersion:= DefaultMinor;
88498851
LibName:= LowerCase(ExtractFileName(LibName)); //strip path
88508852
NPos:= Pos(cPython, LibName);
88518853
if NPos=0 then exit;
88528854
Inc(NPos, Length(cPython));
88538855
if NPos>Length(LibName) then exit;
88548856
ch:= LibName[NPos];
88558857
case ch of
8856-
'2'..'5': //support major versions 2...5, default 3
8857-
MajorVersion:= StrToIntDef(ch, 3);
8858+
'2'..'5': //support major versions 2...5
8859+
MajorVersion:= StrToIntDef(ch, DefaultMajor);
88588860
else
88598861
exit;
88608862
end;
@@ -8880,7 +8882,7 @@ procedure PythonVersionFromDLLName(LibName: string; out MajorVersion, MinorVersi
88808882
end;
88818883
end;
88828884
//the rest is minor version number '0'...'999'
8883-
MinorVersion:= StrToIntDef(LibName, 0);
8885+
MinorVersion:= StrToIntDef(LibName, DefaultMinor);
88848886
end;
88858887

88868888
end.

0 commit comments

Comments
 (0)