From: Josh Soref <2119212+jsoref@users.noreply.github.com> Date: Thu, 13 Nov 2025 14:11:43 +0000 (-0500) Subject: Do not catch KeyboardInterrupt or SystemExit X-Git-Tag: rec-5.4.0-alpha1~88^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=db08a9369c65ab5f0541d8d6e3a7bcba22e14a46;p=thirdparty%2Fpdns.git Do not catch KeyboardInterrupt or SystemExit Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com> --- diff --git a/.github/scripts/clang-tidy-diff.py b/.github/scripts/clang-tidy-diff.py index 1d93fd226c..c4f6fdb6dd 100755 --- a/.github/scripts/clang-tidy-diff.py +++ b/.github/scripts/clang-tidy-diff.py @@ -270,7 +270,7 @@ def main(): print('Writing fixes to ' + args.export_fixes + ' ...') try: merge_replacement_files(tmpdir, args.export_fixes) - except: + except Exception: sys.stderr.write('Error exporting fixes.\n') traceback.print_exc() diff --git a/contrib/ProtobufLogger.py b/contrib/ProtobufLogger.py index 965d328e43..04101adcf8 100644 --- a/contrib/ProtobufLogger.py +++ b/contrib/ProtobufLogger.py @@ -27,7 +27,7 @@ try: import google.protobuf.json_format import opentelemetry.proto.trace.v1.trace_pb2 opentelemetryAvailable = True -except: +except Exception: opentelemetryAvailable = False diff --git a/regression-tests.api/test_helper.py b/regression-tests.api/test_helper.py index 62651b8a2f..4b412468b6 100644 --- a/regression-tests.api/test_helper.py +++ b/regression-tests.api/test_helper.py @@ -48,7 +48,7 @@ class ApiTestCase(unittest.TestCase): def assert_success_json(self, result): try: result.raise_for_status() - except: + except Exception: print(result.content) raise self.assertEqual(result.headers['Content-Type'], 'application/json') @@ -60,7 +60,7 @@ class ApiTestCase(unittest.TestCase): def assert_success(self, result): try: result.raise_for_status() - except: + except Exception: print(result.content) raise diff --git a/regression-tests.auth-py/test_ProxyProtocol.py b/regression-tests.auth-py/test_ProxyProtocol.py index 8a03ab4844..be625878d2 100644 --- a/regression-tests.auth-py/test_ProxyProtocol.py +++ b/regression-tests.auth-py/test_ProxyProtocol.py @@ -130,7 +130,7 @@ secondary def generateAuthZone(cls, confdir, zonename, zonecontent): try: os.unlink(os.path.join(confdir, '%s.zone' % zonename)) - except: + except Exception: pass @classmethod diff --git a/regression-tests.dnsdist/test_DOH.py b/regression-tests.dnsdist/test_DOH.py index c1017c526d..da02f03605 100644 --- a/regression-tests.dnsdist/test_DOH.py +++ b/regression-tests.dnsdist/test_DOH.py @@ -377,7 +377,7 @@ class DOHTests(object): conn.send('AAAA') response = conn.recv(65535) self.assertFalse(response) - except: + except Exception: pass metricMap = { @@ -1659,7 +1659,7 @@ class DOHFrontendLimits(object): if self._dohLibrary != 'h2o': alpn.append('h2') conns.append(self.openTLSConnection(self._dohServerPort, self._serverName, self._caCert, alpn=alpn)) - except: + except Exception: conns.append(None) count = 0 @@ -1676,7 +1676,7 @@ class DOHFrontendLimits(object): count = count + 1 else: failed = failed + 1 - except: + except Exception: failed = failed + 1 for conn in conns: @@ -1868,7 +1868,7 @@ class DOHLimits(object): conn.perform_rb() conn.getinfo(pycurl.RESPONSE_CODE) count = count + 1 - except: + except Exception: failed = failed + 1 for conn in conns: diff --git a/regression-tests.dnsdist/test_ProxyProtocol.py b/regression-tests.dnsdist/test_ProxyProtocol.py index b01dacf551..823ba48563 100644 --- a/regression-tests.dnsdist/test_ProxyProtocol.py +++ b/regression-tests.dnsdist/test_ProxyProtocol.py @@ -113,7 +113,7 @@ def MockTCPReverseProxyAddingProxyProtocol(listeningPort, forwardingPort, server break except socket.timeout: break - except: + except Exception: break incoming.close() diff --git a/regression-tests.dnsdist/test_TCPKeepAlive.py b/regression-tests.dnsdist/test_TCPKeepAlive.py index a3ca2f7c85..1f47b72b34 100644 --- a/regression-tests.dnsdist/test_TCPKeepAlive.py +++ b/regression-tests.dnsdist/test_TCPKeepAlive.py @@ -60,7 +60,7 @@ class TestTCPKeepAlive(DNSDistTest): break self.assertEqual(expectedResponse, response) count = count + 1 - except: + except Exception: pass conn.close() @@ -99,7 +99,7 @@ class TestTCPKeepAlive(DNSDistTest): break self.assertEqual(expectedResponse, response) count = count + 1 - except: + except Exception: pass conn.close() @@ -129,7 +129,7 @@ class TestTCPKeepAlive(DNSDistTest): break self.assertEqual(expectedResponse, response) count = count + 1 - except: + except Exception: pass conn.close() @@ -153,7 +153,7 @@ class TestTCPKeepAlive(DNSDistTest): if response is None: break count = count + 1 - except: + except Exception: pass conn.close() @@ -177,7 +177,7 @@ class TestTCPKeepAlive(DNSDistTest): if response is None: break count = count + 1 - except: + except Exception: pass conn.close() @@ -200,7 +200,7 @@ class TestTCPKeepAlive(DNSDistTest): if response is None: break count = count + 1 - except: + except Exception: pass conn.close() @@ -240,7 +240,7 @@ class TestTCPKeepAlive(DNSDistTest): break self.assertEqual(expectedResponse, response) count = count + 1 - except: + except Exception: pass for con in conns: @@ -292,7 +292,7 @@ class TestTCPKeepAliveNoDownstreamDrop(DNSDistTest): if response is None: break count = count + 1 - except: + except Exception: pass conn.close() diff --git a/regression-tests.dnsdist/test_TCPLimits.py b/regression-tests.dnsdist/test_TCPLimits.py index 974a4f1081..f0c081ac58 100644 --- a/regression-tests.dnsdist/test_TCPLimits.py +++ b/regression-tests.dnsdist/test_TCPLimits.py @@ -50,7 +50,7 @@ class TestTCPLimits(DNSDistTest): response = self.recvTCPResponseOverConnection(conn) self.assertTrue(response) count = count + 1 - except: + except Exception: pass # this one should fail @@ -63,7 +63,7 @@ class TestTCPLimits(DNSDistTest): failed = True else: count = count + 1 - except: + except Exception: failed = True conn.close() @@ -91,7 +91,7 @@ class TestTCPLimits(DNSDistTest): count = count + 1 else: failed = failed + 1 - except: + except Exception: failed = failed + 1 for conn in conns: @@ -172,7 +172,7 @@ class TestTCPLimitsReadIO(DNSDistTest): conn.send(payload[count].to_bytes()) count = count + 1 time.sleep(0.001) - except: + except Exception: failed = True break @@ -181,7 +181,7 @@ class TestTCPLimitsReadIO(DNSDistTest): response = self.recvTCPResponseOverConnection(conn) if not response: failed = True - except: + except Exception: failed = True conn.close() @@ -194,7 +194,7 @@ class TestTCPLimitsReadIO(DNSDistTest): response = self.recvTCPResponseOverConnection(conn) if response is None: failed = True - except: + except Exception: failed = True finally: conn.close() @@ -391,7 +391,7 @@ class TestTCPFrontendLimits(DNSDistTest): count = count + 1 else: failed = failed + 1 - except: + except Exception: failed = failed + 1 for conn in conns: diff --git a/regression-tests.dnsdist/test_TLS.py b/regression-tests.dnsdist/test_TLS.py index 56f801252d..714ba8df4d 100644 --- a/regression-tests.dnsdist/test_TLS.py +++ b/regression-tests.dnsdist/test_TLS.py @@ -476,7 +476,7 @@ class TestTLSFrontendLimits(DNSDistTest): for idx in range(self._maxTCPConnsPerTLSFrontend + 1): try: conns.append(self.openTLSConnection(self._tlsServerPort, self._serverName, self._caCert)) - except: + except Exception: conns.append(None) count = 0 @@ -493,7 +493,7 @@ class TestTLSFrontendLimits(DNSDistTest): count = count + 1 else: failed = failed + 1 - except: + except Exception: failed = failed + 1 for conn in conns: diff --git a/regression-tests.recursor-dnssec/recursortests.py b/regression-tests.recursor-dnssec/recursortests.py index 689be83739..e195fc1485 100644 --- a/regression-tests.recursor-dnssec/recursortests.py +++ b/regression-tests.recursor-dnssec/recursortests.py @@ -31,7 +31,7 @@ def have_ipv6(): sock.bind(('::1', 56581)) sock.close() return True - except: + except Exception: return False diff --git a/regression-tests.recursor-dnssec/test_RecDnstap.py b/regression-tests.recursor-dnssec/test_RecDnstap.py index 138aa8ec99..ab01a83798 100644 --- a/regression-tests.recursor-dnssec/test_RecDnstap.py +++ b/regression-tests.recursor-dnssec/test_RecDnstap.py @@ -203,7 +203,7 @@ class TestRecursorDNSTap(RecursorTest): try: try: os.remove(param.path) - except: + except Exception: pass sock.bind(param.path) sock.listen(100) @@ -278,7 +278,7 @@ cname 3600 IN CNAME a.example. def getFirstDnstap(self): try: data = DNSTapServerParameters.queue.get(True, timeout=2.0) - except: + except Exception: data = False self.assertTrue(data) dnstap = dnstap_pb2.Dnstap()