View Issue Details
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0002417||FreeCAD||Bug||public||2016-01-23 13:27||2016-01-31 13:00|
|Target Version||Fixed in Version||0.16|
|Summary||0002417: console autocomplete runs python properties|
|Description||The FreeCAD console executes the properties of an object on autocomplete.|
|Steps To Reproduce||run this macro:|
Gui.object = a()
and in console type:
this will trigger the properties.
|Tags||No tags attached.|
The same also happens with old-style classes:
The commit 0f858f99 fixes this part of the problem. Instances of old-style classes can be easily identified by checking for PyInstance_Type. Then its type object (PyClass_Type) can be used to get all its attributes.
However, I didn't find a way to identify instances or the types of new-style classes.
Then, a "module" is also a new style class and to get all its attributes I must query the instance of the module and not its type object.
Any idea how to solve this?
I found a solution. To test for new-style classes the tp_flags is set to Py_TPFLAGS_HEAPTYPE and additionally I check that it's an instance of 'PyBaseObject_Type' (which corresponds to 'object' in Python).
And the hasattr/getattr access has been replaced with a call of Py_CompileString & PyEval_EvalCode because otherwise a property is triggered twice.
But note, when you enter 'Gui.object.test1.' into the console then test1 will be executed. I have tested this with the IDLE editor and this shows the same behaviour.
|2016-01-23 13:27||looo||New Issue|
|2016-01-31 01:28||wmayer||Changeset attached||=> FreeCAD Master master 0f858f99|
|2016-01-31 09:50||wmayer||Note Added: 0006778|
|2016-01-31 12:54||wmayer||Changeset attached||=> FreeCAD Master master a3bf5421|
|2016-01-31 12:54||wmayer||Assigned To||=> wmayer|
|2016-01-31 12:54||wmayer||Status||new => closed|
|2016-01-31 12:54||wmayer||Resolution||open => fixed|
|2016-01-31 13:00||wmayer||Note Added: 0006779|
|2016-01-31 13:00||wmayer||Fixed in Version||=> 0.16|