summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2021-01-26 17:27:46 +0100
committerFlorian Bruhin <me@the-compiler.org>2021-01-26 17:49:39 +0100
commit7576dc2719a65c72319d6e453372632e2729e907 (patch)
tree71383d071c3b6b7d5f1734dc991338aab59edadd
parenta5063283dee2da81c44e440d308e078242412f49 (diff)
downloadqutebrowser-7576dc2719a65c72319d6e453372632e2729e907.tar.gz
qutebrowser-7576dc2719a65c72319d6e453372632e2729e907.zip
Get rid of IOError
It's an alias to OSError since Python 3.3: https://docs.python.org/3/library/exceptions.html https://www.python.org/dev/peps/pep-3151/
-rw-r--r--qutebrowser/browser/hints.py2
-rw-r--r--qutebrowser/misc/lineparser.py6
-rw-r--r--scripts/dev/misc_checks.py4
-rw-r--r--tests/unit/misc/test_lineparser.py4
4 files changed, 10 insertions, 6 deletions
diff --git a/qutebrowser/browser/hints.py b/qutebrowser/browser/hints.py
index 4bf093646..f94e28157 100644
--- a/qutebrowser/browser/hints.py
+++ b/qutebrowser/browser/hints.py
@@ -1071,7 +1071,7 @@ class WordHinter:
hints.discard(word[:i + 1])
hints.add(word)
self.words.update(hints)
- except IOError as e:
+ except OSError as e:
error = "Word hints requires reading the file at {}: {}"
raise HintingError(error.format(dictionary, str(e)))
diff --git a/qutebrowser/misc/lineparser.py b/qutebrowser/misc/lineparser.py
index 60da6b895..9d35692e9 100644
--- a/qutebrowser/misc/lineparser.py
+++ b/qutebrowser/misc/lineparser.py
@@ -88,14 +88,14 @@ class BaseLineParser(QObject):
mode: The mode to use ('a'/'r'/'w')
Raises:
- IOError: if the file is already open
+ OSError: if the file is already open
Yields:
a file object for the config file
"""
assert self._configfile is not None
if self._opened:
- raise IOError("Refusing to double-open LineParser.")
+ raise OSError("Refusing to double-open LineParser.")
self._opened = True
try:
if self._binary:
@@ -172,7 +172,7 @@ class LineParser(BaseLineParser):
def save(self):
"""Save the config file."""
if self._opened:
- raise IOError("Refusing to double-open LineParser.")
+ raise OSError("Refusing to double-open LineParser.")
do_save = self._prepare_save()
if not do_save:
return
diff --git a/scripts/dev/misc_checks.py b/scripts/dev/misc_checks.py
index ae766c878..1d6c3155e 100644
--- a/scripts/dev/misc_checks.py
+++ b/scripts/dev/misc_checks.py
@@ -222,6 +222,10 @@ def check_spelling(args: argparse.Namespace) -> Optional[bool]:
re.compile(r'http://www\.gnu\.org/licenses/'),
"use https:// URL.",
),
+ (
+ re.compile(r'IOError'),
+ "use OSError",
+ ),
]
# Files which should be ignored, e.g. because they come from another
diff --git a/tests/unit/misc/test_lineparser.py b/tests/unit/misc/test_lineparser.py
index b254ee222..0384d3498 100644
--- a/tests/unit/misc/test_lineparser.py
+++ b/tests/unit/misc/test_lineparser.py
@@ -48,7 +48,7 @@ class TestBaseLineParser:
mocker.patch('builtins.open', mock.mock_open())
with lineparser._open('r'):
- with pytest.raises(IOError,
+ with pytest.raises(OSError,
match="Refusing to double-open LineParser."):
with lineparser._open('r'):
pass
@@ -106,7 +106,7 @@ class TestLineParser:
def test_double_open(self, lineparser):
"""Test if save() bails on an already open file."""
with lineparser._open('r'):
- with pytest.raises(IOError,
+ with pytest.raises(OSError,
match="Refusing to double-open LineParser."):
lineparser.save()