Fix handling of missing QtWebEngine resources

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.
This commit is contained in:
Florian Bruhin 2024-05-10 18:41:50 +02:00
parent 81de20d78b
commit a7a7c434e2
3 changed files with 6 additions and 2 deletions

View File

@ -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)

View File

@ -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]:

View File

@ -177,7 +177,7 @@ class TestFindWebengineResources:
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()