summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2021-07-13 10:23:13 +0200
committerFlorian Bruhin <me@the-compiler.org>2021-07-13 10:23:25 +0200
commit0001d4fe20a4cdef9dd628fad220e09a03618932 (patch)
treea1a422f16860e62207b3c489a92ecc6fccd1ce4e
parentb78fc716a9e0cda835edb9b5950f7d75b583a986 (diff)
downloadqutebrowser-0001d4fe20a4cdef9dd628fad220e09a03618932.tar.gz
qutebrowser-0001d4fe20a4cdef9dd628fad220e09a03618932.zip
Handle UnicodeEncodeError in path completion
-rw-r--r--qutebrowser/completion/models/filepathcategory.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/qutebrowser/completion/models/filepathcategory.py b/qutebrowser/completion/models/filepathcategory.py
index ac5dd2278..f9b6608a3 100644
--- a/qutebrowser/completion/models/filepathcategory.py
+++ b/qutebrowser/completion/models/filepathcategory.py
@@ -91,7 +91,13 @@ class FilePathCategory(QAbstractListModel):
for path in self._glob(url_path)
)
else:
- paths = self._glob(os.path.expanduser(val))
+ try:
+ expanded = os.path.expanduser(val)
+ except UnicodeEncodeError:
+ # os.path.expanduser('~\ud800') can raise UnicodeEncodeError
+ # via pwd.getpwnam
+ expanded = val
+ paths = self._glob(expanded)
self._paths = sorted(self._contract_user(val, path) for path in paths)
def data(self, index: QModelIndex, role: int = Qt.DisplayRole) -> Optional[str]: