diff --git a/PythonForDelphi/Components/Sources/Core/PythonEngine.pas b/PythonForDelphi/Components/Sources/Core/PythonEngine.pas index 10b84f42..a4a6ac37 100644 --- a/PythonForDelphi/Components/Sources/Core/PythonEngine.pas +++ b/PythonForDelphi/Components/Sources/Core/PythonEngine.pas @@ -3149,6 +3149,7 @@ procedure PyObjectDestructor( pSelf : PPyObject); cdecl; procedure FreeSubtypeInst(ob:PPyObject); cdecl; procedure Register; function PyType_HasFeature(AType : PPyTypeObject; AFlag : Integer) : Boolean; +function GetPythonVersionFromDLLName(const DLLFileName : String): String; { Helper functions} (* @@ -4746,7 +4747,9 @@ procedure TPythonEngine.DoOpenDll(const aDllName : String); end; if not PYTHON_KNOWN_VERSIONS[i].CanUseLatest then Break; - end; + end + else + RegVersion := GetPythonVersionFromDLLName(aDllName); inherited; end; @@ -9754,6 +9757,11 @@ procedure Register; TPythonType, TPythonModule, TPythonDelphiVar]); end; +function GetPythonVersionFromDLLName(const DLLFileName : String): String; +begin + Result := DLLFileName[{$IFDEF MSWINDOWS}7{$ELSE}10{$ENDIF}] + '.' + DLLFileName[{$IFDEF MSWINDOWS}8{$ELSE}11{$ENDIF}]; +end; + function PyType_HasFeature(AType : PPyTypeObject; AFlag : Integer) : Boolean; begin //(((t)->tp_flags & (f)) != 0) diff --git a/PythonForDelphi/Components/Sources/Core/PythonVersions.pas b/PythonForDelphi/Components/Sources/Core/PythonVersions.pas index c243f339..f917991f 100644 --- a/PythonForDelphi/Components/Sources/Core/PythonVersions.pas +++ b/PythonForDelphi/Components/Sources/Core/PythonVersions.pas @@ -464,8 +464,7 @@ function PythonVersionFromPath(const Path: string; out PythonVersion: TPythonVer end; PythonVersion.DLLPath := DLLPath; - SysVersion := Copy(DLLFileName, 7, 2); - Insert('.', SysVersion, 2); + SysVersion := GetPythonVersionFromDLLName(DLLFileName); PythonVersion.SysVersion := SysVersion; PythonVersion.fSysArchitecture := PythonVersion.ExpectedArchitecture;