From 1a1e75c253361d796c6c35c4220c1cd47397f400 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 8 Oct 2024 09:41:51 +1100 Subject: [PATCH] Cleanup: replace implicit BaseException with Exception Exception is more appropriate as a general exception in these cases. --- .../BlendFileDnaExporter_25.py | 2 +- doc/python_api/sphinx_doc_gen.py | 2 +- scripts/modules/addon_utils.py | 2 +- scripts/modules/animsys_refactor.py | 4 ++-- scripts/modules/bl_app_override/helpers.py | 2 +- scripts/modules/bpy/utils/__init__.py | 16 ++++++++-------- scripts/modules/bpy_extras/io_utils.py | 4 ++-- scripts/modules/bpy_types.py | 2 +- scripts/modules/rna_xml.py | 6 +++--- source/blender/python/rna_dump.py | 6 +++--- 10 files changed, 23 insertions(+), 23 deletions(-) diff --git a/doc/blender_file_format/BlendFileDnaExporter_25.py b/doc/blender_file_format/BlendFileDnaExporter_25.py index 574b42a457c..2106f872a40 100755 --- a/doc/blender_file_format/BlendFileDnaExporter_25.py +++ b/doc/blender_file_format/BlendFileDnaExporter_25.py @@ -402,7 +402,7 @@ def main(): log.info(" saving to: " + Path_Blend) try: bpy.ops.wm.save_as_mainfile(filepath=Path_Blend, copy=True, compress=False) - except: + except Exception: log.error("Filename {0} does not exist and can't be created... quitting".format(Path_Blend)) return else: diff --git a/doc/python_api/sphinx_doc_gen.py b/doc/python_api/sphinx_doc_gen.py index 5da192aa8f8..bd012bc5d84 100644 --- a/doc/python_api/sphinx_doc_gen.py +++ b/doc/python_api/sphinx_doc_gen.py @@ -2537,7 +2537,7 @@ def main(): try: os.mkdir(SPHINX_IN_TMP) - except: + except Exception: pass # Copy extra files needed for theme. diff --git a/scripts/modules/addon_utils.py b/scripts/modules/addon_utils.py index efdb8f7e949..d8439613741 100644 --- a/scripts/modules/addon_utils.py +++ b/scripts/modules/addon_utils.py @@ -166,7 +166,7 @@ def _fake_module(mod_name, mod_path, speedy=True): mod.bl_info = ast.literal_eval(body.value) mod.__file__ = mod_path mod.__time__ = os.path.getmtime(mod_path) - except: + except Exception: print("AST error parsing bl_info for:", repr(mod_path)) import traceback traceback.print_exc() diff --git a/scripts/modules/animsys_refactor.py b/scripts/modules/animsys_refactor.py index e7ef63640a1..a0d0f287c03 100644 --- a/scripts/modules/animsys_refactor.py +++ b/scripts/modules/animsys_refactor.py @@ -81,14 +81,14 @@ class DataPathBuilder: # print("base." + item_new) base_new = eval("base." + item_new) break # found, don't keep looking - except: + except Exception: pass item_new = "." + item_new else: item_new = item try: base_new = eval("base" + item_new) - except: + except Exception: pass if base_new is Ellipsis: diff --git a/scripts/modules/bl_app_override/helpers.py b/scripts/modules/bl_app_override/helpers.py index fe26336e4a0..de68ace36e2 100644 --- a/scripts/modules/bl_app_override/helpers.py +++ b/scripts/modules/bl_app_override/helpers.py @@ -111,7 +111,7 @@ class AppOverrideState: # (someone else was changing the sys.path), ignore! try: sys.path.remove(path) - except: + except Exception: pass addons = self._addon_store["addons"] diff --git a/scripts/modules/bpy/utils/__init__.py b/scripts/modules/bpy/utils/__init__.py index 323987e1700..86a2d913c68 100644 --- a/scripts/modules/bpy/utils/__init__.py +++ b/scripts/modules/bpy/utils/__init__.py @@ -138,7 +138,7 @@ def _test_import(module_name, loaded_modules): try: mod = __import__(module_name) - except: + except Exception: import traceback traceback.print_exc() return None @@ -236,7 +236,7 @@ def load_scripts(*, reload_scripts=False, refresh_scripts=False, extensions=True if register: try: register() - except: + except Exception: import traceback traceback.print_exc() else: @@ -250,7 +250,7 @@ def load_scripts(*, reload_scripts=False, refresh_scripts=False, extensions=True if unregister: try: unregister() - except: + except Exception: import traceback traceback.print_exc() @@ -264,7 +264,7 @@ def load_scripts(*, reload_scripts=False, refresh_scripts=False, extensions=True try: return importlib.reload(mod) - except: + except Exception: import traceback traceback.print_exc() @@ -817,7 +817,7 @@ def keyconfig_set(filepath, *, report=None): try: error_msg = "" execfile(filepath) - except: + except Exception: import traceback error_msg = traceback.format_exc() @@ -864,7 +864,7 @@ def user_resource(resource_type, *, path="", create=False): if not _os.path.exists(target_path): try: _os.makedirs(target_path) - except: + except Exception: import traceback traceback.print_exc() target_path = "" @@ -913,7 +913,7 @@ def extension_path_user(package, *, path="", create=False): if not _os.path.exists(target_path): try: _os.makedirs(target_path) - except: + except Exception: import traceback traceback.print_exc() target_path = "" @@ -1219,7 +1219,7 @@ def manual_map(): for cb in reversed(_manual_map): try: prefix, url_manual_mapping = cb() - except: + except Exception: print("Error calling {!r}".format(cb)) import traceback traceback.print_exc() diff --git a/scripts/modules/bpy_extras/io_utils.py b/scripts/modules/bpy_extras/io_utils.py index 1ade6c42410..c8b0e734afd 100644 --- a/scripts/modules/bpy_extras/io_utils.py +++ b/scripts/modules/bpy_extras/io_utils.py @@ -548,13 +548,13 @@ def path_reference_copy(copy_set, report=print): try: os.makedirs(dir_to, exist_ok=True) - except: + except Exception: import traceback traceback.print_exc() try: shutil.copy(file_src, file_dst) - except: + except Exception: import traceback traceback.print_exc() diff --git a/scripts/modules/bpy_types.py b/scripts/modules/bpy_types.py index d8fbdc88548..e6f65d78236 100644 --- a/scripts/modules/bpy_types.py +++ b/scripts/modules/bpy_types.py @@ -1035,7 +1035,7 @@ class _GenericUI: # the entire menu from drawing try: func(self, context) - except: + except Exception: import traceback traceback.print_exc() diff --git a/scripts/modules/rna_xml.py b/scripts/modules/rna_xml.py index e24cc5efe2e..ac57957d743 100644 --- a/scripts/modules/rna_xml.py +++ b/scripts/modules/rna_xml.py @@ -38,7 +38,7 @@ def build_property_typemap(skip_classes, skip_typemap): for prop_id in properties_blacklist: try: properties.remove(prop_id) - except: + except Exception: print("skip_typemap unknown prop_id '{:s}.{:s}'".format(cls_name, prop_id)) else: print("skip_typemap unknown class '{:s}'".format(cls_name)) @@ -130,7 +130,7 @@ def rna2xml( else: try: subvalue_ls = list(subvalue) - except: + except Exception: subvalue_ls = None if subvalue_ls is None: @@ -213,7 +213,7 @@ def rna2xml( value = getattr(root_rna, attr) try: ls = value[:] - except: + except Exception: ls = None if type(ls) == list: diff --git a/source/blender/python/rna_dump.py b/source/blender/python/rna_dump.py index 9e455577941..5f896522650 100644 --- a/source/blender/python/rna_dump.py +++ b/source/blender/python/rna_dump.py @@ -58,7 +58,7 @@ def seek(r, txt, recurs): try: keys = r.keys() - except: + except Exception: keys = None if keys is not None: @@ -67,7 +67,7 @@ def seek(r, txt, recurs): try: __members__ = dir(r) - except: + except Exception: __members__ = [] for item in __members__: @@ -93,7 +93,7 @@ def seek(r, txt, recurs): else: try: length = len(r) - except: + except Exception: length = 0 if VERBOSE is False and length >= 4: