From c9b3bdbfcbdb160e04a23986051fbe78c953be88 Mon Sep 17 00:00:00 2001 From: Aurelius84 Date: Thu, 9 Apr 2020 21:42:48 +0800 Subject: [PATCH] API(program_guard) error message enhancement (#23452) * API(program_guard) error message enhancement test=develop * fix Cycle import test=develop * polish code according comment test=develop --- python/paddle/fluid/framework.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/python/paddle/fluid/framework.py b/python/paddle/fluid/framework.py index 002e92546ee..dffaa3fd6aa 100644 --- a/python/paddle/fluid/framework.py +++ b/python/paddle/fluid/framework.py @@ -4987,12 +4987,12 @@ def program_guard(main_program, startup_program=None): data = fluid.data(name='image', shape=[None, 784, 784], dtype='float32') """ - if not isinstance(main_program, Program): - raise TypeError("main_program should be Program") + from .data_feeder import check_type + check_type(main_program, 'main_program', Program, 'fluid.program_guard') main_program = switch_main_program(main_program) if startup_program is not None: - if not isinstance(startup_program, Program): - raise TypeError("startup_program should be Program") + check_type(startup_program, 'startup_program', Program, + 'fluid.program_guard') startup_program = switch_startup_program(startup_program) yield switch_main_program(main_program) -- GitLab