@@ -540,9 +540,9 @@ TPythonVersionProp = record
540540 sq_concat : binaryfunc;
541541 sq_repeat : ssizeargfunc;
542542 sq_item : ssizeargfunc;
543- sq_slice : ssizessizeargfunc;
543+ sq_slice : ssizessizeargfunc; // empty slot in python 3.x
544544 sq_ass_item : ssizeobjargproc;
545- sq_ass_slice : ssizessizeobjargproc;
545+ sq_ass_slice : ssizessizeobjargproc; // empty slot in python 3.x
546546 sq_contains : objobjproc;
547547 sq_inplace_concat : binaryfunc;
548548 sq_inplace_repeat : ssizeargfunc;
@@ -556,6 +556,8 @@ TPythonVersionProp = record
556556 end ;
557557 PPyMappingMethods = ^PyMappingMethods;
558558
559+ // PyBufferProcs has changed drastiacally in Python 3.0 but since
560+ // it is currently not implemented it does not matter
559561 PyBufferProcs = { $IFNDEF CPUX64} packed { $ENDIF} record
560562 bf_getreadbuffer : getreadbufferproc;
561563 bf_getwritebuffer : getwritebufferproc;
@@ -804,7 +806,7 @@ TPythonVersionProp = record
804806 tp_subclasses : PPyObject;
805807 tp_weaklist : PPyObject;
806808 tp_del : PyDestructor;
807- tp_version_tag : NativeUInt ; // Type attribute cache version tag. Added in version 2.6
809+ tp_version_tag : Cardinal ; // Type attribute cache version tag. Added in version 2.6
808810 tp_finalize : PyDestructor;
809811 // More spares
810812 tp_xxx1 : NativeInt;
@@ -1786,8 +1788,8 @@ TPythonInterface=class(TDynamicDll)
17861788 PyLong_FromDouble:function (db:double):PPyObject; cdecl;
17871789 PyLong_FromLong:function (l:LongInt):PPyObject; cdecl;
17881790 PyLong_FromString:function (pc:PAnsiChar;var ppc:PAnsiChar;i:integer):PPyObject; cdecl;
1789- PyLong_FromUnsignedLong:function(val:cardinal ) : PPyObject; cdecl;
1790- PyLong_AsUnsignedLong:function(ob:PPyObject) : Cardinal ; cdecl;
1791+ PyLong_FromUnsignedLong:function(val:LongWord ) : PPyObject; cdecl;
1792+ PyLong_AsUnsignedLong:function(ob:PPyObject) : LongWord ; cdecl;
17911793 PyLong_FromUnicode:function(ob:PPyObject; a, b : integer) : PPyObject; cdecl;
17921794 PyLong_FromLongLong:function(val:Int64) : PPyObject; cdecl;
17931795 PyLong_AsLongLong:function(ob:PPyObject) : Int64; cdecl;
@@ -2822,7 +2824,7 @@ TPyObject = class
28222824 end ;
28232825 TPyObjectClass = class of TPyObject;
28242826
2825- TBasicServices = set of (bsPrint, bsGetAttr, bsSetAttr,
2827+ TBasicServices = set of (bsGetAttr, bsSetAttr,
28262828 bsRepr, bsCompare, bsHash,
28272829 bsStr, bsGetAttrO, bsSetAttrO,
28282830 bsCall,
@@ -8769,6 +8771,7 @@ function TPythonType_SqInplaceRepeat(pSelf : PPyObject; i: NativeInt): PPyObject
87698771end ;
87708772
87718773procedure TPythonType.InitServices ;
8774+ { Called from TPythonType.Initialize which first calls CheckEngine - FEngine is alread assigned }
87728775begin
87738776 with FType do
87748777 begin
@@ -8788,7 +8791,7 @@ procedure TPythonType.InitServices;
87888791 tp_repr := TPythonType_Repr;
87898792 if bsStr in Services.Basic then
87908793 tp_str := TPythonType_Str;
8791- if bsCompare in Services.Basic then
8794+ if ( bsCompare in Services.Basic) and not FEngine.IsPython3000 then
87928795 tp_compare := TPythonType_Compare;
87938796 if bsHash in Services.Basic then
87948797 tp_hash := TPythonType_Hash;
@@ -8822,7 +8825,7 @@ procedure TPythonType.InitServices;
88228825 // Number services
88238826 if Services.Number <> [] then
88248827 begin
8825- if GetPythonEngine .IsPython3000 then
8828+ if FEngine .IsPython3000 then
88268829 begin
88278830 FNumber := AllocMem(SizeOf(PyNumberMethods300)); // zeroes memory
88288831 with PPyNumberMethods300(FNumber)^ do
@@ -8833,8 +8836,8 @@ procedure TPythonType.InitServices;
88338836 if nsDivide in Services.Number then ; // gone in Python 3.x
88348837 if nsFloorDivide in Services.Number then nb_floor_divide := TPythonType_NbFloorDivide; // #3.30
88358838 if nsTrueDivide in Services.Number then nb_true_divide := TPythonType_NbTrueDivide; // #3.31
8836- if (nsMatrixMultiply in Services.Number) and ((GetPythonEngine .MajorVersion > 3 )
8837- or ((GetPythonEngine .MajorVersion = 3 ) and (GetPythonEngine .MinorVersion >= 5 )))
8839+ if (nsMatrixMultiply in Services.Number) and ((FEngine .MajorVersion > 3 )
8840+ or ((FEngine .MajorVersion = 3 ) and (FEngine .MinorVersion >= 5 )))
88388841 then
88398842 nb_matrix_multiply := TPythonType_NbMatrixMultiply; // #3.35
88408843 if nsRemainder in Services.Number then nb_remainder := TPythonType_NbRemainder; // #3.4
@@ -8871,8 +8874,8 @@ procedure TPythonType.InitServices;
88718874 if nsInplaceXor in Services.InplaceNumber then nb_inplace_xor := TPythonType_NbInplaceXor; // #3.28
88728875 if nsInplaceOr in Services.InplaceNumber then nb_inplace_or := TPythonType_NbInplaceOr; // #3.29
88738876 if (nsInplaceMatrixMultiply in Services.InplaceNumber) and
8874- ((GetPythonEngine .MajorVersion > 3 ) or ((GetPythonEngine .MajorVersion = 3 )
8875- and (GetPythonEngine .MinorVersion >= 5 )))
8877+ ((FEngine .MajorVersion > 3 ) or ((FEngine .MajorVersion = 3 )
8878+ and (FEngine .MinorVersion >= 5 )))
88768879 then
88778880 nb_inplace_matrix_multiply := TPythonType_NbInplaceMatrixMultiply; // #3.36
88788881 end ;
@@ -9749,9 +9752,8 @@ function GetPythonEngine : TPythonEngine;
97499752begin
97509753 if not Assigned( gPythonEngine ) then
97519754 raise Exception.Create( ' No Python engine was created' );
9752- if not gPythonEngine.Finalizing then
9753- if not gPythonEngine.Initialized then
9754- raise Exception.Create( ' The Python engine is not properly initialized' );
9755+ if not gPythonEngine.Finalizing and not gPythonEngine.Initialized then
9756+ raise Exception.Create( ' The Python engine is not properly initialized' );
97559757 Result := gPythonEngine;
97569758end ;
97579759
0 commit comments