@@ -129,13 +129,10 @@ interface
129129 end ;
130130const
131131{ $IFDEF MSWINDOWS}
132- PYTHON_KNOWN_VERSIONS: array [1 ..13 ] of TPythonVersionProp =
133- ( (DllName: ' python24.dll' ; RegVersion: ' 2.4' ; APIVersion: 1012 ; CanUseLatest: True),
134- (DllName: ' python25.dll' ; RegVersion: ' 2.5' ; APIVersion: 1013 ; CanUseLatest: True),
132+ PYTHON_KNOWN_VERSIONS: array [1 ..10 ] of TPythonVersionProp =
133+ ( (DllName: ' python25.dll' ; RegVersion: ' 2.5' ; APIVersion: 1013 ; CanUseLatest: True),
135134 (DllName: ' python26.dll' ; RegVersion: ' 2.6' ; APIVersion: 1013 ; CanUseLatest: True),
136135 (DllName: ' python27.dll' ; RegVersion: ' 2.7' ; APIVersion: 1013 ; CanUseLatest: True),
137- (DllName: ' python30.dll' ; RegVersion: ' 3.0' ; APIVersion: 1013 ; CanUseLatest: True),
138- (DllName: ' python31.dll' ; RegVersion: ' 3.1' ; APIVersion: 1013 ; CanUseLatest: True),
139136 (DllName: ' python32.dll' ; RegVersion: ' 3.2' ; APIVersion: 1013 ; CanUseLatest: True),
140137 (DllName: ' python33.dll' ; RegVersion: ' 3.3' ; APIVersion: 1013 ; CanUseLatest: True),
141138 (DllName: ' python34.dll' ; RegVersion: ' 3.4' ; APIVersion: 1013 ; CanUseLatest: True),
@@ -145,13 +142,10 @@ interface
145142 (DllName: ' python38.dll' ; RegVersion: ' 3.8' ; APIVersion: 1013 ; CanUseLatest: True) );
146143{ $ENDIF}
147144{ $IFDEF LINUX}
148- PYTHON_KNOWN_VERSIONS: array [1 ..13 ] of TPythonVersionProp =
149- ( (DllName: ' libpython2.4.so' ; RegVersion: ' 2.4' ; APIVersion: 1012 ; CanUseLatest: True),
150- (DllName: ' libpython2.5.so' ; RegVersion: ' 2.5' ; APIVersion: 1013 ; CanUseLatest: True),
145+ PYTHON_KNOWN_VERSIONS: array [1 ..10 ] of TPythonVersionProp =
146+ ( (DllName: ' libpython2.5.so' ; RegVersion: ' 2.5' ; APIVersion: 1013 ; CanUseLatest: True),
151147 (DllName: ' libpython2.6.so' ; RegVersion: ' 2.6' ; APIVersion: 1013 ; CanUseLatest: True),
152148 (DllName: ' libpython2.7.so' ; RegVersion: ' 2.7' ; APIVersion: 1013 ; CanUseLatest: True),
153- (DllName: ' libpython3.0.so' ; RegVersion: ' 3.0' ; APIVersion: 1013 ; CanUseLatest: True),
154- (DllName: ' libpython3.1.so' ; RegVersion: ' 3.1' ; APIVersion: 1013 ; CanUseLatest: True),
155149 (DllName: ' libpython3.2.so' ; RegVersion: ' 3.2' ; APIVersion: 1013 ; CanUseLatest: True),
156150 (DllName: ' libpython3.3.so' ; RegVersion: ' 3.3' ; APIVersion: 1013 ; CanUseLatest: True),
157151 (DllName: ' libpython3.4.so' ; RegVersion: ' 3.4' ; APIVersion: 1013 ; CanUseLatest: True),
@@ -160,44 +154,35 @@ interface
160154 (DllName: ' libpython3.7.so' ; RegVersion: ' 3.7' ; APIVersion: 1013 ; CanUseLatest: True)
161155 (DllName: ' libpython3.8.so' ; RegVersion: ' 3.8' ; APIVersion: 1013 ; CanUseLatest: True) );
162156{ $ENDIF}
163- { $IFDEF PYTHON24}
164- COMPILED_FOR_PYTHON_VERSION_INDEX = 1 ;
165- { $ENDIF}
166157{ $IFDEF PYTHON25}
167- COMPILED_FOR_PYTHON_VERSION_INDEX = 2 ;
158+ COMPILED_FOR_PYTHON_VERSION_INDEX = 1 ;
168159{ $ENDIF}
169160{ $IFDEF PYTHON26}
170- COMPILED_FOR_PYTHON_VERSION_INDEX = 3 ;
161+ COMPILED_FOR_PYTHON_VERSION_INDEX = 2 ;
171162{ $ENDIF}
172163{ $IFDEF PYTHON27}
173- COMPILED_FOR_PYTHON_VERSION_INDEX = 4 ;
174- { $ENDIF}
175- { $IFDEF PYTHON30}
176- COMPILED_FOR_PYTHON_VERSION_INDEX = 5 ;
177- { $ENDIF}
178- { $IFDEF PYTHON31}
179- COMPILED_FOR_PYTHON_VERSION_INDEX = 6 ;
164+ COMPILED_FOR_PYTHON_VERSION_INDEX = 3 ;
180165{ $ENDIF}
181166{ $IFDEF PYTHON32}
182- COMPILED_FOR_PYTHON_VERSION_INDEX = 7 ;
167+ COMPILED_FOR_PYTHON_VERSION_INDEX = 4 ;
183168{ $ENDIF}
184169{ $IFDEF PYTHON33}
185- COMPILED_FOR_PYTHON_VERSION_INDEX = 8 ;
170+ COMPILED_FOR_PYTHON_VERSION_INDEX = 5 ;
186171{ $ENDIF}
187172{ $IFDEF PYTHON34}
188- COMPILED_FOR_PYTHON_VERSION_INDEX = 9 ;
173+ COMPILED_FOR_PYTHON_VERSION_INDEX = 6 ;
189174{ $ENDIF}
190175{ $IFDEF PYTHON35}
191- COMPILED_FOR_PYTHON_VERSION_INDEX = 10 ;
176+ COMPILED_FOR_PYTHON_VERSION_INDEX = 7 ;
192177{ $ENDIF}
193178{ $IFDEF PYTHON36}
194- COMPILED_FOR_PYTHON_VERSION_INDEX = 11 ;
179+ COMPILED_FOR_PYTHON_VERSION_INDEX = 8 ;
195180{ $ENDIF}
196181{ $IFDEF PYTHON37}
197- COMPILED_FOR_PYTHON_VERSION_INDEX = 12 ;
182+ COMPILED_FOR_PYTHON_VERSION_INDEX = 9 ;
198183{ $ENDIF}
199184{ $IFDEF PYTHON38}
200- COMPILED_FOR_PYTHON_VERSION_INDEX = 13 ;
185+ COMPILED_FOR_PYTHON_VERSION_INDEX = 10 ;
201186{ $ENDIF}
202187 PYT_METHOD_BUFFER_INCREASE = 10 ;
203188 PYT_MEMBER_BUFFER_INCREASE = 10 ;
@@ -1071,6 +1056,11 @@ interface
10711056 n_child : PNode;
10721057 end ;
10731058
1059+ PPyCompilerFlags = ^PyCompilerFlags;
1060+ PyCompilerFlags = { $IFNDEF CPUX64} packed { $ENDIF} record
1061+ flags : integer;
1062+ end ;
1063+
10741064 // From weakrefobject.h
10751065
10761066 PPyWeakReference = ^PyWeakReference;
@@ -1959,7 +1949,8 @@ TPythonInterface=class(TDynamicDll)
19591949 PyThreadState_SetAsyncExc: function(t_id :LongInt; exc :PPyObject) : Integer; cdecl;
19601950 Py_AtExit:function (proc: AtExitProc):integer; cdecl;
19611951 // Py_Cleanup:procedure; cdecl;
1962- Py_CompileString:function (s1,s2:PAnsiChar;i:integer):PPyObject; cdecl;
1952+ Py_CompileStringFlags:function (s1,s2:PAnsiChar;i:integer;flags:PPyCompilerFlags):PPyObject; cdecl;
1953+ Py_CompileStringExFlags:function (s1,s2:PAnsiChar;i:integer;flags:PPyCompilerFlags;optimize:integer):PPyObject; cdecl;
19631954 Py_FatalError:procedure(s:PAnsiChar); cdecl;
19641955 Py_FindMethod:function (md:PPyMethodDef;ob:PPyObject;key:PAnsiChar):PPyObject; cdecl;
19651956 Py_FindMethodInChain:function (mc:PPyMethodChain;ob:PPyObject;key:PAnsiChar):PPyObject; cdecl;
@@ -1980,7 +1971,7 @@ TPythonInterface=class(TDynamicDll)
19801971 Py_GetPrefix : function : PAnsiChar; cdecl;
19811972 Py_GetProgramName : function : PAnsiChar; cdecl;
19821973
1983- PyParser_SimpleParseString : function ( str : PAnsiChar; start : Integer) : PNode; cdecl;
1974+ PyParser_SimpleParseStringFlags : function ( str : PAnsiChar; start, flags : Integer) : PNode; cdecl;
19841975 PyNode_Free : procedure( n : PNode ); cdecl;
19851976 PyErr_NewException : function ( name : PAnsiChar; base, dict : PPyObject ) : PPyObject; cdecl;
19861977 Py_Malloc : function ( size : NativeInt ) : Pointer;
@@ -2071,6 +2062,10 @@ TPythonInterface=class(TDynamicDll)
20712062 _Py_c_quot: Pointer;
20722063 _Py_c_sum: Pointer;
20732064}
2065+ // Not exported in Python 3.8 and implemented as functions
2066+ function PyParser_SimpleParseString ( str : PAnsiChar; start : Integer) : PNode; cdecl;
2067+ function Py_CompileString ( s1,s2:PAnsiChar;i:integer) : PPyObject; cdecl;
2068+
20742069 // functions redefined in Delphi
20752070 procedure Py_INCREF ( op: PPyObject);
20762071 procedure Py_DECREF ( op: PPyObject);
@@ -4047,18 +4042,18 @@ procedure TPythonInterface.MapDll;
40474042 PyThreadState_SetAsyncExc :=Import (' PyThreadState_SetAsyncExc' );
40484043 Py_AtExit :=Import (' Py_AtExit' );
40494044 // Py_Cleanup :=Import('Py_Cleanup');
4050- Py_CompileString :=Import (' Py_CompileString' );
40514045 Py_FatalError :=Import (' Py_FatalError' );
40524046 if not IsPython3000 then begin
4053- Py_FindMethod :=Import (' Py_FindMethod' );
4054- Py_FindMethodInChain :=Import (' Py_FindMethodInChain' );
4047+ Py_FindMethod :=Import (' Py_FindMethod' );
4048+ Py_FindMethodInChain :=Import (' Py_FindMethodInChain' );
40554049 DLL_Py_FlushLine :=Import (' Py_FlushLine' );
4050+ _PyString_Resize :=Import (' _PyString_Resize' );
4051+ Py_CompileStringFlags :=Import (' Py_CompileStringFlags' );
4052+ end else begin
4053+ _PyString_Resize :=Import (' _PyBytes_Resize' );
4054+ Py_CompileStringExFlags :=Import (' Py_CompileStringExFlags' );
40564055 end ;
4057- _PyObject_New :=Import (' _PyObject_New' );
4058- if not IsPython3000 then
4059- _PyString_Resize :=Import (' _PyString_Resize' )
4060- else
4061- _PyString_Resize :=Import (' _PyBytes_Resize' );
4056+ _PyObject_New :=Import (' _PyObject_New' );
40624057 Py_Finalize :=Import (' Py_Finalize' );
40634058 if getProcAddress( FDLLHandle, ' PyCode_Addr2Line' ) <> nil then
40644059 DLL_PyCode_Addr2Line := Import (' PyCode_Addr2Line' );
@@ -4082,7 +4077,7 @@ procedure TPythonInterface.MapDll;
40824077 Py_GetPythonHome :=Import (' Py_GetPythonHome' );
40834078 Py_GetPrefix :=Import (' Py_GetPrefix' );
40844079 Py_GetProgramName :=Import (' Py_GetProgramName' );
4085- PyParser_SimpleParseString :=Import (' PyParser_SimpleParseString ' );
4080+ PyParser_SimpleParseStringFlags := Import (' PyParser_SimpleParseStringFlags ' );
40864081 PyNode_Free :=Import (' PyNode_Free' );
40874082 PyErr_NewException :=Import (' PyErr_NewException' );
40884083// / jah 29-sep-2000 : updated for python 2.0
@@ -4121,6 +4116,19 @@ procedure TPythonInterface.MapDll;
41214116 PyGILState_Release := Import (' PyGILState_Release' );
41224117end ;
41234118
4119+ function TPythonInterface.Py_CompileString ( s1,s2:PAnsiChar;i:integer):PPyObject; cdecl;
4120+ begin
4121+ if IsPython3000 then
4122+ Result := Py_CompileStringExFlags(s1, s2, i, nil , -1 )
4123+ else
4124+ Result := Py_CompileStringFlags(s1, s2, i, nil );
4125+ end ;
4126+
4127+ function TPythonInterface.PyParser_SimpleParseString ( str : PAnsiChar; start : integer) : PNode; cdecl;
4128+ begin
4129+ Result := PyParser_SimpleParseStringFlags(str, start, 0 );
4130+ end ;
4131+
41244132procedure TPythonInterface.Py_INCREF (op: PPyObject);
41254133begin
41264134 Inc(op^.ob_refcnt);
0 commit comments