dogtail-devel [Bug 508352] New: findChildren in tree.py needs a 'if children' check



If you have any questions why you received this email, please see the text at
the end of this email. Replies to this email are NOT read, please see the text
at the end of this email. You can add comments to this bug at:
  http://bugzilla.gnome.org/show_bug.cgi?id=508352

  dogtail | Framework | Ver: 0.6.1
           Summary: findChildren in tree.py needs a 'if children' check
           Product: dogtail
           Version: 0.6.1
          Platform: Other
        OS/Version: All
            Status: UNCONFIRMED
          Severity: normal
          Priority: Normal
         Component: Framework
        AssignedTo: dogtail-maint gnome bugs
        ReportedBy: anand harihara gmail com
         QAContact: dogtail-maint gnome bugs
     GNOME version: Unspecified
   GNOME milestone: Unspecified


Please describe the problem:
In findChildren, when children is None then we get TypeError. 
This is manifested in case of HyperLinks (directly?) under the node.

I am using python-dogtail 0.6.1-3ubuntu2 on ubuntu gutsy.


Steps to reproduce:
1.Open firefox and then any page with hyperlinks.
2.  Run the following in script or python prompt :

from dogtail import *

print
tree.root.findChild(predicate.GenericPredicate(roleName='menu',name='Applications')).findChildren(predicate.GenericPredicate(roleName='menu
item'))

print tree.root.findChildren(predicate.GenericPredicate(roleName='menu'))



Actual results:
The first call works.
The second one gives "TypeError: 'NoneType' object is not iterable"

Expected results:
The check given below solves the issue, 

>>        if children :
            for child in children:
                if child.satisfies(pred): selfList.append(child)
                if recursive:
             ...

I am not sure if it's the best approach or whether we should cover it in
getattr in Node class. As this problem seems to have slipped through somehow it
would be better to put in a check anycase.

(Also, see  "# Somehow, if we allow the children to be seen, things get weird."
comment in class Link)

Does this happen every time?
Yes

Other information:
A similar check might be required in dump.py.

However even in this case when I do a tree.root.dump() even with the 'if
node.children' check introduced in function 'plain', I get the following :

  File "pyspi.pyx", line 1006, in atspi.Hyperlink.getObject
  File "pyspi.pyx", line 245, in atspi.Base.__checkSelf

wrt above, I saw that only the Base class has as assertion, the others here
raise an AttributeError. Should it be changed ?


-- 
See http://bugzilla.gnome.org/page.cgi?id=email.html for more info about why you received
this email, why you can't respond via email, how to stop receiving
emails (or reduce the number you receive), and how to contact someone
if you are having problems with the system.

You can add comments to this bug at http://bugzilla.gnome.org/show_bug.cgi?id=508352.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]