Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

python: Replace IOError with OSError.

Anders Kaseorg2caeb38e9eab
diff --git a/zerver/decorator.py b/zerver/decorator.py
index d63afbfb78f..b16430316bb 100644
--- a/zerver/decorator.py
+++ b/zerver/decorator.py
@@ -914,7 +914,7 @@ def get_tor_ips() -> Set[str]:
# Circuit-breaking will ensure that we back off on re-reading the
# file.
if len(exit_node_list) == 0:
- raise IOError("File is empty")
+ raise OSError("File is empty")
return set(exit_node_list)
@@ -940,7 +940,7 @@ def rate_limit_request_by_ip(request: HttpRequest, domain: str) -> None:
pass
elif ip_addr in get_tor_ips():
ip_addr = "tor-exit-node"
- except (IOError, CircuitBreakerError) as err:
+ except (OSError, CircuitBreakerError) as err:
# In the event that we can't get an updated list of TOR exit
# nodes, assume the IP is _not_ one, and leave it unchanged.
# We log a warning so that this endpoint being taken out of
diff --git a/zerver/tests/test_push_notifications.py b/zerver/tests/test_push_notifications.py
index 07dfc02b6ca..720752ce884 100644
--- a/zerver/tests/test_push_notifications.py
+++ b/zerver/tests/test_push_notifications.py
@@ -2290,7 +2290,7 @@ class GCMSendTest(PushNotificationTest):
)
def test_json_request_raises_ioerror(self, mock_gcm: mock.MagicMock) -> None:
- mock_gcm.json_request.side_effect = IOError("error")
+ mock_gcm.json_request.side_effect = OSError("error")
with self.assertLogs("zerver.lib.push_notifications", level="WARNING") as logger:
send_android_push_notification_to_user(self.user_profile, {}, {})
self.assertIn(