diff --git a/mmcv/utils/config.py b/mmcv/utils/config.py index 7d69a10b08..4f96372ae4 100644 --- a/mmcv/utils/config.py +++ b/mmcv/utils/config.py @@ -7,6 +7,7 @@ import shutil import sys import tempfile +import types import uuid import warnings from argparse import Action, ArgumentParser @@ -209,6 +210,8 @@ def _file2dict(filename, use_predefined_variables=True): name: value for name, value in mod.__dict__.items() if not name.startswith('__') + and not isinstance(value, types.ModuleType) + and not isinstance(value, types.FunctionType) } # delete imported module del sys.modules[temp_module_name] diff --git a/tests/data/config/l.py b/tests/data/config/l.py index 85736f96e0..4a17bfcbcf 100644 --- a/tests/data/config/l.py +++ b/tests/data/config/l.py @@ -1,4 +1,10 @@ # Copyright (c) OpenMMLab. All rights reserved. +import os.path as osp + + +def func(x): + return x + _base_ = ['./l1.py', './l2.yaml', './l3.json', './l4.py'] item3 = False item4 = 'test' diff --git a/tests/data/config/n.py b/tests/data/config/n.py index fa7aae266e..8d295984c8 100644 --- a/tests/data/config/n.py +++ b/tests/data/config/n.py @@ -1,4 +1,10 @@ # Copyright (c) OpenMMLab. All rights reserved. +import os.path as osp + + +def func(x): + return x + test_item1 = [1, 2] bool_item2 = True str_item3 = 'test'