Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3d8936a

Browse files
committed
Fix demo 6 for Python 3
- python code works but remains memory leaks
1 parent 8035a2c commit 3d8936a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

PythonForDelphi/Demos/FPC/Demo06/Unit1.pas

+4-2
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,10 @@ function PyPoint_getattr(obj : PPyObject; key : PAnsiChar) : PPyObject; cdecl;
173173
else
174174
begin
175175
// Else check for a method
176-
Result := Py_FindMethod( MethodsByName('PythonType1'), obj, key);
176+
Result:=PyObject_GenericGetAttr(obj,PyString_FromString('OffsetBy'));
177+
//Result := Py_FindMethod( MethodsByName('PythonType1'), obj, key);
177178
// or we could write, because it's quicker:
178-
// Result := Py_FindMethod( Form1.PythonType1.MethodsData, obj, key);
179+
//Result := Py_FindMethod( Form1.PythonType1.MethodsData, obj, key);
179180
if not Assigned(Result) then
180181
PyErr_SetString (PyExc_AttributeError^, PAnsiChar(Format('Unknown attribute "%s"',[key])));
181182
end;
@@ -261,6 +262,7 @@ procedure TForm1.PythonType1Initialization(Sender: TObject);
261262
TheType := PyType;
262263
// And then add the methods of the object, if needed
263264
AddMethod( 'OffsetBy', PyPoint_OffsetBy , 'OffsetBy(dx, dy)' );
265+
PythonEngine1.PyType_Ready(TheTypePtr);
264266
end;
265267
end;
266268

0 commit comments

Comments
 (0)