After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 328318 - Nodes without children return an exception when you get children property
Nodes without children return an exception when you get children property
Status: RESOLVED FIXED
Product: dogtail
Classification: Deprecated
Component: Framework
CVS HEAD
Other All
: Normal normal
: ---
Assigned To: Zack Cerza
Dogtail Maintainers
Depends on:
Blocks:
 
 
Reported: 2006-01-23 18:11 UTC by Jose Dapena Paz
Modified: 2006-04-13 14:26 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Jose Dapena Paz 2006-01-23 18:11:39 UTC
Please describe the problem:
Suppose you have a node without children, and you try to get its children, with
a call like "node.children". If this node hasn't got any children, it returns an
AttributeError exception.

The expected behaviour is returning an empty list, I think.

Steps to reproduce:
1. Get a node without children
2. Try to get the property children



Actual results:
You get an AttributeError exception in get_attr.

Expected results:
You should get an empty list.

Does this happen every time?
Yes

Other information:
The problem is in the __get_attr__ method of Node (see tree.py). For the
"children" case, it tries to add the children to the list. If the list remains
empty  (as in the case it's empty), it raises the exception, when it should
return the empty list.
Comment 1 Zack Cerza 2006-01-24 17:42:43 UTC
Thanks for reporting this. The current behavior is longstanding, but has annoyed me for a while. I've been wanting to change it (and will, now that i know someone else is bothered by it), but it will mean substantial changes to code that depends on that behavior. It will probably have to wait until after 0.5.0.
Comment 2 Zack Cerza 2006-04-13 14:26:07 UTC
I've just committed a large patch to remove dogtail.tree's use of AttributeErrors in cases where the attribute exists, but doesn't apply to that particular Node instance. A node with no children will have an empty list as that attribute, and a node with no AccessibleText interface will have None as its text attribute.