Skip to content

Commit da1179c

Browse files
committed
pyscripter#52 Py_FindMethod not available in Python 3.x
1 parent 31b244b commit da1179c

File tree

4 files changed

+3
-18
lines changed

4 files changed

+3
-18
lines changed

PythonForDelphi/Components/Sources/Core/PythonEngine.pas

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7800,15 +7800,6 @@ function TPyObject.GetAttr(key : PAnsiChar) : PPyObject;
78007800
finally
78017801
Py_XDecRef(PyKey);
78027802
end;
7803-
7804-
// // check for a method
7805-
// if IsPython3000 then
7806-
// // I think Python 3000 from beta 2 gets the methods from the tp_methods field
7807-
// Result := nil
7808-
// else
7809-
// Result := Py_FindMethod( PythonType.MethodsData, GetSelf, key);
7810-
// if not Assigned(Result) then
7811-
// PyErr_SetString (PyExc_AttributeError^, PAnsiChar(Format('Unknown attribute "%s"',[key])));
78127803
end;
78137804
end;
78147805

PythonForDelphi/Demos/Demo06/Unit1.pas

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,7 @@ function PyPoint_getattr(obj : PPyObject; key : PAnsiChar) : PPyObject; cdecl;
170170
else
171171
begin
172172
// Else check for a method
173-
Result := Py_FindMethod( MethodsByName('PythonType1'), obj, key);
174-
// or we could write, because it's quicker:
175-
// Result := Py_FindMethod( Form1.PythonType1.MethodsData, obj, key);
173+
Result := PyObject_GenericGetAttr(obj, PyString_FromString(key));
176174
if not Assigned(Result) then
177175
PyErr_SetString (PyExc_AttributeError^, PAnsiChar(Format('Unknown attribute "%s"',[key])));
178176
end;

PythonForDelphi/Demos/Demo07/Unit1.pas

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,7 @@ function PyPoint_getattr(obj : PPyObject; key : PAnsiChar) : PPyObject; cdecl;
208208
else
209209
begin
210210
// Else check for a method
211-
Result := Py_FindMethod( MethodsByName('PythonType1'), obj, key);
212-
// or we could write, because it's quicker:
213-
// Result := Py_FindMethod( Form1.PythonType1.MethodsData, obj, key);
211+
Result := PyObject_GenericGetAttr(obj, PyString_FromString(key));
214212
if not Assigned(Result) then
215213
PyErr_SetString (PyExc_AttributeError^, PAnsiChar(Format('Unknown attribute "%s"',[key])));
216214
end;

PythonForDelphi/Demos/FPC/Demo06/Unit1.pas

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,7 @@ 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);
177-
// or we could write, because it's quicker:
178-
// Result := Py_FindMethod( Form1.PythonType1.MethodsData, obj, key);
176+
Result := PyObject_GenericGetAttr(obj, PyString_FromString(key));
179177
if not Assigned(Result) then
180178
PyErr_SetString (PyExc_AttributeError^, PAnsiChar(Format('Unknown attribute "%s"',[key])));
181179
end;

0 commit comments

Comments
 (0)