summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBert JW Regeer <bertjw@regeer.org>2020-05-06 23:11:22 -0700
committerBert JW Regeer <bertjw@regeer.org>2020-11-28 12:19:54 -0800
commit9113a725c0440f9f07ea01a891599d4ae7b89027 (patch)
tree94fc1c3237ac3140ce50c85b4723904d84896ddc
parentd6d46e6e908d56d4864c6ae8cb9690817f4df007 (diff)
downloadwebob-9113a725c0440f9f07ea01a891599d4ae7b89027.tar.gz
Catch/raise OSError instead of IOError
-rw-r--r--src/webob/static.py6
-rw-r--r--tests/test_in_wsgiref.py2
-rw-r--r--tests/test_request.py2
-rw-r--r--tests/test_static.py2
4 files changed, 6 insertions, 6 deletions
diff --git a/src/webob/static.py b/src/webob/static.py
index 27f1324..508d2a5 100644
--- a/src/webob/static.py
+++ b/src/webob/static.py
@@ -38,13 +38,13 @@ class FileApp:
return exc.HTTPMethodNotAllowed("You cannot %s a file" % req.method)
try:
stat = os.stat(self.filename)
- except (IOError, OSError) as e:
+ except OSError as e:
msg = "Can't open %r: %s" % (self.filename, e)
return exc.HTTPNotFound(comment=msg)
try:
file = self._open(self.filename, "rb")
- except (IOError, OSError) as e:
+ except OSError as e:
msg = "You are not permitted to view this file (%s)" % e
return exc.HTTPForbidden(msg)
@@ -123,7 +123,7 @@ class DirectoryApp:
if not self.path.endswith(os.path.sep):
self.path += os.path.sep
if not os.path.isdir(self.path):
- raise IOError("Path does not exist or is not directory: %r" % self.path)
+ raise OSError("Path does not exist or is not directory: %r" % self.path)
self.index_page = index_page
self.hide_index_with_redirect = hide_index_with_redirect
self.fileapp_kw = kw
diff --git a/tests/test_in_wsgiref.py b/tests/test_in_wsgiref.py
index 28f355c..cf8e999 100644
--- a/tests/test_in_wsgiref.py
+++ b/tests/test_in_wsgiref.py
@@ -92,7 +92,7 @@ def _req_int_cgi(req):
def _req_int_readline(req):
try:
assert req.body_file.readline() == b"a=b\n"
- except IOError:
+ except OSError:
# too early to detect disconnect
raise AssertionError("False disconnect alert")
req.body_file.readline()
diff --git a/tests/test_request.py b/tests/test_request.py
index 5cd893a..07bd23c 100644
--- a/tests/test_request.py
+++ b/tests/test_request.py
@@ -3243,7 +3243,7 @@ class UnseekableInput:
class UnseekableInputWithSeek(UnseekableInput):
def seek(self, pos, rel=0):
- raise IOError("Invalid seek!")
+ raise OSError("Invalid seek!")
class _Helper_test_request_wrong_clen:
diff --git a/tests/test_static.py b/tests/test_static.py
index a5d99fb..e136586 100644
--- a/tests/test_static.py
+++ b/tests/test_static.py
@@ -84,7 +84,7 @@ class TestFileApp(unittest.TestCase):
# Mock the built-in ``open()`` function to allow finner control about
# what we are testing.
def open_ioerror(*args, **kwargs):
- raise IOError()
+ raise OSError()
def open_oserror(*args, **kwargs):
raise OSError()