Skip to content

Commit

Permalink
Fix handling of missing QtWebEngine resources
Browse files Browse the repository at this point in the history
I was getting crash reports from someone about this. Not sure what's going wrong
there (hence the additional information in the exception).

What's clear however is that we're raising ParseError, but only handling that
when actually parsing. The code calling copy_/_find_webengine_resources only
handles OSError. So let's raise a FileNotFoundError instead.
  • Loading branch information
The-Compiler committed May 10, 2024
1 parent 81de20d commit a7a7c43
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions doc/changelog.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ Fixed
bug.
- Trying to use qutebrowser after it's been deleted/moved on disk (e.g. after a
Python upgrade) should now not crash anymore.
- When the QtWebEngine resources dir couldn't be found, qutebrowser now doesn't
crash anymore (but QtWebEngine still might).
[[v3.1.1]]
v3.1.1 (unreleased)
Expand Down
4 changes: 3 additions & 1 deletion qutebrowser/misc/pakjoy.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,9 @@ def _find_webengine_resources() -> pathlib.Path:
if (candidate / PAK_FILENAME).exists():
return candidate

raise binparsing.ParseError("Couldn't find webengine resources dir")
candidates_str = "\n".join(f" {p}" for p in candidates)
raise FileNotFoundError(
f"Couldn't find webengine resources dir, candidates:\n{candidates_str}")


def copy_webengine_resources() -> Optional[pathlib.Path]:
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/misc/test_pakjoy.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def test_fallback_path(self, fallback_path: pathlib.Path):
def test_nowhere(self, fallback_path: pathlib.Path):
"""Test we raise if we can't find the resources."""
with pytest.raises(
binparsing.ParseError, match="Couldn't find webengine resources dir"
FileNotFoundError, match="Couldn't find webengine resources dir, candidates:\n*"
):
pakjoy._find_webengine_resources()

Expand Down

0 comments on commit a7a7c43

Please sign in to comment.