Skip to content

Commit 3708875

Browse files
committed
Compatibility with Python 3.9
1 parent 38d3e62 commit 3708875

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

PythonForDelphi/Components/Sources/Core/PythonEngine.pas

+9-8
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ TPythonVersionProp = record
113113
end;
114114
const
115115
{$IFDEF MSWINDOWS}
116-
PYTHON_KNOWN_VERSIONS: array[1..8] of TPythonVersionProp =
116+
PYTHON_KNOWN_VERSIONS: array[1..9] of TPythonVersionProp =
117117
(
118118
(DllName: 'python27.dll'; RegVersion: '2.7'; APIVersion: 1013),
119119
(DllName: 'python32.dll'; RegVersion: '3.2'; APIVersion: 1013),
@@ -122,11 +122,12 @@ TPythonVersionProp = record
122122
(DllName: 'python35.dll'; RegVersion: '3.5'; APIVersion: 1013),
123123
(DllName: 'python36.dll'; RegVersion: '3.6'; APIVersion: 1013),
124124
(DllName: 'python37.dll'; RegVersion: '3.7'; APIVersion: 1013),
125-
(DllName: 'python38.dll'; RegVersion: '3.8'; APIVersion: 1013)
125+
(DllName: 'python38.dll'; RegVersion: '3.8'; APIVersion: 1013),
126+
(DllName: 'python39.dll'; RegVersion: '3.9'; APIVersion: 1013)
126127
);
127128
{$ENDIF}
128129
{$IFDEF _so_files}
129-
PYTHON_KNOWN_VERSIONS: array[1..8] of TPythonVersionProp =
130+
PYTHON_KNOWN_VERSIONS: array[1..9] of TPythonVersionProp =
130131
(
131132
(DllName: 'libpython2.7.so'; RegVersion: '2.7'; APIVersion: 1013),
132133
(DllName: 'libpython3.2m.so'; RegVersion: '3.2'; APIVersion: 1013),
@@ -135,11 +136,12 @@ TPythonVersionProp = record
135136
(DllName: 'libpython3.5m.so'; RegVersion: '3.5'; APIVersion: 1013),
136137
(DllName: 'libpython3.6m.so'; RegVersion: '3.6'; APIVersion: 1013),
137138
(DllName: 'libpython3.7m.so'; RegVersion: '3.7'; APIVersion: 1013),
138-
(DllName: 'libpython3.8m.so'; RegVersion: '3.8'; APIVersion: 1013)
139+
(DllName: 'libpython3.8m.so'; RegVersion: '3.8'; APIVersion: 1013),
140+
(DllName: 'libpython3.9m.so'; RegVersion: '3.9'; APIVersion: 1013)
139141
);
140142
{$ENDIF}
141143
{$IFDEF DARWIN}
142-
PYTHON_KNOWN_VERSIONS: array[1..8] of TPythonVersionProp =
144+
PYTHON_KNOWN_VERSIONS: array[1..9] of TPythonVersionProp =
143145
(
144146
(DllName: 'libpython2.7.dylib'; RegVersion: '2.7'; APIVersion: 1013),
145147
(DllName: 'libpython3.2.dylib'; RegVersion: '3.2'; APIVersion: 1013),
@@ -148,7 +150,8 @@ TPythonVersionProp = record
148150
(DllName: 'libpython3.5.dylib'; RegVersion: '3.5'; APIVersion: 1013),
149151
(DllName: 'libpython3.6.dylib'; RegVersion: '3.6'; APIVersion: 1013),
150152
(DllName: 'libpython3.7.dylib'; RegVersion: '3.7'; APIVersion: 1013),
151-
(DllName: 'libpython3.8.dylib'; RegVersion: '3.8'; APIVersion: 1013)
153+
(DllName: 'libpython3.8.dylib'; RegVersion: '3.8'; APIVersion: 1013),
154+
(DllName: 'libpython3.9.dylib'; RegVersion: '3.9'; APIVersion: 1013)
152155
);
153156
{$endif}
154157

@@ -1732,7 +1735,6 @@ TPythonInterface=class(TDynamicDll)
17321735
PyFunction_GetGlobals:function (ob:PPyObject):PPyObject; cdecl;
17331736
PyFunction_New:function (ob1,ob2:PPyObject):PPyObject; cdecl;
17341737
PyImport_AddModule:function (name:PAnsiChar):PPyObject; cdecl;
1735-
PyImport_Cleanup:procedure; cdecl;
17361738
PyImport_GetMagicNumber:function :LongInt; cdecl;
17371739
PyImport_ImportFrozenModule:function (key:PAnsiChar):integer; cdecl;
17381740
PyImport_ImportModule:function (name:PAnsiChar):PPyObject; cdecl;
@@ -3822,7 +3824,6 @@ procedure TPythonInterface.MapDll;
38223824
PyFunction_GetGlobals :=Import('PyFunction_GetGlobals');
38233825
PyFunction_New :=Import('PyFunction_New');
38243826
PyImport_AddModule :=Import('PyImport_AddModule');
3825-
PyImport_Cleanup :=Import('PyImport_Cleanup');
38263827
PyImport_GetMagicNumber :=Import('PyImport_GetMagicNumber');
38273828
PyImport_ImportFrozenModule:=Import('PyImport_ImportFrozenModule');
38283829
PyImport_ImportModule :=Import('PyImport_ImportModule');

PythonForDelphi/Components/Sources/Core/UnitTests/VarPythTest.pas

+1
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ procedure TTestVarPyth.TestObjects;
392392
Assert.IsTrue( VarIsPythonModule(_main) );
393393
Assert.IsTrue( VarIsPythonModule(SysModule) );
394394
Assert.IsTrue( Import('sys').version = SysModule.version );
395+
Log(SysModule.version);
395396
Assert.IsTrue( Boolean(SysModule.modules.Contains(GetPythonEngine.ExecModule)) ); // if __main__ in sys.modules
396397
Assert.IsTrue( VarIsSameType(_main, SysModule) );
397398
Assert.IsTrue( _type(_main).__name__ = 'module');

0 commit comments

Comments
 (0)