@@ -1901,7 +1901,6 @@ TPythonInterface=class(TDynamicDll)
1901
1901
_PyString_Resize:function (var ob:PPyObject;i:NativeInt):integer; cdecl;
1902
1902
Py_GetExecPrefixA : function : PAnsiChar; cdecl;
1903
1903
Py_GetPathA : function : PAnsiChar; cdecl;
1904
- Py_SetPathA : procedure (path : PAnsiChar); cdecl;
1905
1904
Py_SetPythonHomeA : procedure (home : PAnsiChar); cdecl;
1906
1905
Py_GetPythonHomeA : function : PAnsiChar; cdecl;
1907
1906
Py_GetPrefixA : function : PAnsiChar; cdecl;
@@ -4265,16 +4264,17 @@ procedure TPythonInterface.MapDll;
4265
4264
PyRange_Type := Import (' PyRange_Type' );
4266
4265
PySlice_Type := Import (' PySlice_Type' );
4267
4266
if not IsPython3000 then
4268
- PyString_Type := Import (' PyString_Type' )
4269
- else
4270
- PyString_Type := Import (' PyBytes_Type' );
4271
- PyBytes_Type := Import (' PyBytes_Type' );
4272
- PyByteArray_Type := Import (' PyByteArray_Type' );
4267
+ PyString_Type := Import (' PyString_Type' );
4268
+
4269
+ if IsPython3000 then begin
4270
+ PyBytes_Type := Import (' PyBytes_Type' );
4271
+ PyByteArray_Type := Import (' PyByteArray_Type' );
4272
+ end ;
4273
4273
PyTuple_Type := Import (' PyTuple_Type' );
4274
4274
PyUnicode_Type := Import (' PyUnicode_Type' );
4275
4275
PyBaseObject_Type := Import (' PyBaseObject_Type' );
4276
4276
if not IsPython3000 then
4277
- PyBuffer_Type := Import (' PyBuffer_Type' );
4277
+ PyBuffer_Type := Import (' PyBuffer_Type' );
4278
4278
PyCallIter_Type := Import (' PyCallIter_Type' );
4279
4279
PyCell_Type := Import (' PyCell_Type' );
4280
4280
PyClassMethod_Type := Import (' PyClassMethod_Type' );
@@ -4342,9 +4342,7 @@ procedure TPythonInterface.MapDll;
4342
4342
PyErr_WarnExplicit := Import (' PyErr_WarnExplicit' );
4343
4343
PyEval_GetBuiltins := Import (' PyEval_GetBuiltins' );
4344
4344
PyImport_GetModuleDict := Import (' PyImport_GetModuleDict' );
4345
- if IsPython3000 then
4346
- PyInt_FromLong := Import (' PyLong_FromLong' )
4347
- else
4345
+ if not IsPython3000 then
4348
4346
PyInt_FromLong := Import (' PyInt_FromLong' );
4349
4347
PyArg_Parse := Import (' PyArg_Parse' );
4350
4348
PyArg_ParseTuple := Import (' PyArg_ParseTuple' );
@@ -4356,23 +4354,24 @@ procedure TPythonInterface.MapDll;
4356
4354
PyRun_String := Import (' PyRun_String' );
4357
4355
PyRun_SimpleString := Import (' PyRun_SimpleString' );
4358
4356
PyDict_GetItemString := Import (' PyDict_GetItemString' );
4359
- PySys_SetArgv := Import (' PySys_SetArgv' );
4357
+
4358
+ if IsPython3000 then
4359
+ PySys_SetArgv := Import (' PySys_SetArgv' )
4360
+ else
4361
+ PySys_SetArgvA := Import (' PySys_SetArgv' );
4360
4362
4361
4363
if not IsPython3000 then begin
4362
4364
PyString_AsString := Import (' PyString_AsString' );
4363
4365
PyString_AsStringAndSize := Import (' PyString_AsStringAndSize' )
4364
- end else begin
4365
- PyString_AsString := Import (' PyBytes_AsString' );
4366
- PyString_AsStringAndSize := Import (' PyBytes_AsStringAndSize' );
4367
4366
end ;
4368
4367
4369
4368
if not IsPython3000 then
4370
4369
DLL_PyString_FromString := Import (' PyString_FromString' );
4371
4370
4372
- Py_Exit := Import (' Py_Exit' );
4371
+ Py_Exit := Import (' Py_Exit' );
4373
4372
4374
4373
if IsPython3000 then
4375
- PyCFunction_NewEx :=Import (' PyCFunction_NewEx' )
4374
+ PyCFunction_NewEx :=Import (' PyCFunction_NewEx' )
4376
4375
else
4377
4376
PyCFunction_New :=Import (' PyCFunction_New' );
4378
4377
@@ -4382,19 +4381,19 @@ procedure TPythonInterface.MapDll;
4382
4381
PyEval_GetLocals := Import (' PyEval_GetLocals' );
4383
4382
// @PyEval_GetOwner :=Import('PyEval_GetOwner');
4384
4383
if not IsPython3000 then
4385
- PyEval_GetRestricted := Import (' PyEval_GetRestricted' );
4384
+ PyEval_GetRestricted := Import (' PyEval_GetRestricted' );
4386
4385
PyEval_InitThreads := Import (' PyEval_InitThreads' );
4387
4386
PyEval_RestoreThread := Import (' PyEval_RestoreThread' );
4388
4387
PyEval_SaveThread := Import (' PyEval_SaveThread' );
4389
4388
if not IsPython3000 then
4390
- PyFile_FromString := Import (' PyFile_FromString' );
4389
+ PyFile_FromString := Import (' PyFile_FromString' );
4391
4390
PyFile_GetLine := Import (' PyFile_GetLine' );
4392
4391
if not IsPython3000 then
4393
- PyFile_Name := Import (' PyFile_Name' );
4392
+ PyFile_Name := Import (' PyFile_Name' );
4394
4393
if not IsPython3000 then
4395
- PyFile_SetBufSize := Import (' PyFile_SetBufSize' );
4394
+ PyFile_SetBufSize := Import (' PyFile_SetBufSize' );
4396
4395
if not IsPython3000 then
4397
- PyFile_SoftSpace := Import (' PyFile_SoftSpace' );
4396
+ PyFile_SoftSpace := Import (' PyFile_SoftSpace' );
4398
4397
PyFile_WriteObject := Import (' PyFile_WriteObject' );
4399
4398
PyFile_WriteString := Import (' PyFile_WriteString' );
4400
4399
PyFloat_AsDouble := Import (' PyFloat_AsDouble' );
@@ -4436,8 +4435,10 @@ procedure TPythonInterface.MapDll;
4436
4435
PyLong_FromString := Import (' PyLong_FromString' );
4437
4436
PyLong_FromUnsignedLong := Import (' PyLong_FromUnsignedLong' );
4438
4437
PyLong_AsUnsignedLong := Import (' PyLong_AsUnsignedLong' );
4439
- PyLong_FromUnicode :=Import (' PyLong_FromUnicode' );
4440
- PyLong_FromUnicodeObject := Import (' PyLong_FromUnicodeObject' );
4438
+ if not IsPython3000 then
4439
+ PyLong_FromUnicode := Import (' PyLong_FromUnicode' );
4440
+ if IsPython3000 then
4441
+ PyLong_FromUnicodeObject := Import (' PyLong_FromUnicodeObject' );
4441
4442
PyLong_FromLongLong := Import (' PyLong_FromLongLong' );
4442
4443
PyLong_FromUnsignedLongLong := Import (' PyLong_FromUnsignedLongLong' );
4443
4444
PyLong_AsLongLong := Import (' PyLong_AsLongLong' );
@@ -4448,8 +4449,10 @@ procedure TPythonInterface.MapDll;
4448
4449
PyMapping_HasKeyString := Import (' PyMapping_HasKeyString' );
4449
4450
PyMapping_Length := Import (' PyMapping_Length' );
4450
4451
PyMapping_SetItemString := Import (' PyMapping_SetItemString' );
4451
- PyMapping_Keys := Import (' PyMapping_Keys' );
4452
- PyMapping_Values := Import (' PyMapping_Values' );
4452
+ if IsPython3000 then begin
4453
+ PyMapping_Keys := Import (' PyMapping_Keys' );
4454
+ PyMapping_Values := Import (' PyMapping_Values' );
4455
+ end ;
4453
4456
if not IsPython3000 then
4454
4457
PyMethod_Class :=Import (' PyMethod_Class' );
4455
4458
PyMethod_Function := Import (' PyMethod_Function' );
@@ -4485,12 +4488,13 @@ procedure TPythonInterface.MapDll;
4485
4488
PyNumber_Rshift := Import (' PyNumber_Rshift' );
4486
4489
PyNumber_Subtract := Import (' PyNumber_Subtract' );
4487
4490
PyNumber_Xor := Import (' PyNumber_Xor' );
4488
- PyOS_InitInterrupts :=Import (' PyOS_InitInterrupts' );
4491
+ if not IsPython3000 then
4492
+ PyOS_InitInterrupts :=Import (' PyOS_InitInterrupts' );
4489
4493
PyOS_InterruptOccurred := Import (' PyOS_InterruptOccurred' );
4490
4494
PyObject_CallObject := Import (' PyObject_CallObject' );
4491
4495
PyObject_CallMethod := Import (' PyObject_CallMethod' );
4492
4496
if not IsPython3000 then
4493
- PyObject_Compare :=Import (' PyObject_Compare' );
4497
+ PyObject_Compare :=Import (' PyObject_Compare' );
4494
4498
PyObject_RichCompare := Import (' PyObject_RichCompare' );
4495
4499
PyObject_RichCompareBool := Import (' PyObject_RichCompareBool' );
4496
4500
PyObject_GetAttr := Import (' PyObject_GetAttr' );
@@ -4518,7 +4522,8 @@ procedure TPythonInterface.MapDll;
4518
4522
PyObject_Call := Import (' PyObject_Call' );
4519
4523
PyObject_GenericGetAttr := Import (' PyObject_GenericGetAttr' );
4520
4524
PyObject_GenericSetAttr := Import (' PyObject_GenericSetAttr' );
4521
- PyObject_GC_Malloc :=Import (' _PyObject_GC_Malloc' );
4525
+ if not IsPython3000 then
4526
+ PyObject_GC_Malloc :=Import (' _PyObject_GC_Malloc' );
4522
4527
PyObject_Malloc := Import (' PyObject_Malloc' );
4523
4528
PyObject_GC_New := Import (' _PyObject_GC_New' );
4524
4529
PyObject_GC_NewVar := Import (' _PyObject_GC_NewVar' );
@@ -4554,16 +4559,19 @@ procedure TPythonInterface.MapDll;
4554
4559
PyString_DecodeEscape :=Import (' PyString_DecodeEscape' );
4555
4560
PyString_Repr :=Import (' PyString_Repr' );
4556
4561
end ;
4557
- PyBytes_AsString := Import (' PyBytes_AsString' );
4558
- PyBytes_AsStringAndSize := Import (' PyBytes_AsStringAndSize' );
4559
- PyBytes_Concat := Import (' PyBytes_Concat' );
4560
- PyBytes_ConcatAndDel := Import (' PyBytes_ConcatAndDel' );
4561
- PyBytes_FromString := Import (' PyBytes_FromString' );
4562
- PyBytes_FromStringAndSize := Import (' PyBytes_FromStringAndSize' );
4563
- PyBytes_Size := Import (' PyBytes_Size' );
4564
- PyBytes_DecodeEscape := Import (' PyBytes_DecodeEscape' );
4565
- PyBytes_Repr := Import (' PyBytes_Repr' );
4566
- _PyBytes_Resize := Import (' _PyBytes_Resize' );
4562
+ if IsPython3000 then
4563
+ begin
4564
+ PyBytes_AsString := Import (' PyBytes_AsString' );
4565
+ PyBytes_AsStringAndSize := Import (' PyBytes_AsStringAndSize' );
4566
+ PyBytes_Concat := Import (' PyBytes_Concat' );
4567
+ PyBytes_ConcatAndDel := Import (' PyBytes_ConcatAndDel' );
4568
+ PyBytes_FromString := Import (' PyBytes_FromString' );
4569
+ PyBytes_FromStringAndSize := Import (' PyBytes_FromStringAndSize' );
4570
+ PyBytes_Size := Import (' PyBytes_Size' );
4571
+ PyBytes_DecodeEscape := Import (' PyBytes_DecodeEscape' );
4572
+ PyBytes_Repr := Import (' PyBytes_Repr' );
4573
+ _PyBytes_Resize := Import (' _PyBytes_Resize' );
4574
+ end ;
4567
4575
PyByteArray_AsString := Import (' PyByteArray_AsString' );
4568
4576
PyByteArray_Concat := Import (' PyByteArray_Concat' );
4569
4577
PyByteArray_Resize := Import (' PyByteArray_Resize' );
@@ -4584,56 +4592,49 @@ procedure TPythonInterface.MapDll;
4584
4592
PyType_GenericAlloc := Import (' PyType_GenericAlloc' );
4585
4593
PyType_GenericNew := Import (' PyType_GenericNew' );
4586
4594
PyType_Ready := Import (' PyType_Ready' );
4587
- if not IsPython3000 then begin
4588
- PyUnicode_FromWideChar := Import (AnsiString(Format(' PyUnicode%s_FromWideChar' ,[UnicodeSuffix])));
4589
- PyUnicode_FromString := Import (AnsiString(Format(' PyUnicode%s_FromString' ,[UnicodeSuffix])));
4590
- PyUnicode_FromStringAndSize := Import (AnsiString(Format(' PyUnicode%s_FromStringAndSize' ,[UnicodeSuffix])));
4591
- PyUnicode_AsWideChar := Import (AnsiString(Format(' PyUnicode%s_AsWideChar' ,[UnicodeSuffix])));
4592
- PyUnicode_Decode := Import (AnsiString(Format(' PyUnicode%s_Decode' ,[UnicodeSuffix])));
4593
- PyUnicode_AsEncodedString := Import (AnsiString(Format(' PyUnicode%s_AsEncodedString' ,[UnicodeSuffix])));
4594
- PyUnicode_FromOrdinal := Import (AnsiString(Format(' PyUnicode%s_FromOrdinal' ,[UnicodeSuffix])));
4595
- PyUnicode_GetSize := Import (AnsiString(Format(' PyUnicode%s_GetSize' ,[UnicodeSuffix])));
4596
- end else begin
4597
- PyUnicode_FromWideChar := Import (' PyUnicode_FromWideChar' );
4598
- PyUnicode_FromString := Import (' PyUnicode_FromString' );
4599
- PyUnicode_FromStringAndSize := Import (' PyUnicode_FromStringAndSize' );
4600
- PyUnicode_AsWideChar := Import (' PyUnicode_AsWideChar' );
4601
- PyUnicode_Decode := Import (' PyUnicode_Decode' );
4602
- PyUnicode_AsEncodedString := Import (' PyUnicode_AsEncodedString' );
4603
- PyUnicode_FromOrdinal := Import (' PyUnicode_FromOrdinal' );
4604
- end ;
4605
- PyUnicode_FromKindAndData := Import (' PyUnicode_FromKindAndData' );
4606
- PyUnicode_AsUTF8 := Import (' PyUnicode_AsUTF8' );
4607
- PyUnicode_AsUTF8AndSize := Import (' PyUnicode_AsUTF8AndSize' );
4608
- PyUnicode_DecodeUTF16 := Import (' PyUnicode_DecodeUTF16' );
4609
- PyUnicode_GetLength := Import (' PyUnicode_GetLength' );
4595
+ if not IsPython3000 then
4596
+ PyUnicode_GetSize := Import (AnsiString(Format(' PyUnicode%s_GetSize' ,[UnicodeSuffix])));
4597
+
4598
+ PyUnicode_FromWideChar := Import (AnsiString(Format(' PyUnicode%s_FromWideChar' ,[UnicodeSuffix])));
4599
+ PyUnicode_FromString := Import (AnsiString(Format(' PyUnicode%s_FromString' ,[UnicodeSuffix])));
4600
+ PyUnicode_FromStringAndSize := Import (AnsiString(Format(' PyUnicode%s_FromStringAndSize' ,[UnicodeSuffix])));
4601
+ PyUnicode_AsWideChar := Import (AnsiString(Format(' PyUnicode%s_AsWideChar' ,[UnicodeSuffix])));
4602
+ PyUnicode_Decode := Import (AnsiString(Format(' PyUnicode%s_Decode' ,[UnicodeSuffix])));
4603
+ PyUnicode_AsEncodedString := Import (AnsiString(Format(' PyUnicode%s_AsEncodedString' ,[UnicodeSuffix])));
4604
+ PyUnicode_FromOrdinal := Import (AnsiString(Format(' PyUnicode%s_FromOrdinal' ,[UnicodeSuffix])));
4605
+
4606
+ if IsPython3000 then begin
4607
+ PyUnicode_FromKindAndData := Import (' PyUnicode_FromKindAndData' );
4608
+ PyUnicode_AsUTF8 := Import (' PyUnicode_AsUTF8' );
4609
+ PyUnicode_AsUTF8AndSize := Import (' PyUnicode_AsUTF8AndSize' );
4610
+ PyUnicode_DecodeUTF16 := Import (' PyUnicode_DecodeUTF16' );
4611
+ PyUnicode_GetLength := Import (' PyUnicode_GetLength' );
4612
+ end ;
4613
+
4610
4614
PyWeakref_GetObject := Import (' PyWeakref_GetObject' );
4611
4615
PyWeakref_NewProxy := Import (' PyWeakref_NewProxy' );
4612
4616
PyWeakref_NewRef := Import (' PyWeakref_NewRef' );
4613
4617
PyWrapper_New := Import (' PyWrapper_New' );
4614
4618
PyBool_FromLong := Import (' PyBool_FromLong' );
4615
4619
PyThreadState_SetAsyncExc := Import (' PyThreadState_SetAsyncExc' );
4616
4620
Py_AtExit := Import (' Py_AtExit' );
4617
- // Py_Cleanup :=Import('Py_Cleanup');
4621
+ // Py_Cleanup := Import('Py_Cleanup');
4618
4622
Py_FatalError := Import (' Py_FatalError' );
4619
4623
if not IsPython3000 then begin
4620
- Py_FindMethod :=Import (' Py_FindMethod' );
4621
- Py_FindMethodInChain :=Import (' Py_FindMethodInChain' );
4622
- DLL_Py_FlushLine :=Import (' Py_FlushLine' );
4623
- _PyString_Resize :=Import (' _PyString_Resize' );
4624
- Py_CompileStringFlags :=Import (' Py_CompileStringFlags' );
4624
+ Py_FindMethod := Import (' Py_FindMethod' );
4625
+ Py_FindMethodInChain := Import (' Py_FindMethodInChain' );
4626
+ DLL_Py_FlushLine := Import (' Py_FlushLine' );
4627
+ _PyString_Resize := Import (' _PyString_Resize' );
4628
+ Py_CompileStringFlags := Import (' Py_CompileStringFlags' );
4625
4629
end else begin
4626
- _PyString_Resize :=Import (' _PyBytes_Resize' );
4627
- Py_CompileStringExFlags :=Import (' Py_CompileStringExFlags' );
4630
+ _PyString_Resize := Import (' _PyBytes_Resize' );
4631
+ Py_CompileStringExFlags := Import (' Py_CompileStringExFlags' );
4628
4632
end ;
4629
4633
_PyObject_New := Import (' _PyObject_New' );
4630
4634
Py_Finalize := Import (' Py_Finalize' );
4631
4635
4632
- if getProcAddress( FDLLHandle, ' PyCode_Addr2Line' ) <> nil then
4633
- DLL_PyCode_Addr2Line := Import (' PyCode_Addr2Line' );
4634
-
4635
- if getProcAddress( FDLLHandle, ' PyImport_ExecCodeModule' ) <> nil then
4636
- DLL_PyImport_ExecCodeModule := Import (' PyImport_ExecCodeModule' );
4636
+ DLL_PyCode_Addr2Line := Import (' PyCode_Addr2Line' , false);
4637
+ DLL_PyImport_ExecCodeModule := Import (' PyImport_ExecCodeModule' , false);
4637
4638
// @PyClass_IsSubclass :=Import('PyClass_IsSubclass');
4638
4639
4639
4640
PyErr_ExceptionMatches := Import (' PyErr_ExceptionMatches' );
@@ -4644,9 +4645,7 @@ procedure TPythonInterface.MapDll;
4644
4645
Py_GetExecPrefix := Import (' Py_GetExecPrefix' );
4645
4646
4646
4647
if IsPython3000 then
4647
- Py_SetPath := Import (' Py_SetPath' )
4648
- else
4649
- Py_SetPathA := Import (' Py_SetPath' );
4648
+ Py_SetPath := Import (' Py_SetPath' );
4650
4649
4651
4650
if IsPython3000 then
4652
4651
Py_GetPath := Import (' Py_GetPath' )
@@ -4690,8 +4689,7 @@ procedure TPythonInterface.MapDll;
4690
4689
Py_IsInitialized := Import (' Py_IsInitialized' );
4691
4690
Py_GetProgramFullPath := Import (' Py_GetProgramFullPath' );
4692
4691
4693
- if getProcAddress( FDLLHandle, ' Py_GetBuildInfo' ) <> nil then
4694
- DLL_Py_GetBuildInfo := Import (' Py_GetBuildInfo' );
4692
+ DLL_Py_GetBuildInfo := Import (' Py_GetBuildInfo' , false);
4695
4693
4696
4694
Py_NewInterpreter := Import (' Py_NewInterpreter' );
4697
4695
Py_EndInterpreter := Import (' Py_EndInterpreter' );
0 commit comments