[pyatspi2] getPath: bail out if we don't find the root accessible
- From: Mike Gorse <mgorse src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pyatspi2] getPath: bail out if we don't find the root accessible
- Date: Tue, 9 Mar 2021 23:08:32 +0000 (UTC)
commit 42d0534204933529fc374f461b4483eb36db3b6f
Author: Mike Gorse <mgorse suse com>
Date: Tue Mar 9 17:09:26 2021 -0600
getPath: bail out if we don't find the root accessible
In theory, we should always be able to reach the root accessible by querying
an object's parent, querying that object's parent, and so on. Nevertheless,
we want to be sure we don't hang, so bail out if this fails within a
reasonable number of attempts.
Fixes #6
pyatspi/utils.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
---
diff --git a/pyatspi/utils.py b/pyatspi/utils.py
index da1f3fc..3bf185c 100644
--- a/pyatspi/utils.py
+++ b/pyatspi/utils.py
@@ -319,7 +319,8 @@ def getPath(acc):
@raise LookupError: When the application accessible cannot be reached
"""
path = []
- while 1:
+ tries = 0
+ while tries < 100:
if acc.parent is None:
path.reverse()
return path
@@ -328,6 +329,8 @@ def getPath(acc):
except Exception:
raise LookupError
acc = acc.parent
+ tries = tries + 1
+ raise LookupError
def pointToList(point):
return (point.x, point.y)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]