Skip to content

Commit

Permalink
fix stackoverflow when dump
Browse files Browse the repository at this point in the history
  • Loading branch information
codeskyblue committed Aug 8, 2024
1 parent 5f3f142 commit d632014
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion uiautomator2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ def screenshot(self, filename: Optional[str] = None, format="pillow", display_id
return
return image_convert(pil_img, format)

def dump_hierarchy(self, compressed=False, pretty=False, max_depth: int = None) -> str:
def dump_hierarchy(self, compressed=False, pretty=False, max_depth: Optional[int] = None) -> str:
"""
Dump window hierarchy
Expand All @@ -275,6 +275,8 @@ def dump_hierarchy(self, compressed=False, pretty=False, max_depth: int = None)
xml content
"""
try:
if max_depth is None:
max_depth = self.settings['max_depth']

Check warning on line 279 in uiautomator2/__init__.py

View check run for this annotation

Codecov / codecov/patch

uiautomator2/__init__.py#L279

Added line #L279 was not covered by tests
content = self._do_dump_hierarchy(compressed, max_depth)
except HierarchyEmptyError: # pragma: no cover
logger.warning("dump empty, return empty xml")
Expand Down
2 changes: 1 addition & 1 deletion uiautomator2/assets/sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -e

APK_VERSION=$(cat ../version.py| grep apk_version | awk '{print $NF}')
APK_VERSION=${APK_VERSION//[\"\']}
JAR_VERSION="0.1.0"
JAR_VERSION="0.1.2"

cd "$(dirname $0)"

Expand Down
1 change: 1 addition & 0 deletions uiautomator2/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def __init__(self, d):
"operation_delay": (0, 0),
"operation_delay_methods": ["click", "swipe"],
"fallback_to_blank_screenshot": False,
"max_depth": 50,
}

self._deprecated_props = {
Expand Down

0 comments on commit d632014

Please sign in to comment.