@@ -540,9 +540,9 @@ TPythonVersionProp = record
540
540
sq_concat : binaryfunc;
541
541
sq_repeat : ssizeargfunc;
542
542
sq_item : ssizeargfunc;
543
- sq_slice : ssizessizeargfunc;
543
+ sq_slice : ssizessizeargfunc; // empty slot in python 3.x
544
544
sq_ass_item : ssizeobjargproc;
545
- sq_ass_slice : ssizessizeobjargproc;
545
+ sq_ass_slice : ssizessizeobjargproc; // empty slot in python 3.x
546
546
sq_contains : objobjproc;
547
547
sq_inplace_concat : binaryfunc;
548
548
sq_inplace_repeat : ssizeargfunc;
@@ -556,6 +556,8 @@ TPythonVersionProp = record
556
556
end ;
557
557
PPyMappingMethods = ^PyMappingMethods;
558
558
559
+ // PyBufferProcs has changed drastiacally in Python 3.0 but since
560
+ // it is currently not implemented it does not matter
559
561
PyBufferProcs = { $IFNDEF CPUX64} packed { $ENDIF} record
560
562
bf_getreadbuffer : getreadbufferproc;
561
563
bf_getwritebuffer : getwritebufferproc;
@@ -804,7 +806,7 @@ TPythonVersionProp = record
804
806
tp_subclasses : PPyObject;
805
807
tp_weaklist : PPyObject;
806
808
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
808
810
tp_finalize : PyDestructor;
809
811
// More spares
810
812
tp_xxx1 : NativeInt;
@@ -1786,8 +1788,8 @@ TPythonInterface=class(TDynamicDll)
1786
1788
PyLong_FromDouble:function (db:double):PPyObject; cdecl;
1787
1789
PyLong_FromLong:function (l:LongInt):PPyObject; cdecl;
1788
1790
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;
1791
1793
PyLong_FromUnicode:function(ob:PPyObject; a, b : integer) : PPyObject; cdecl;
1792
1794
PyLong_FromLongLong:function(val:Int64) : PPyObject; cdecl;
1793
1795
PyLong_AsLongLong:function(ob:PPyObject) : Int64; cdecl;
@@ -2822,7 +2824,7 @@ TPyObject = class
2822
2824
end ;
2823
2825
TPyObjectClass = class of TPyObject;
2824
2826
2825
- TBasicServices = set of (bsPrint, bsGetAttr, bsSetAttr,
2827
+ TBasicServices = set of (bsGetAttr, bsSetAttr,
2826
2828
bsRepr, bsCompare, bsHash,
2827
2829
bsStr, bsGetAttrO, bsSetAttrO,
2828
2830
bsCall,
@@ -8769,6 +8771,7 @@ function TPythonType_SqInplaceRepeat(pSelf : PPyObject; i: NativeInt): PPyObject
8769
8771
end ;
8770
8772
8771
8773
procedure TPythonType.InitServices ;
8774
+ { Called from TPythonType.Initialize which first calls CheckEngine - FEngine is alread assigned }
8772
8775
begin
8773
8776
with FType do
8774
8777
begin
@@ -8788,7 +8791,7 @@ procedure TPythonType.InitServices;
8788
8791
tp_repr := TPythonType_Repr;
8789
8792
if bsStr in Services.Basic then
8790
8793
tp_str := TPythonType_Str;
8791
- if bsCompare in Services.Basic then
8794
+ if ( bsCompare in Services.Basic) and not FEngine.IsPython3000 then
8792
8795
tp_compare := TPythonType_Compare;
8793
8796
if bsHash in Services.Basic then
8794
8797
tp_hash := TPythonType_Hash;
@@ -8822,7 +8825,7 @@ procedure TPythonType.InitServices;
8822
8825
// Number services
8823
8826
if Services.Number <> [] then
8824
8827
begin
8825
- if GetPythonEngine .IsPython3000 then
8828
+ if FEngine .IsPython3000 then
8826
8829
begin
8827
8830
FNumber := AllocMem(SizeOf(PyNumberMethods300)); // zeroes memory
8828
8831
with PPyNumberMethods300(FNumber)^ do
@@ -8833,8 +8836,8 @@ procedure TPythonType.InitServices;
8833
8836
if nsDivide in Services.Number then ; // gone in Python 3.x
8834
8837
if nsFloorDivide in Services.Number then nb_floor_divide := TPythonType_NbFloorDivide; // #3.30
8835
8838
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 )))
8838
8841
then
8839
8842
nb_matrix_multiply := TPythonType_NbMatrixMultiply; // #3.35
8840
8843
if nsRemainder in Services.Number then nb_remainder := TPythonType_NbRemainder; // #3.4
@@ -8871,8 +8874,8 @@ procedure TPythonType.InitServices;
8871
8874
if nsInplaceXor in Services.InplaceNumber then nb_inplace_xor := TPythonType_NbInplaceXor; // #3.28
8872
8875
if nsInplaceOr in Services.InplaceNumber then nb_inplace_or := TPythonType_NbInplaceOr; // #3.29
8873
8876
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 )))
8876
8879
then
8877
8880
nb_inplace_matrix_multiply := TPythonType_NbInplaceMatrixMultiply; // #3.36
8878
8881
end ;
@@ -9749,9 +9752,8 @@ function GetPythonEngine : TPythonEngine;
9749
9752
begin
9750
9753
if not Assigned( gPythonEngine ) then
9751
9754
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' );
9755
9757
Result := gPythonEngine;
9756
9758
end ;
9757
9759
0 commit comments