From c3efdceca9483ad394f5072e20bc0e368f759d5e Mon Sep 17 00:00:00 2001 From: xujiaqi01 <173596896@qq.com> Date: Wed, 10 Jun 2020 13:37:33 +0800 Subject: [PATCH] fix try except in python3 (#62) --- core/trainer.py | 2 +- core/utils/envs.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/trainer.py b/core/trainer.py index 4d4bd7f7..9694d0d0 100755 --- a/core/trainer.py +++ b/core/trainer.py @@ -196,7 +196,7 @@ class Trainer(object): self._status_processor[context['status']](context) else: self.other_status_processor(context) - except Exception, err: + except Exception as err: traceback.print_exc() print('Catch Exception:%s' % str(err)) sys.stdout.flush() diff --git a/core/utils/envs.py b/core/utils/envs.py index c0004cc0..bbb2a824 100755 --- a/core/utils/envs.py +++ b/core/utils/envs.py @@ -180,7 +180,7 @@ def lazy_instance_by_package(package, class_name): globals(), locals(), package.split(".")) instance = getattr(model_package, class_name) return instance - except Exception, err: + except Exception as err: traceback.print_exc() print('Catch Exception:%s' % str(err)) return None @@ -196,7 +196,7 @@ def lazy_instance_by_fliename(abs, class_name): globals(), locals(), package.split(".")) instance = getattr(model_package, class_name) return instance - except Exception, err: + except Exception as err: traceback.print_exc() print('Catch Exception:%s' % str(err)) return None -- GitLab