diff --git a/python/paddle/fluid/framework.py b/python/paddle/fluid/framework.py index 002e92546ee6aa0a872685a67aa036ce4939baf7..dffaa3fd6aaac7567f792dc56fc646c48c16a062 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)