diff --git a/buildscripts/archive_artifacts.py b/buildscripts/archive_artifacts.py index e3f814591b9f8..b0359c89c47f6 100644 --- a/buildscripts/archive_artifacts.py +++ b/buildscripts/archive_artifacts.py @@ -42,7 +42,7 @@ def create_tarball(output_filename, file_patterns, exclude_patterns): try: from pyzstd import ZstdFile - except: + except Exception: pass print(f"Creating tarball: {output_filename}") diff --git a/buildscripts/bazel_burn_in.py b/buildscripts/bazel_burn_in.py index e935afceabcac..017aae3f171ef 100644 --- a/buildscripts/bazel_burn_in.py +++ b/buildscripts/bazel_burn_in.py @@ -107,7 +107,7 @@ def create_burn_in_target(target_original: str, target_burn_in: str, test: str): # If the label is present, and buildozer fails for another reason, the build # of the burn-in target produces a clear message that it is duplicated. buildozer.bd_remove([target_burn_in], "data", [test_label]) - except: + except Exception: pass buildozer.bd_set([target_burn_in], "srcs", test_label) buildozer.bd_set([target_burn_in], "shard_count", "1") diff --git a/buildscripts/check_for_noexcept.py b/buildscripts/check_for_noexcept.py index 5a3e052e1f423..24a73f8cec642 100644 --- a/buildscripts/check_for_noexcept.py +++ b/buildscripts/check_for_noexcept.py @@ -219,14 +219,14 @@ class Alert: identifier: str | None def get_title(self) -> str: - if self.kind == AlertKind.Noexcept: + if self.kind == AlertKind.Noexcept Exception: return ANNOTATION_TITLE_TEXT_NOEXCEPT_CHANGE else: assert self.kind == AlertKind.NonNoexceptMove return ANNOTATION_TITLE_TEXT_NON_NOEXCEPT_MOVE def get_message(self) -> str: - if self.kind == AlertKind.Noexcept: + if self.kind == AlertKind.Noexcept Exception: return ANNOTATION_MESSAGE_TEXT_NOEXCEPT_CHANGE else: assert self.kind == AlertKind.NonNoexceptMove diff --git a/buildscripts/gdb/wt_dump_table.py b/buildscripts/gdb/wt_dump_table.py index 70440d9979b13..ed46952503605 100644 --- a/buildscripts/gdb/wt_dump_table.py +++ b/buildscripts/gdb/wt_dump_table.py @@ -133,7 +133,7 @@ def dump_update_chain(update_chain): if can_bson: try: obj = bson.decode_all(val_bytes)[0] - except: + except Exception: pass print(" " + "\n ".join(str(wt_val).split("\n")) + " " + str(obj) + " =>") diff --git a/buildscripts/idl/tests/testcase.py b/buildscripts/idl/tests/testcase.py index 4144b6e985bd9..f03d26f6f5415 100644 --- a/buildscripts/idl/tests/testcase.py +++ b/buildscripts/idl/tests/testcase.py @@ -71,7 +71,7 @@ def _parse(self, doc_str, resolver): try: return idl.parser.parse(doc_str, "unknown", resolver) - except: + except Exception: self.fail("Failed to parse document:\n%s" % (doc_str)) def _assert_parse(self, doc_str, parsed_doc): diff --git a/buildscripts/lldb/lldb_printers.py b/buildscripts/lldb/lldb_printers.py index 07ae9ca30c2e5..87ffd6c4b60bc 100644 --- a/buildscripts/lldb/lldb_printers.py +++ b/buildscripts/lldb/lldb_printers.py @@ -346,7 +346,7 @@ def update(self): self.data_type = resolve_type_to_base( self.valobj.GetChildMemberWithName("slots_").GetType() ).GetPointerType() - except: + except Exception: print("Exception: " + str(sys.exc_info())) diff --git a/buildscripts/resmokelib/configure_resmoke.py b/buildscripts/resmokelib/configure_resmoke.py index c05c91d473521..07b7b5b65ad8f 100644 --- a/buildscripts/resmokelib/configure_resmoke.py +++ b/buildscripts/resmokelib/configure_resmoke.py @@ -912,7 +912,7 @@ def get_excluded_mongot_versions(mongot_version): ) except (KeyboardInterrupt, SystemExit): raise - except: + except Exception: # We want this as a catch all exception # If there is some problem setting up metrics we don't want resmoke to fail # We would rather just swallow the error diff --git a/buildscripts/resmokelib/multiversion/multiversion_service.py b/buildscripts/resmokelib/multiversion/multiversion_service.py index ed0fa35f1377a..9863dec121933 100644 --- a/buildscripts/resmokelib/multiversion/multiversion_service.py +++ b/buildscripts/resmokelib/multiversion/multiversion_service.py @@ -169,7 +169,7 @@ def from_yaml_file(cls, yaml_file: str) -> MongoReleases: safe_load_result = yaml.safe_load(yaml_contents) try: return cls(**safe_load_result) - except: + except Exception: LOGGER.info( "MongoReleases.from_yaml_file() failed\n" f"yaml_file = {yaml_file}\n" diff --git a/buildscripts/resmokelib/powercycle/powercycle.py b/buildscripts/resmokelib/powercycle/powercycle.py index faf6f1eb784fa..0946d0dd1902d 100755 --- a/buildscripts/resmokelib/powercycle/powercycle.py +++ b/buildscripts/resmokelib/powercycle/powercycle.py @@ -114,7 +114,7 @@ def exit_handler(): with open(REPORT_JSON_FILE, "w") as jstream: json.dump(REPORT_JSON, jstream) LOGGER.debug("Exit handler: report file contents %s", REPORT_JSON) - except: + except Exception: pass if EXIT_YML_FILE: @@ -123,21 +123,21 @@ def exit_handler(): with open(EXIT_YML_FILE, "w") as yaml_stream: yaml.safe_dump(EXIT_YML, yaml_stream) LOGGER.debug("Exit handler: report file contents %s", EXIT_YML) - except: + except Exception: pass LOGGER.debug("Exit handler: Killing processes") try: Processes.kill_all() LOGGER.debug("Exit handler: Killing processes finished") - except: + except Exception: pass LOGGER.debug("Exit handler: Cleaning up temporary files") try: NamedTempFile.delete_all() LOGGER.debug("Exit handler: Cleaning up temporary files finished") - except: + except Exception: pass diff --git a/buildscripts/resmokelib/run/__init__.py b/buildscripts/resmokelib/run/__init__.py index f6bd7a4842667..84ad3a6db7054 100644 --- a/buildscripts/resmokelib/run/__init__.py +++ b/buildscripts/resmokelib/run/__init__.py @@ -895,7 +895,7 @@ def _execute_suite(self, suite: Suite) -> bool: } ) return True - except: + except Exception: self._exec_logger.exception( "Encountered an error when running %ss of suite %s.", suite.test_kind, diff --git a/buildscripts/resmokelib/symbolizer/__init__.py b/buildscripts/resmokelib/symbolizer/__init__.py index 6f2239740915c..780730975c67f 100644 --- a/buildscripts/resmokelib/symbolizer/__init__.py +++ b/buildscripts/resmokelib/symbolizer/__init__.py @@ -192,7 +192,7 @@ def _setup_symbols(self): self.logger.info("Applying patch diff (if any)...") self._patch_diff_by_id() - except: + except Exception: if self.dest_dir is not None: self.logger.warning( "Removing downloaded directory due to error, directory to be removed: %s", diff --git a/buildscripts/resmokelib/testing/docker_cluster_image_builder.py b/buildscripts/resmokelib/testing/docker_cluster_image_builder.py index 7e660dd168b32..908ab8881cd66 100644 --- a/buildscripts/resmokelib/testing/docker_cluster_image_builder.py +++ b/buildscripts/resmokelib/testing/docker_cluster_image_builder.py @@ -101,7 +101,7 @@ def _get_san_options(self): @staticmethod def get_resmoke_run_command() -> str: """Construct the supported resmoke `run` command to test against an external system under test.""" - # The supported `run` command should keep all of the same args except: + # The supported `run` command should keep all of the same args except Exception: # (1) it should remove the `--dockerComposeBuildImages` option and value # (2) it should add the `--externalSUT` flag command = sys.argv diff --git a/buildscripts/resmokelib/testing/hooks/background_job.py b/buildscripts/resmokelib/testing/hooks/background_job.py index 049ecc09d3f46..65a0191fbc4af 100644 --- a/buildscripts/resmokelib/testing/hooks/background_job.py +++ b/buildscripts/resmokelib/testing/hooks/background_job.py @@ -45,7 +45,7 @@ def run(self): try: self._hook_test_case.run_dynamic_test(self._test_report) - except: + except Exception: self.exc_info = sys.exc_info() finally: with self._lock: diff --git a/buildscripts/resmokelib/testing/hooks/cleanup.py b/buildscripts/resmokelib/testing/hooks/cleanup.py index f35d53c5802f0..dd1cd0d36f98e 100644 --- a/buildscripts/resmokelib/testing/hooks/cleanup.py +++ b/buildscripts/resmokelib/testing/hooks/cleanup.py @@ -97,6 +97,6 @@ def run_test(self): self.logger.info("Starting the fixture back up again...") self.fixture.setup() self.fixture.await_ready() - except: + except Exception: self.logger.exception("Encountered an error while restarting the fixture.") raise diff --git a/buildscripts/resmokelib/testing/hooks/cleanup_concurrency_workloads.py b/buildscripts/resmokelib/testing/hooks/cleanup_concurrency_workloads.py index 1fbb6f673f2e1..8fbd6ed65e4a7 100644 --- a/buildscripts/resmokelib/testing/hooks/cleanup_concurrency_workloads.py +++ b/buildscripts/resmokelib/testing/hooks/cleanup_concurrency_workloads.py @@ -74,7 +74,7 @@ def run_test(self): self.logger.info("Dropping database %s", db_name) try: with_naive_retry(lambda: client.drop_database(db_name)) - except: + except Exception: self.logger.exception("Encountered an error while dropping database %s.", db_name) raise @@ -89,7 +89,7 @@ def run_test(self): self.logger.info("Dropping db %s collection %s", same_db_name, coll) try: with_naive_retry(lambda: client[same_db_name].drop_collection(coll)) - except: + except Exception: self.logger.exception( "Encountered an error while dropping db % collection %s.", same_db_name, diff --git a/buildscripts/resmokelib/testing/hooks/interface.py b/buildscripts/resmokelib/testing/hooks/interface.py index 6fc57edaee6ed..1000bb3e99fde 100644 --- a/buildscripts/resmokelib/testing/hooks/interface.py +++ b/buildscripts/resmokelib/testing/hooks/interface.py @@ -82,7 +82,7 @@ def run_dynamic_test(self, test_report): self.logger.error("{0} failed".format(self.description)) test_report.addFailure(self, sys.exc_info()) raise errors.TestFailure(err.args[0]) - except: + except Exception: self.return_code = 2 test_report.addFailure(self, sys.exc_info()) raise diff --git a/buildscripts/resmokelib/testing/hooks/validate.py b/buildscripts/resmokelib/testing/hooks/validate.py index 4c71f699c0a04..1705a7b554c2a 100644 --- a/buildscripts/resmokelib/testing/hooks/validate.py +++ b/buildscripts/resmokelib/testing/hooks/validate.py @@ -120,7 +120,7 @@ def run_test(self): # Perform inter-node validation (if the running fixture provides a method to run it). if getattr(self.fixture, "internode_validation", None): self.fixture.internode_validation() - except: + except Exception: self.logger.exception("Uncaught exception while validating collections") raise @@ -175,7 +175,7 @@ def validate_node( ): raise RuntimeError(f"Internal error while validating database: {db_name}") return True - except: + except Exception: logger.exception( f"Unknown exception while validating node {node.get_driver_connection_url()}" ) @@ -274,7 +274,7 @@ def list_collections(db: Database, filter: dict, timeout: int = 10): ) ) return True - except: + except Exception: logger.exception("Unknown exception while validating database") return False diff --git a/buildscripts/resmokelib/testing/job.py b/buildscripts/resmokelib/testing/job.py index a413bb102b08f..d5890fcc5a08d 100644 --- a/buildscripts/resmokelib/testing/job.py +++ b/buildscripts/resmokelib/testing/job.py @@ -113,7 +113,7 @@ def start( "Received a StopExecution exception when setting up the fixture: %s.", err ) setup_succeeded = False - except: + except Exception: # Something unexpected happened when setting up the fixture. We don't attempt to run # any tests. self.logger.exception("Encountered an error when setting up the fixture.") @@ -130,7 +130,7 @@ def start( # Stop running tests immediately. self.logger.error("Received a StopExecution exception: %s.", err) self._interrupt_all_jobs(queue, interrupt_flag) - except: + except Exception: # Unknown error, stop execution. self.logger.exception("Encountered an error during test execution.") self._interrupt_all_jobs(queue, interrupt_flag) @@ -147,7 +147,7 @@ def start( "Received a StopExecution exception when tearing down the fixture: %s.", err ) teardown_succeeded = False - except: + except Exception: # Something unexpected happened when tearing down the fixture. We indicate back to # the executor thread that teardown has failed. This may mean resmoke.py is exiting # without having terminated all of the child processes it spawned. @@ -241,7 +241,7 @@ def _execute_test(self, test: TestCase, hook_failure_flag: Optional[threading.Ev try: test.configure(self.fixture, config.NUM_CLIENTS_PER_FIXTURE, config.USE_TENANT_CLIENT) - except: + except Exception: self.logger.error( "%s marked as a failure because it could not be configured.", test.short_description(), @@ -410,7 +410,7 @@ def _run_hooks_before_tests(self, test: TestCase, hook_failure_flag: Optional[th if self.suite_options.fail_fast: raise errors.StopExecution("A hook's before_test failed") - except: + except Exception: # Record the before_test() error in 'self.report'. self.report.startTest(test) self.report.addError(test, sys.exc_info()) @@ -438,7 +438,7 @@ def _run_hooks_after_tests( try: self.logger.info("Stopping the balancer before running end-test hooks") self.fixture.stop_balancer() - except: + except Exception: self.logger.exception( "%s failed while stopping the balancer for after-test hooks", test.short_description(), @@ -480,7 +480,7 @@ def _run_hooks_after_tests( if self.suite_options.fail_fast: raise errors.StopExecution("A hook's after_test failed") - except: + except Exception: self.report.setError(test, sys.exc_info()) raise @@ -488,7 +488,7 @@ def _run_hooks_after_tests( try: self.logger.info("Resuming the balancer after running end-test hooks") self.fixture.start_balancer() - except: + except Exception: self.logger.exception( "%s failed while re-starting the balancer after end-test hooks", test.short_description(), diff --git a/buildscripts/resmokelib/testing/report.py b/buildscripts/resmokelib/testing/report.py index 3f999bcaaf948..4794d62c5ca8f 100644 --- a/buildscripts/resmokelib/testing/report.py +++ b/buildscripts/resmokelib/testing/report.py @@ -126,7 +126,7 @@ def startTest(self, test: TestCase): self.job_logger.info("Running %s...\n%s", basename, command) else: self.job_logger.info("Running %s...", basename) - except: + except Exception: # This can happen in rare cases like in ProcessTestCase where the process building itself fails self.job_logger.exception("Failed to form command for test %s" % basename) diff --git a/buildscripts/resmokelib/testing/testcases/fixture.py b/buildscripts/resmokelib/testing/testcases/fixture.py index 993d5b776b511..f6cdaa8613c16 100644 --- a/buildscripts/resmokelib/testing/testcases/fixture.py +++ b/buildscripts/resmokelib/testing/testcases/fixture.py @@ -72,7 +72,7 @@ def run_test(self): except errors.ServerFailure as err: self.logger.error("An error occurred during the setup of %s: %s", self.fixture, err) raise - except: + except Exception: self.logger.exception("An error occurred during the setup of %s.", self.fixture) raise @@ -99,7 +99,7 @@ def run_test(self): except errors.ServerFailure as err: self.logger.error("An error occurred during the teardown of %s: %s", self.fixture, err) raise - except: + except Exception: self.logger.exception("An error occurred during the teardown of %s.", self.fixture) raise @@ -130,6 +130,6 @@ def run_test(self): # If the server wasn't already running, we can't exactly fail to abort it. self.logger.info("Finished aborting %s.", self.fixture) self.return_code = 0 - except: + except Exception: self.logger.exception("An error occurred while aborting %s.", self.fixture) raise diff --git a/buildscripts/resmokelib/testing/testcases/interface.py b/buildscripts/resmokelib/testing/testcases/interface.py index 7f945e102d090..e293a4ee9eefc 100644 --- a/buildscripts/resmokelib/testing/testcases/interface.py +++ b/buildscripts/resmokelib/testing/testcases/interface.py @@ -158,7 +158,7 @@ def run_test(self): self._execute(self.proc) except self.failureException: raise - except: + except Exception: self.logger.exception( "Encountered an error running %s %s", self.test_kind, self.basename() ) @@ -169,7 +169,7 @@ def as_command(self): try: proc = self._make_process() return proc.as_command() - except: + except Exception: self.logger.exception( "Encountered an error getting command for %s %s", self.test_kind, self.basename() ) diff --git a/buildscripts/resmokelib/testing/testcases/jstest.py b/buildscripts/resmokelib/testing/testcases/jstest.py index 1c6889d099530..8ca2b083efaca 100644 --- a/buildscripts/resmokelib/testing/testcases/jstest.py +++ b/buildscripts/resmokelib/testing/testcases/jstest.py @@ -210,7 +210,7 @@ def run(self): """Run the jstest.""" try: threading.Thread.run(self) - except: + except Exception: self.exc_info = sys.exc_info() def __init__( @@ -278,7 +278,7 @@ def _run_multiple_copies(self): thread = self.ThreadWithException(target=test_case.run_test) threads.append(thread) thread.start() - except: + except Exception: self.logger.exception( "Encountered an error starting threads for jstest %s.", self.basename() ) diff --git a/buildscripts/resmokelib/utils/file_span_exporter.py b/buildscripts/resmokelib/utils/file_span_exporter.py index 1037038beb676..d637766b99fb0 100644 --- a/buildscripts/resmokelib/utils/file_span_exporter.py +++ b/buildscripts/resmokelib/utils/file_span_exporter.py @@ -57,7 +57,7 @@ def export(self, spans: Sequence[ReadableSpan]) -> SpanExportResult: json.dump(message, file, indent=2) else: json.dump(message, file, indent=None, separators=(",", ":")) - except: + except Exception: logger.exception("Failed to write OTEL metrics to file %s", file_name) return SpanExportResult.FAILURE diff --git a/buildscripts/tests/test_check_for_noexcept.py b/buildscripts/tests/test_check_for_noexcept.py index c2c0e83e62186..75d449018922a 100644 --- a/buildscripts/tests/test_check_for_noexcept.py +++ b/buildscripts/tests/test_check_for_noexcept.py @@ -486,7 +486,7 @@ def test_get_move_operations_noexcept_matters(self): """, ) - for snippet in with_noexcept: + for snippet in with_noexcept Exception: all_moves = get_move_operations(snippet) noexcept = _noexcept_moves_only(all_moves) non_noexcept = _nonnoexcept_moves_only(all_moves) @@ -495,7 +495,7 @@ def test_get_move_operations_noexcept_matters(self): len(non_noexcept), 0, msg=f"Expected no non-noexcept move operation: {snippet}" ) - for snippet in without_noexcept: + for snippet in without_noexcept Exception: all_moves = get_move_operations(snippet) noexcept = _noexcept_moves_only(all_moves) non_noexcept = _nonnoexcept_moves_only(all_moves) @@ -521,12 +521,12 @@ def test_get_noexcepts(self): _BASIC_NON_NOEXCEPT_MOVE_OPERATIONS + _BASIC_NON_NOEXCEPT_NON_MOVE_OPERATIONS ) - for snippet in with_noexcept: + for snippet in with_noexcept Exception: self.assertGreater( len(get_noexcepts(snippet)), 0, msg=f"Expected noexcept in snippet: {snippet}" ) - for snippet in without_noexcept: + for snippet in without_noexcept Exception: self.assertEqual( len(get_noexcepts(snippet)), 0, msg=f"Expected no noexcept in snippet: {snippet}" ) diff --git a/jstests/auth/lib/automated_idp_authn_simulator_azure.py b/jstests/auth/lib/automated_idp_authn_simulator_azure.py index e0af3e44b8486..e4c2e6361e205 100644 --- a/jstests/auth/lib/automated_idp_authn_simulator_azure.py +++ b/jstests/auth/lib/automated_idp_authn_simulator_azure.py @@ -77,7 +77,7 @@ def authenticate_azure(activation_endpoint, userCode, username, test_credentials password_input_box = WebDriverWait(driver, 30).until( EC.presence_of_element_located((By.ID, "passwordEntry")) ) - except: + except Exception: password_input_box = WebDriverWait(driver, 30).until( EC.presence_of_element_located((By.ID, "i0118")) ) @@ -86,7 +86,7 @@ def authenticate_azure(activation_endpoint, userCode, username, test_credentials verify_button = WebDriverWait(driver, 30).until( EC.presence_of_element_located((By.XPATH, "//button[@data-testid='primaryButton']")) ) - except: + except Exception: verify_button = WebDriverWait(driver, 30).until( EC.presence_of_element_located((By.ID, "idSIButton9")) ) diff --git a/jstests/ssl/x509/mkcert.py b/jstests/ssl/x509/mkcert.py index b4bb48dadf0ab..6b7b263e3e358 100755 --- a/jstests/ssl/x509/mkcert.py +++ b/jstests/ssl/x509/mkcert.py @@ -31,7 +31,7 @@ b"mongoClusterMembership", b"Name of MongoDB cluster this cert is a member of", ) -except: +except Exception: pass CONFIGFILE = "jstests/ssl/x509/certs.yml" @@ -123,7 +123,7 @@ def load_authority_file(issuer): certificate = OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_PEM, pem) signing_key = OpenSSL.crypto.load_privatekey(OpenSSL.crypto.FILETYPE_PEM, pem) return (certificate, signing_key) - except: + except Exception: pass return (None, None) diff --git a/modules_poc/cindex.py b/modules_poc/cindex.py index e31d0eceab75b..6864dcb44f6d5 100644 --- a/modules_poc/cindex.py +++ b/modules_poc/cindex.py @@ -221,7 +221,7 @@ def __init__(self, wrapped: Callable[[TInstance], TResult]): self.wrapped = wrapped try: self.__doc__ = wrapped.__doc__ - except: + except Exception: pass def __get__(self, instance: TInstance, instance_type: Any = None) -> TResult: diff --git a/src/third_party/grpc/dist/src/c-ares/gen_build_yaml.py b/src/third_party/grpc/dist/src/c-ares/gen_build_yaml.py index ffc2d6f5d7513..228ec7895c089 100755 --- a/src/third_party/grpc/dist/src/c-ares/gen_build_yaml.py +++ b/src/third_party/grpc/dist/src/c-ares/gen_build_yaml.py @@ -152,7 +152,7 @@ def ares_build(x): ], } ] -except: +except Exception: pass print(yaml.dump(out)) diff --git a/src/third_party/wiredtiger/bench/workgen/runner/runner/__init__.py b/src/third_party/wiredtiger/bench/workgen/runner/runner/__init__.py index f2f1c22ebd559..9547d64f30afd 100755 --- a/src/third_party/wiredtiger/bench/workgen/runner/runner/__init__.py +++ b/src/third_party/wiredtiger/bench/workgen/runner/runner/__init__.py @@ -52,7 +52,7 @@ def _prepend_env_path(pathvar, s): last = '' try: last = ':' + os.environ[pathvar] - except: + except Exception: pass os.environ[pathvar] = s + last @@ -60,14 +60,14 @@ def _prepend_env_path(pathvar, s): # If the path already works, don't change it. try: import wiredtiger -except: +except Exception: # We'll try hard to make the importing work, we'd like to runners # to be executable directly without having to set environment variables. sys.path.insert(0, os.path.join(wt_dir, 'lang', 'python')) sys.path.insert(0, os.path.join(wt_builddir, 'lang', 'python')) try: import wiredtiger - except: + except Exception: # If the WiredTiger libraries is not in our library search path, # we need to set it and retry. However, the dynamic link # library has already cached its value, our only option is @@ -91,7 +91,7 @@ def _prepend_env_path(pathvar, s): try: import workgen -except: +except Exception: sys.path.insert(0, os.path.join(workgen_src, 'workgen')) sys.path.insert(0, os.path.join(wt_builddir, 'bench', 'workgen')) import workgen diff --git a/src/third_party/wiredtiger/dist/dist.py b/src/third_party/wiredtiger/dist/dist.py index dfa7da3d18198..88d1b6698903a 100755 --- a/src/third_party/wiredtiger/dist/dist.py +++ b/src/third_party/wiredtiger/dist/dist.py @@ -108,7 +108,7 @@ def __init__(self, filename): def remove(self, filename): try: os.remove(filename) - except: + except Exception: pass @contextmanager diff --git a/src/third_party/wiredtiger/test/3rdparty/concurrencytest-0.1.2-locally-modified/concurrencytest.py b/src/third_party/wiredtiger/test/3rdparty/concurrencytest-0.1.2-locally-modified/concurrencytest.py index 2dff87fa11379..227bc0e9aee3a 100755 --- a/src/third_party/wiredtiger/test/3rdparty/concurrencytest-0.1.2-locally-modified/concurrencytest.py +++ b/src/third_party/wiredtiger/test/3rdparty/concurrencytest-0.1.2-locally-modified/concurrencytest.py @@ -110,7 +110,7 @@ def do_fork(suite): # Set the pid tag for the parent to log with this information. subunit_result.tags(["pid:" + str(os.getpid())], []) process_suite.run(subunit_result) - except: + except Exception: # Try and report traceback on stream, but exit with error # even if stream couldn't be created or something else # goes wrong. The traceback is formatted to a string and diff --git a/src/third_party/wiredtiger/test/3rdparty/discover-0.4.0-locally-modified/discover.py b/src/third_party/wiredtiger/test/3rdparty/discover-0.4.0-locally-modified/discover.py index c1e20273bcbda..84efbe80291eb 100755 --- a/src/third_party/wiredtiger/test/3rdparty/discover-0.4.0-locally-modified/discover.py +++ b/src/third_party/wiredtiger/test/3rdparty/discover-0.4.0-locally-modified/discover.py @@ -109,7 +109,7 @@ def loadTestsFromModule(self, module, use_load_tests=True): if use_load_tests and load_tests is not None: try: return load_tests(self, tests, None) - except: + except Exception: ExceptionClass, e = sys.exc_info()[:2] if not isinstance(e, Exception): # for BaseException exceptions @@ -286,7 +286,7 @@ def _find_tests(self, start_dir, pattern): name = self._get_name_from_path(full_path) try: module = self._get_module_from_name(name) - except: + except Exception: yield _make_failed_import_test(name, self.suiteClass) else: mod_file = os.path.abspath(getattr(module, '__file__', full_path)) @@ -323,7 +323,7 @@ def _find_tests(self, start_dir, pattern): else: try: yield load_tests(self, tests, pattern) - except: + except Exception: ExceptionClass, e = sys.exc_info()[:2] if not isinstance(e, Exception): # for BaseException exceptions diff --git a/src/third_party/wiredtiger/test/3rdparty/testscenarios-0.4/lib/testscenarios/scenarios.py b/src/third_party/wiredtiger/test/3rdparty/testscenarios-0.4/lib/testscenarios/scenarios.py index eeb72ebb8a4e1..7c3196ec84891 100644 --- a/src/third_party/wiredtiger/test/3rdparty/testscenarios-0.4/lib/testscenarios/scenarios.py +++ b/src/third_party/wiredtiger/test/3rdparty/testscenarios-0.4/lib/testscenarios/scenarios.py @@ -159,7 +159,7 @@ def per_module_scenarios(attribute_name, modules): for short_name, module_name in modules: try: mod = __import__(module_name, {}, {}, ['']) - except: + except Exception: mod = sys.exc_info() scenarios.append(( short_name, diff --git a/src/third_party/wiredtiger/test/3rdparty/testtools-2.7.1/testtools/matchers/_exception.py b/src/third_party/wiredtiger/test/3rdparty/testtools-2.7.1/testtools/matchers/_exception.py index 66aaa906ea38b..07fb16828c43b 100644 --- a/src/third_party/wiredtiger/test/3rdparty/testtools-2.7.1/testtools/matchers/_exception.py +++ b/src/third_party/wiredtiger/test/3rdparty/testtools-2.7.1/testtools/matchers/_exception.py @@ -98,7 +98,7 @@ def match(self, matchee): return Mismatch(f'{matchee!r} returned {result!r}') # Catch all exceptions: Raises() should be able to match a # KeyboardInterrupt or SystemExit. - except: + except Exception: exc_info = sys.exc_info() if self.exception_matcher: mismatch = self.exception_matcher.match(exc_info) diff --git a/src/third_party/wiredtiger/test/3rdparty/testtools-2.7.1/testtools/runtest.py b/src/third_party/wiredtiger/test/3rdparty/testtools-2.7.1/testtools/runtest.py index 4f0e894b3281e..04e78c3bb2b8f 100644 --- a/src/third_party/wiredtiger/test/3rdparty/testtools-2.7.1/testtools/runtest.py +++ b/src/third_party/wiredtiger/test/3rdparty/testtools-2.7.1/testtools/runtest.py @@ -191,7 +191,7 @@ def _run_user(self, fn, *args, **kwargs): """ try: return fn(*args, **kwargs) - except: + except Exception: return self._got_user_exception(sys.exc_info()) def _got_user_exception(self, exc_info, tb_label='traceback'): diff --git a/src/third_party/wiredtiger/test/3rdparty/testtools-2.7.1/testtools/testcase.py b/src/third_party/wiredtiger/test/3rdparty/testtools-2.7.1/testtools/testcase.py index 004fdb5c8476f..cad40957afcff 100644 --- a/src/third_party/wiredtiger/test/3rdparty/testtools-2.7.1/testtools/testcase.py +++ b/src/third_party/wiredtiger/test/3rdparty/testtools-2.7.1/testtools/testcase.py @@ -719,7 +719,7 @@ def useFixture(self, fixture): e.args[-1][0] is fixtures.fixture.SetupError): gather_details(e.args[-1][1].args[0], self.getDetails()) raise - except: + except Exception: exc_info = sys.exc_info() try: # fixture._details is not available if using the newer @@ -732,7 +732,7 @@ def useFixture(self, fixture): fixture._details is not None ): gather_details(fixture.getDetails(), self.getDetails()) - except: + except Exception: # Report the setUp exception, then raise the error during # gather_details. self._report_traceback(exc_info) diff --git a/src/third_party/wiredtiger/test/3rdparty/testtools-2.7.1/testtools/tests/test_testcase.py b/src/third_party/wiredtiger/test/3rdparty/testtools-2.7.1/testtools/tests/test_testcase.py index 207991152c716..6ddd928a767a6 100644 --- a/src/third_party/wiredtiger/test/3rdparty/testtools-2.7.1/testtools/tests/test_testcase.py +++ b/src/third_party/wiredtiger/test/3rdparty/testtools-2.7.1/testtools/tests/test_testcase.py @@ -205,7 +205,7 @@ class TestErrorHolder(TestCase): def makeException(self): try: raise RuntimeError("danger danger") - except: + except Exception: return sys.exc_info() def makePlaceHolder(self, test_id="foo", error=None, diff --git a/src/third_party/wiredtiger/test/3rdparty/testtools-2.7.1/testtools/tests/test_testresult.py b/src/third_party/wiredtiger/test/3rdparty/testtools-2.7.1/testtools/tests/test_testresult.py index 015972cc2f39c..6b641e64c99a5 100644 --- a/src/third_party/wiredtiger/test/3rdparty/testtools-2.7.1/testtools/tests/test_testresult.py +++ b/src/third_party/wiredtiger/test/3rdparty/testtools-2.7.1/testtools/tests/test_testresult.py @@ -129,7 +129,7 @@ def test(self): def make_exception_info(exceptionFactory, *args, **kwargs): try: raise exceptionFactory(*args, **kwargs) - except: + except Exception: return sys.exc_info() diff --git a/src/third_party/wiredtiger/test/3rdparty/testtools-2.7.1/testtools/tests/twistedsupport/test_matchers.py b/src/third_party/wiredtiger/test/3rdparty/testtools-2.7.1/testtools/tests/twistedsupport/test_matchers.py index 3147503309356..8b90f168ba067 100644 --- a/src/third_party/wiredtiger/test/3rdparty/testtools-2.7.1/testtools/tests/twistedsupport/test_matchers.py +++ b/src/third_party/wiredtiger/test/3rdparty/testtools-2.7.1/testtools/tests/twistedsupport/test_matchers.py @@ -41,7 +41,7 @@ def make_failure(exc_value): """Raise ``exc_value`` and return the failure.""" try: raise exc_value - except: + except Exception: return Failure() diff --git a/src/third_party/wiredtiger/test/3rdparty/testtools-2.7.1/testtools/testsuite.py b/src/third_party/wiredtiger/test/3rdparty/testtools-2.7.1/testtools/testsuite.py index 79fc4852c3649..d13b65298a4b8 100644 --- a/src/third_party/wiredtiger/test/3rdparty/testtools-2.7.1/testtools/testsuite.py +++ b/src/third_party/wiredtiger/test/3rdparty/testtools-2.7.1/testtools/testsuite.py @@ -91,7 +91,7 @@ def run(self, result): finished_test = queue.get() threads[finished_test][0].join() del threads[finished_test] - except: + except Exception: for thread, process_result in threads.values(): process_result.stop() raise @@ -172,7 +172,7 @@ def run(self, result): pass else: raise ValueError(f'unknown event type {event!r}') - except: + except Exception: for thread, process_result in threads.values(): # Signal to each TestControl in the ExtendedToStreamDecorator # that the thread should stop running tests and cleanup diff --git a/src/third_party/wiredtiger/test/suite/rollback_to_stable_util.py b/src/third_party/wiredtiger/test/suite/rollback_to_stable_util.py index f962856a56e72..4e4d32d270de0 100644 --- a/src/third_party/wiredtiger/test/suite/rollback_to_stable_util.py +++ b/src/third_party/wiredtiger/test/suite/rollback_to_stable_util.py @@ -40,7 +40,7 @@ def get_rts_verify_path(): try: root = get_git_root() return os.path.join(root, rel_path) - except: + except Exception: pass this_dir = pathlib.Path(__file__).parent.resolve() diff --git a/src/third_party/wiredtiger/test/suite/run.py b/src/third_party/wiredtiger/test/suite/run.py index 5a1fad927621c..43b62f0f051ea 100755 --- a/src/third_party/wiredtiger/test/suite/run.py +++ b/src/third_party/wiredtiger/test/suite/run.py @@ -370,7 +370,7 @@ def error(exitval, prefix, msg): left, right = args.pop(0).split('/') batchnum = int(left) batchtotal = int(right) - except: + except Exception: print('batch argument should be nnn/nnn') usage() sys.exit(2) diff --git a/src/third_party/wiredtiger/test/suite/test_backup02.py b/src/third_party/wiredtiger/test/suite/test_backup02.py index d49cdf9a50cd9..61e9c6aa77407 100644 --- a/src/third_party/wiredtiger/test/suite/test_backup02.py +++ b/src/third_party/wiredtiger/test/suite/test_backup02.py @@ -76,7 +76,7 @@ def test_backup02(self): more_time = more_time - 0.1 for i in range(self.nops): work_queue.put_nowait(('gu', i, my_data)) - except: + except Exception: # Deplete the work queue if there's an error. while not work_queue.empty(): work_queue.get() diff --git a/src/third_party/wiredtiger/test/suite/test_backup06.py b/src/third_party/wiredtiger/test/suite/test_backup06.py index f41911dd6d0b1..f3bdfc17dfc2d 100644 --- a/src/third_party/wiredtiger/test/suite/test_backup06.py +++ b/src/third_party/wiredtiger/test/suite/test_backup06.py @@ -35,7 +35,7 @@ # Windows does not getrlimit/setrlimit so we must catch the resource # module load. import resource -except: +except Exception: None # test_backup06.py diff --git a/src/third_party/wiredtiger/test/suite/test_backup21.py b/src/third_party/wiredtiger/test/suite/test_backup21.py index 6eaa144c9acf2..baddac1947cfe 100644 --- a/src/third_party/wiredtiger/test/suite/test_backup21.py +++ b/src/third_party/wiredtiger/test/suite/test_backup21.py @@ -74,7 +74,7 @@ def test_concurrent_operations_with_backup(self): if iteration == self.ops/2: iteration = 0 op = 'd' - except: + except Exception: # Deplete the work queue if there's an error. while not work_queue.empty(): work_queue.get() diff --git a/src/third_party/wiredtiger/test/suite/test_base03.py b/src/third_party/wiredtiger/test/suite/test_base03.py index 2d57ea5bf5967..deb86ce64cc68 100644 --- a/src/third_party/wiredtiger/test/suite/test_base03.py +++ b/src/third_party/wiredtiger/test/suite/test_base03.py @@ -53,7 +53,7 @@ def session_create(self, name, args): """ try: self.session.create(name, args) - except: + except Exception: print('**** ERROR in session.create("' + name + '","' + args + '") ***** ') raise diff --git a/src/third_party/wiredtiger/test/suite/test_base05.py b/src/third_party/wiredtiger/test/suite/test_base05.py index df617af8ada04..40139e309c198 100644 --- a/src/third_party/wiredtiger/test/suite/test_base05.py +++ b/src/third_party/wiredtiger/test/suite/test_base05.py @@ -46,7 +46,7 @@ def session_create(self, name, args): """ try: self.session.create(name, args) - except: + except Exception: print('**** ERROR in session.create("' + name + '","' + args + '") ***** ') raise diff --git a/src/third_party/wiredtiger/test/suite/test_bug018.py b/src/third_party/wiredtiger/test/suite/test_bug018.py index 84c47d9c6ed8f..dc794f681f076 100644 --- a/src/third_party/wiredtiger/test/suite/test_bug018.py +++ b/src/third_party/wiredtiger/test/suite/test_bug018.py @@ -143,7 +143,7 @@ def test_bug018(self): self.captureerr.check(self) # check there is no error output so far try: results2 = list(self.session.open_cursor(self.uri2)) - except: + except Exception: # Make sure there's some error, but we don't care what. self.captureerr.checkAdditionalPattern(self, '.') results2 = [] diff --git a/src/third_party/wiredtiger/test/suite/test_checkpoint02.py b/src/third_party/wiredtiger/test/suite/test_checkpoint02.py index 6f06a6799aa53..66bf50849ebed 100644 --- a/src/third_party/wiredtiger/test/suite/test_checkpoint02.py +++ b/src/third_party/wiredtiger/test/suite/test_checkpoint02.py @@ -87,7 +87,7 @@ def test_checkpoint02(self): t = op_thread(self.conn, uris, self.key_format, work_queue, done) opthreads.append(t) t.start() - except: + except Exception: # Deplete the work queue if there's an error. while not work_queue.empty(): work_queue.get() diff --git a/src/third_party/wiredtiger/test/suite/test_config02.py b/src/third_party/wiredtiger/test/suite/test_config02.py index d1f09846d07db..b34093255c645 100644 --- a/src/third_party/wiredtiger/test/suite/test_config02.py +++ b/src/third_party/wiredtiger/test/suite/test_config02.py @@ -83,7 +83,7 @@ def common_test(self, homearg, homeenv, configextra): try: os.putenv('SOMEVAR', 'somevalue') os.unsetenv('SOMEVAR') - except: + except Exception: self.skipTest('putenv and/or unsetenv not support on this OS') return configarg = 'create' diff --git a/src/third_party/wiredtiger/test/suite/test_cursor01.py b/src/third_party/wiredtiger/test/suite/test_cursor01.py index 91c0750d87f96..7f55758ca609c 100644 --- a/src/third_party/wiredtiger/test/suite/test_cursor01.py +++ b/src/third_party/wiredtiger/test/suite/test_cursor01.py @@ -71,7 +71,7 @@ def session_create(self, name, args): """ try: self.session.create(name, args) - except: + except Exception: print('**** ERROR in session.create("' + name + '","' + args + '") ***** ') raise diff --git a/src/third_party/wiredtiger/test/suite/test_cursor04.py b/src/third_party/wiredtiger/test/suite/test_cursor04.py index 67e86ac978f2d..b9de7c88ff258 100644 --- a/src/third_party/wiredtiger/test/suite/test_cursor04.py +++ b/src/third_party/wiredtiger/test/suite/test_cursor04.py @@ -56,7 +56,7 @@ def session_create(self, name, args): """ try: self.session.create(name, args) - except: + except Exception: print('**** ERROR in session.create("' + name + '","' + args + '") ***** ') raise diff --git a/src/third_party/wiredtiger/test/suite/test_cursor_tracker.py b/src/third_party/wiredtiger/test/suite/test_cursor_tracker.py index b6dc03bbe7cc9..61242ad16ba05 100644 --- a/src/third_party/wiredtiger/test/suite/test_cursor_tracker.py +++ b/src/third_party/wiredtiger/test/suite/test_cursor_tracker.py @@ -95,7 +95,7 @@ def session_create(self, name, args): """ try: self.session.create(name, args) - except: + except Exception: print('**** ERROR in session.create("' + name + '","' + args + '") ***** ') raise @@ -438,11 +438,11 @@ def _dumpcursor(self, cursor): def cur_dump_here(self, cursor, prefix): try: k = self._cursor_key_to_string(cursor.get_key()) - except: + except Exception: k = '[invalid]' try: v = self._cursor_value_to_string(cursor.get_value()) - except: + except Exception: v = '[invalid]' print(prefix + k + ' ' + v) diff --git a/src/third_party/wiredtiger/test/suite/test_encrypt04.py b/src/third_party/wiredtiger/test/suite/test_encrypt04.py index 40e95a3c6b6be..0613d7f8d8a35 100644 --- a/src/third_party/wiredtiger/test/suite/test_encrypt04.py +++ b/src/third_party/wiredtiger/test/suite/test_encrypt04.py @@ -154,7 +154,7 @@ def check_okay(self, expect_okay, expr): try: expr() completed = True - except: + except Exception: pass self.assertEqual(False, completed) return expect_okay diff --git a/src/third_party/wiredtiger/test/suite/test_metadata_cursor01.py b/src/third_party/wiredtiger/test/suite/test_metadata_cursor01.py index e647f0d591a5d..0e07a828ca4c3 100644 --- a/src/third_party/wiredtiger/test/suite/test_metadata_cursor01.py +++ b/src/third_party/wiredtiger/test/suite/test_metadata_cursor01.py @@ -67,7 +67,7 @@ def session_create(self, name, args): """ try: self.session.create(name, args) - except: + except Exception: print('**** ERROR in session.create("' + name + '","' + args + '") ***** ') raise diff --git a/src/third_party/wiredtiger/test/suite/test_schema03.py b/src/third_party/wiredtiger/test/suite/test_schema03.py index 109463f6a76e6..1bc8213e36729 100644 --- a/src/third_party/wiredtiger/test/suite/test_schema03.py +++ b/src/third_party/wiredtiger/test/suite/test_schema03.py @@ -40,7 +40,7 @@ # Windows does not getrlimit/setrlimit so we must catch the resource # module load import resource -except: +except Exception: None # test_schema03.py diff --git a/src/third_party/wiredtiger/test/suite/test_timestamp22.py b/src/third_party/wiredtiger/test/suite/test_timestamp22.py index ab8d2ca9616e4..5c329ae17f745 100644 --- a/src/third_party/wiredtiger/test/suite/test_timestamp22.py +++ b/src/third_party/wiredtiger/test/suite/test_timestamp22.py @@ -83,7 +83,7 @@ def expect(self, expected, message): else: yield got = self.SUCCESS - except: + except Exception: got = self.FAILURE self.cleanStderr() diff --git a/src/third_party/wiredtiger/test/suite/wtdataset.py b/src/third_party/wiredtiger/test/suite/wtdataset.py index 78c6e32faf789..6ab6a91797a2f 100644 --- a/src/third_party/wiredtiger/test/suite/wtdataset.py +++ b/src/third_party/wiredtiger/test/suite/wtdataset.py @@ -320,7 +320,7 @@ def __init__(self, testcase, uri, multiplier, **kwargs): def store_count(self, i): try: return self.track_values[i] - except: + except Exception: return 0 # override @@ -376,7 +376,7 @@ def __init__(self, testcase, uri, multiplier, **kwargs): def store_count(self, i): try: return self.track_values[i] - except: + except Exception: return 0 # override diff --git a/src/third_party/wiredtiger/test/suite/wthooks.py b/src/third_party/wiredtiger/test/suite/wthooks.py index 49083aba577b0..311449b2c2dbc 100644 --- a/src/third_party/wiredtiger/test/suite/wthooks.py +++ b/src/third_party/wiredtiger/test/suite/wthooks.py @@ -165,7 +165,7 @@ def __init__(self, hooknames = []): for hook in imported.initialize(arg): hook._initialize(name, self) self.hooks.append(hook) - except: + except Exception: print('Cannot import hook: ' + name + ', check file ' + modname + '.py') raise self.hook_names = tuple(names_seen) @@ -259,7 +259,7 @@ def __setitem__(self, name, value): try: hooktype = int(value[0]) fcn = value[1] - except: + except Exception: raise ValueError('value must be (HOOK_xxxx, function)') self.hookmgr.add_hook(self.clazz, name, hooktype, fcn) diff --git a/src/third_party/wiredtiger/test/suite/wttest.py b/src/third_party/wiredtiger/test/suite/wttest.py index 9525771ba72a9..635e076219df5 100644 --- a/src/third_party/wiredtiger/test/suite/wttest.py +++ b/src/third_party/wiredtiger/test/suite/wttest.py @@ -552,7 +552,7 @@ def setUp(self): try: self.conn = self.setUpConnectionOpen(".") self.session = self.setUpSessionOpen(self.conn) - except: + except Exception: self.tearDown() raise @@ -626,7 +626,7 @@ def tearDown(self, dueToRetry=False): for action in self.teardown_actions: try: tmp = action() - except: + except Exception: e = sys.exc_info() self.prexception(e) tmp = (-1, str(e[1])) @@ -645,7 +645,7 @@ def tearDown(self, dueToRetry=False): try: self.platform_api.tearDown(self) - except: + except Exception: self.pr('ERROR: failed to tear down the platform API') self.prexception(sys.exc_info()) @@ -656,7 +656,7 @@ def tearDown(self, dueToRetry=False): (not passed or WiredTigerTestCase._preserveFiles): self.pr('downloading object files') self.download_objects(self.bucket, self.bucket_prefix) - except: + except Exception: self.pr('ERROR: failed to download objects') self.prexception(sys.exc_info()) @@ -682,7 +682,7 @@ def tearDown(self, dueToRetry=False): close_failed = True dumped_error_log = True passed = False - except: + except Exception: pass self._connections = [] try: @@ -703,7 +703,7 @@ def tearDown(self, dueToRetry=False): if (passed and (not WiredTigerTestCase._preserveFiles)) or self.skipped: try: shutil.rmtree(self.testdir, ignore_errors=True) - except: + except Exception: self.pr('ERROR: failed to delete the test directory: ' + self.testdir) self.prexception(sys.exc_info()) else: diff --git a/src/third_party/wiredtiger/test/syscall/syscall.py b/src/third_party/wiredtiger/test/syscall/syscall.py index 1e59f34f27a88..8dabd2356104e 100755 --- a/src/third_party/wiredtiger/test/syscall/syscall.py +++ b/src/third_party/wiredtiger/test/syscall/syscall.py @@ -464,7 +464,7 @@ def fail(self, line, s): # make it work if line is None or is a plain string. try: prefix = simplify_path(self.wttopdir, line.prefix()) - except: + except Exception: prefix = 'syscall.py: ' print(prefix + s, file=sys.stderr) @@ -472,7 +472,7 @@ def failrange(self, errfile, line, lineto, s): # make it work if line is None or is a plain string. try: prefix = simplify_path(self.wttopdir, line.range_prefix(lineto)) - except: + except Exception: prefix = 'syscall.py: ' print(prefix + s + '\n' + errfile.get_context(), file=sys.stderr) diff --git a/src/third_party/wiredtiger/tools/gdb/gdb_scripts/wt_debug_script_update.py b/src/third_party/wiredtiger/tools/gdb/gdb_scripts/wt_debug_script_update.py index 0c8cb74971c09..07fd7d206770c 100644 --- a/src/third_party/wiredtiger/tools/gdb/gdb_scripts/wt_debug_script_update.py +++ b/src/third_party/wiredtiger/tools/gdb/gdb_scripts/wt_debug_script_update.py @@ -84,7 +84,7 @@ def dump_update_chain(update_chain): obj = bson.decode_all(val_bytes)[0] if obj["_id"]['id'] and obj["_id"]["id"].subtype == 4: obj["_id"]["id"] = obj["_id"]["id"].as_uuid() - except: + except Exception: pass print(' ' + '\n '.join(str(wt_val).split('\n')) + " " + str(obj) + " =>") diff --git a/src/third_party/wiredtiger/tools/optrack/find-latency-spikes.py b/src/third_party/wiredtiger/tools/optrack/find-latency-spikes.py index 44ed55db230e2..97d7f5fa86904 100755 --- a/src/third_party/wiredtiger/tools/optrack/find-latency-spikes.py +++ b/src/third_party/wiredtiger/tools/optrack/find-latency-spikes.py @@ -347,7 +347,7 @@ def createCallstackSeries(data, logfilename): # Let's open the log file. try: logfile = open(logfilename, "w"); - except: + except Exception: logfile = sys.stdout; for row in data.itertuples(): @@ -362,7 +362,7 @@ def createCallstackSeries(data, logfilename): = getIntervalData(intervalBeginningsStack, row, logfile); if (error and (not errorReported)): errorReported = reportDataError(logfile, logfilename); - except: + except Exception: if (not errorReported): errorReported = reportDataError(logfile, logfilename); continue; @@ -1167,7 +1167,7 @@ def parseConfigFile(fname): try: configFile = open(fname, "r"); - except: + except Exception: print(color.BOLD + color.RED + "Could not open " + fname + " for reading." + color.END); return False; diff --git a/src/third_party/wiredtiger/tools/optrack/optrack_to_t2.py b/src/third_party/wiredtiger/tools/optrack/optrack_to_t2.py index 2b51dec1cd2b2..ab8634c1e478f 100755 --- a/src/third_party/wiredtiger/tools/optrack/optrack_to_t2.py +++ b/src/third_party/wiredtiger/tools/optrack/optrack_to_t2.py @@ -164,7 +164,7 @@ def createCallstackSeries(data, logfilename): # Let's open the log file. try: logfile = open(logfilename, "w"); - except: + except Exception: logfile = sys.stdout; for row in data.itertuples(): @@ -181,7 +181,7 @@ def createCallstackSeries(data, logfilename): = getIntervalData(intervalBeginningsStack, row, logfile); if (error and (not errorReported)): errorReported = reportDataError(logfile, logfilename); - except: + except Exception: if (not errorReported): errorReported = reportDataError(logfile, logfilename); continue; @@ -256,7 +256,7 @@ def getSessionFromFileName(fname): try: sid = int(words[0]); return sid; - except: + except Exception: return 0; else: return 0; diff --git a/src/third_party/wiredtiger/tools/optrack/wt_optrack_decode.py b/src/third_party/wiredtiger/tools/optrack/wt_optrack_decode.py index ea7a51a707fcb..a37c8ab9e2c79 100755 --- a/src/third_party/wiredtiger/tools/optrack/wt_optrack_decode.py +++ b/src/third_party/wiredtiger/tools/optrack/wt_optrack_decode.py @@ -66,7 +66,7 @@ def buildTranslationMap(mapFileName): try: mapFile = open(mapFileName, "r"); - except: + except Exception: print(color.BOLD + color.RED); print("Could not open " + mapFileName + " for reading"); print(color.END); @@ -86,7 +86,7 @@ def buildTranslationMap(mapFileName): try: funcID = int(words[0]); - except: + except Exception: continue; funcName = words[1].strip(); @@ -123,7 +123,7 @@ def parseOneRecord(file): try: bytesRead = file.read(RECORD_SIZE); - except: + except Exception: return None; if (len(bytesRead) < RECORD_SIZE): @@ -146,7 +146,7 @@ def validateHeader(file): try: bytesRead = file.read(MIN_HEADER_SIZE); - except: + except Exception: print(color.BOLD + color.RED + "failed read of input file" + color.END); raise @@ -176,7 +176,7 @@ def validateHeader(file): padding, sec_from_epoch = struct.unpack('=IQ', bytesRead); return True, threadType, tsc_nsec, sec_from_epoch; - except: + except Exception: return False, -1; else: return False, -1, 1; @@ -208,7 +208,7 @@ def parseFile(fileName): # Open the log file for reading try: file = open(fileName, "rb"); - except: + except Exception: print(color.BOLD + color.RED + "Could not open " + fileName + " for reading" + color.END); raise @@ -236,7 +236,7 @@ def parseFile(fileName): try: outputFileName = fileName + "-" + threadTypeString + ".txt"; outputFile = open(outputFileName, "w"); - except: + except Exception: print(color.BOLD + color.RED + "Could not open file " + outputfileName + ".txt for writing." + color.END); @@ -263,7 +263,7 @@ def parseFile(fileName): + str(int(time)) + "\n"); totalRecords += 1; - except: + except Exception: exc_type, exc_value, exc_traceback = sys.exc_info() traceback.print_exception(exc_type, exc_value, exc_traceback); print(color.BOLD + color.RED); diff --git a/src/third_party/wiredtiger/tools/py_common/printer.py b/src/third_party/wiredtiger/tools/py_common/printer.py index 3d60553212e0e..e2c0d8bcae3ec 100644 --- a/src/third_party/wiredtiger/tools/py_common/printer.py +++ b/src/third_party/wiredtiger/tools/py_common/printer.py @@ -125,7 +125,7 @@ def raw_bytes(b): if result != '': result += ' ' return f'"{result + s.decode()}"' - except: + except Exception: pass # The earlier steps failed, so it must be binary data diff --git a/src/third_party/wiredtiger/tools/py_common/snappy_util.py b/src/third_party/wiredtiger/tools/py_common/snappy_util.py index b8ca2a3887ee8..7e63eab853a53 100644 --- a/src/third_party/wiredtiger/tools/py_common/snappy_util.py +++ b/src/third_party/wiredtiger/tools/py_common/snappy_util.py @@ -41,7 +41,7 @@ def snappy_decompress_page(b: binary_data.BinaryFile, page_header, header_length import snappy global have_snappy have_snappy = True - except: + except Exception: # Try to install it automatically logger.warning('python-snappy not found, attempting to install...') try: @@ -81,7 +81,7 @@ def snappy_decompress_page(b: binary_data.BinaryFile, page_header, header_length decompressed = snappy.uncompress(compressed_data) if not lengths_match: logger.info(f' Successfully decompressed using stored length ({compressed_byte_count} bytes)') - except: + except Exception: pass # If that failed and lengths differ, try calculated length @@ -92,7 +92,7 @@ def snappy_decompress_page(b: binary_data.BinaryFile, page_header, header_length try: decompressed = snappy.uncompress(compressed_data) logger.info(f' Successfully decompressed using calculated length ({calculated_length} bytes)') - except: + except Exception: pass # If any attempt succeeded, use the result @@ -107,7 +107,7 @@ def snappy_decompress_page(b: binary_data.BinaryFile, page_header, header_length compressed_data = compressed_data_full[:min(compressed_byte_count, len(compressed_data_full))] print_snappy_diagnostics(compressed_data, compressed_byte_count, page_header, compress_skip) return payload_data - except: + except Exception: logger.error('? The page failed to uncompress') if opts.debug: traceback.print_exception(*sys.exc_info()) diff --git a/src/third_party/wiredtiger/tools/py_common/wiredtiger_util.py b/src/third_party/wiredtiger/tools/py_common/wiredtiger_util.py index 8f847f5e90874..56877976ac25f 100755 --- a/src/third_party/wiredtiger/tools/py_common/wiredtiger_util.py +++ b/src/third_party/wiredtiger/tools/py_common/wiredtiger_util.py @@ -58,7 +58,7 @@ def import_wiredtiger(): ''' try: from wiredtiger import wiredtiger_open - except: + except Exception: setup_python_path() from wiredtiger import wiredtiger_open return wiredtiger_open diff --git a/src/third_party/wiredtiger/tools/wt_ckpt_decode.py b/src/third_party/wiredtiger/tools/wt_ckpt_decode.py index 4505e24355bee..a9d12a6f212dd 100755 --- a/src/third_party/wiredtiger/tools/wt_ckpt_decode.py +++ b/src/third_party/wiredtiger/tools/wt_ckpt_decode.py @@ -88,7 +88,7 @@ def decode_arg(arg, allocsize): i, addr = unpack_int(addr) result.append(i) result_len += 1 - except: + except Exception: break # Then we check the number of results against what we expect. diff --git a/src/third_party/wiredtiger/tools/wt_cmp_uri.py b/src/third_party/wiredtiger/tools/wt_cmp_uri.py index a1272469b7816..54545e6292a1b 100755 --- a/src/third_party/wiredtiger/tools/wt_cmp_uri.py +++ b/src/third_party/wiredtiger/tools/wt_cmp_uri.py @@ -330,12 +330,12 @@ def wiredtiger_compare_uri(args): try: cc1 = get_compare_cursor(conn1, timestamp1, uri1, arg1) - except: + except Exception: print('Failed opening {} in {} at timestamp {}'.format(uri1, wtdir1, timestamp1)) raise try: cc2 = get_compare_cursor(conn2, timestamp2, uri2, arg2) - except: + except Exception: print('Failed opening {} in {} at timestamp {}'.format(uri2, wtdir2, timestamp2)) raise diff --git a/src/third_party/zstandard/zstd/tests/test-zstd-versions.py b/src/third_party/zstandard/zstd/tests/test-zstd-versions.py index 1bcf39e2b25a1..837deb9633cec 100755 --- a/src/third_party/zstandard/zstd/tests/test-zstd-versions.py +++ b/src/third_party/zstandard/zstd/tests/test-zstd-versions.py @@ -93,7 +93,7 @@ def dict_ok(tag, dict_name, sample): with open(sample, "rb") as i: subprocess.check_call(cmd, stdin=i, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) return True - except: + except Exception: return False diff --git a/tools/flag_sync/util.py b/tools/flag_sync/util.py index d783a0c1ed64d..4142f6124514d 100644 --- a/tools/flag_sync/util.py +++ b/tools/flag_sync/util.py @@ -15,7 +15,7 @@ def get_flags(namespace: str): raise Exception("Namespace doesn't exist.") try: return json.loads(r.text) - except: + except Exception: raise Exception("Couldn't parse flag json.") diff --git a/x509/mkcert.py b/x509/mkcert.py index e276ccef7a93e..1ccca5b37b198 100644 --- a/x509/mkcert.py +++ b/x509/mkcert.py @@ -165,7 +165,7 @@ def get_oid(cn_or_oid): return NAME_TO_OID[cn_or_oid] try: return ObjectIdentifier(cn_or_oid) - except: + except Exception: raise CertificateGenerationError(f"Name attribute {cn_or_oid} not recognized") @@ -541,7 +541,7 @@ def process_normal_cert(cert): issuer_ski = issuer_cert.extensions.get_extension_for_class( x509.SubjectKeyIdentifier ) - except: + except Exception: issuer_ski = None # Set all fields of the certificate.