@@ -126,26 +126,28 @@ interface
126126 end ;
127127const
128128{ $IFDEF MSWINDOWS}
129- PYTHON_KNOWN_VERSIONS: array [1 ..8 ] of TPythonVersionProp =
129+ PYTHON_KNOWN_VERSIONS: array [1 ..9 ] of TPythonVersionProp =
130130 ( (DllName: ' python23.dll' ; RegVersion: ' 2.3' ; APIVersion: 1012 ; CanUseLatest: True),
131131 (DllName: ' python24.dll' ; RegVersion: ' 2.4' ; APIVersion: 1012 ; CanUseLatest: True),
132132 (DllName: ' python25.dll' ; RegVersion: ' 2.5' ; APIVersion: 1013 ; CanUseLatest: True),
133133 (DllName: ' python26.dll' ; RegVersion: ' 2.6' ; APIVersion: 1013 ; CanUseLatest: True),
134134 (DllName: ' python27.dll' ; RegVersion: ' 2.7' ; APIVersion: 1013 ; CanUseLatest: True),
135135 (DllName: ' python30.dll' ; RegVersion: ' 3.0' ; APIVersion: 1013 ; CanUseLatest: True),
136136 (DllName: ' python31.dll' ; RegVersion: ' 3.1' ; APIVersion: 1013 ; CanUseLatest: True),
137- (DllName: ' python32.dll' ; RegVersion: ' 3.2' ; APIVersion: 1013 ; CanUseLatest: True) );
137+ (DllName: ' python32.dll' ; RegVersion: ' 3.2' ; APIVersion: 1013 ; CanUseLatest: True),
138+ (DllName: ' python33.dll' ; RegVersion: ' 3.3' ; APIVersion: 1013 ; CanUseLatest: True) );
138139{ $ENDIF}
139140{ $IFDEF LINUX}
140- PYTHON_KNOWN_VERSIONS: array [1 ..8 ] of TPythonVersionProp =
141+ PYTHON_KNOWN_VERSIONS: array [1 ..9 ] of TPythonVersionProp =
141142 ( (DllName: ' libpython2.3.so' ; RegVersion: ' 2.3' ; APIVersion: 1012 ; CanUseLatest: True),
142143 (DllName: ' libpython2.4.so' ; RegVersion: ' 2.4' ; APIVersion: 1012 ; CanUseLatest: True),
143144 (DllName: ' libpython2.5.so' ; RegVersion: ' 2.5' ; APIVersion: 1013 ; CanUseLatest: True),
144145 (DllName: ' libpython2.6.so' ; RegVersion: ' 2.6' ; APIVersion: 1013 ; CanUseLatest: True),
145146 (DllName: ' libpython2.7.so' ; RegVersion: ' 2.7' ; APIVersion: 1013 ; CanUseLatest: True),
146147 (DllName: ' libpython3.0.so' ; RegVersion: ' 3.0' ; APIVersion: 1013 ; CanUseLatest: True),
147148 (DllName: ' libpython3.1.so' ; RegVersion: ' 3.1' ; APIVersion: 1013 ; CanUseLatest: True),
148- (DllName: ' libpython3.2.so' ; RegVersion: ' 3.2' ; APIVersion: 1013 ; CanUseLatest: True) );
149+ (DllName: ' libpython3.2.so' ; RegVersion: ' 3.2' ; APIVersion: 1013 ; CanUseLatest: True),
150+ (DllName: ' libpython3.3.so' ; RegVersion: ' 3.3' ; APIVersion: 1013 ; CanUseLatest: True) );
149151{ $ENDIF}
150152{ $IFDEF PYTHON23}
151153 COMPILED_FOR_PYTHON_VERSION_INDEX = 1 ;
@@ -171,6 +173,9 @@ interface
171173{ $IFDEF PYTHON32}
172174 COMPILED_FOR_PYTHON_VERSION_INDEX = 8 ;
173175{ $ENDIF}
176+ { $IFDEF PYTHON33}
177+ COMPILED_FOR_PYTHON_VERSION_INDEX = 9 ;
178+ { $ENDIF}
174179
175180 PYT_METHOD_BUFFER_INCREASE = 10 ;
176181 PYT_MEMBER_BUFFER_INCREASE = 10 ;
@@ -1504,6 +1509,8 @@ TPythonInterface=class(TDynamicDll)
15041509 FInitialized: Boolean;
15051510 FFinalizing: Boolean;
15061511 FIsPython3000: Boolean;
1512+ FMajorVersion: integer;
1513+ FMinorVersion: integer;
15071514 FBuiltInModuleName: String;
15081515 function GetInitialized : Boolean;
15091516
@@ -2050,6 +2057,8 @@ TPythonInterface=class(TDynamicDll)
20502057 property Initialized : Boolean read GetInitialized;
20512058 property Finalizing : Boolean read FFinalizing;
20522059 property IsPython3000 : Boolean read FIsPython3000;
2060+ property MajorVersion : integer read FMajorVersion;
2061+ property MinorVersion : integer read FMinorVersion;
20532062 property BuiltInModuleName: String read FBuiltInModuleName write FBuiltInModuleName;
20542063
20552064end ;
@@ -3478,6 +3487,10 @@ procedure TPythonInterface.AfterLoad;
34783487begin
34793488 inherited ;
34803489 FIsPython3000 := Pos(' PYTHON3' , UpperCase(DLLName)) = 1 ;
3490+ FMajorVersion := StrToInt(DLLName[7 { $IFDEF LINUX} +3 { $ENDIF} ]);
3491+ FMinorVersion := StrToInt(DLLName[8 { $IFDEF LINUX} +3 { $ENDIF} ]);
3492+
3493+
34813494 if FIsPython3000 then
34823495 FBuiltInModuleName := ' builtins'
34833496 else
@@ -3520,7 +3533,9 @@ procedure TPythonInterface.CheckPython;
35203533
35213534function TPythonInterface.GetUnicodeTypeSuffix : String;
35223535begin
3523- if APIVersion >= 1011 then
3536+ if (fMajorVersion > 3 ) or ((fMajorVersion = 3 ) and (fMinorVersion >= 3 )) then
3537+ Result := ' '
3538+ else if APIVersion >= 1011 then
35243539 Result := ' UCS2'
35253540 else
35263541 Result := ' ' ;
@@ -3538,9 +3553,9 @@ procedure TPythonInterface.MapDll;
35383553 if not IsPython3000 then begin
35393554 Py_TabcheckFlag := Import (' Py_TabcheckFlag' );
35403555 Py_UnicodeFlag := Import (' Py_UnicodeFlag' );
3556+ Py_DivisionWarningFlag := Import (' Py_DivisionWarningFlag' );
35413557 end ;
35423558 Py_IgnoreEnvironmentFlag := Import (' Py_IgnoreEnvironmentFlag' );
3543- Py_DivisionWarningFlag := Import (' Py_DivisionWarningFlag' );
35443559
35453560 // _PySys_TraceFunc := Import('_PySys_TraceFunc');
35463561 // _PySys_ProfileFunc := Import('_PySys_ProfileFunc');
@@ -4670,7 +4685,8 @@ procedure TPythonEngine.AssignPyFlags;
46704685 SetFlag(Py_TabcheckFlag, pfTabcheck in FPyFlags);
46714686 end ;
46724687 SetFlag(Py_IgnoreEnvironmentFlag, pfIgnoreEnvironmentFlag in FPyFlags);
4673- SetFlag(Py_DivisionWarningFlag, pfDivisionWarningFlag in FPyFlags);
4688+ if Assigned(Py_DivisionWarningFlag) then
4689+ SetFlag(Py_DivisionWarningFlag, pfDivisionWarningFlag in FPyFlags);
46744690end ;
46754691
46764692procedure TPythonEngine.Initialize ;
0 commit comments