diff --git a/tests/parser-cases/issue_177.thrift b/tests/parser-cases/issue_177.thrift new file mode 100644 index 0000000..703cb8e --- /dev/null +++ b/tests/parser-cases/issue_177.thrift @@ -0,0 +1,6 @@ +include "issue_177_include.thrift" + +struct Issue177 { + 1: issue_177_include.Status status + 2: issue_177_include.invalidType type +} diff --git a/tests/parser-cases/issue_177_include.thrift b/tests/parser-cases/issue_177_include.thrift new file mode 100644 index 0000000..30ebf30 --- /dev/null +++ b/tests/parser-cases/issue_177_include.thrift @@ -0,0 +1,4 @@ +enum Status { + OK = 1 + ERROR = 2 +} diff --git a/tests/test_parser.py b/tests/test_parser.py index 17b353e..5f4809f 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -320,3 +320,9 @@ def test_nest_incomplete_type(): def test_issue_121(): load('parser-cases/issue_121.thrift') + + +def test_issue_177(): + with pytest.raises(ThriftParserError) as excinfo: + load('parser-cases/issue_177.thrift') + assert "type found: 'issue_177_include.invalidType'" in str(excinfo.value) \ No newline at end of file diff --git a/thriftpy2/parser/__init__.py b/thriftpy2/parser/__init__.py index c026387..0c4f60b 100644 --- a/thriftpy2/parser/__init__.py +++ b/thriftpy2/parser/__init__.py @@ -33,6 +33,10 @@ def load(path, module_name=None, include_dirs=None, include_dir=None, encoding=' include_dir=include_dir) if incomplete_type: fill_incomplete_ttype(thrift, thrift) + if incomplete_type: + missing_type = list(incomplete_type.values())[0][0] + msg = 'No type found: %r when parse file %r' % (missing_type, path) + raise ThriftParserError(msg) if real_module: sys.modules[module_name] = thrift return thrift