From cfc202528b0771f714c8b4299bbfdb9f22d90867 Mon Sep 17 00:00:00 2001 From: JinLiYan Date: Thu, 7 Jul 2016 15:34:58 +0800 Subject: [PATCH 1/2] =?UTF-8?q?byte=E5=A4=84=E7=90=86=E9=97=AE=E9=A2=98?= =?UTF-8?q?=EF=BC=8Cinclude=E6=96=87=E4=BB=B6=E8=B7=AF=E5=BE=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- thriftpy/parser/parser.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/thriftpy/parser/parser.py b/thriftpy/parser/parser.py index f93c305..d62e5ae 100644 --- a/thriftpy/parser/parser.py +++ b/thriftpy/parser/parser.py @@ -46,12 +46,12 @@ def p_header_unit(p): def p_include(p): '''include : INCLUDE LITERAL''' thrift = thrift_stack[-1] - if thrift.__thrift_file__ is None: raise ThriftParserError('Unexcepted include statement while loading' 'from file like object.') - - for include_dir in include_dirs_: + replace_include_dirs = [os.path.dirname(thrift.__thrift_file__)] + + include_dirs_ + for include_dir in replace_include_dirs: path = os.path.join(include_dir, p[2]) if os.path.exists(path): child = parse(path) @@ -153,7 +153,6 @@ def p_const_map_item(p): def p_const_ref(p): '''const_ref : IDENTIFIER''' child = thrift_stack[-1] - for name in p[1].split('.'): father = child child = getattr(child, name, None) @@ -609,7 +608,7 @@ def _cast_bool(v): def _cast_byte(v): - assert isinstance(v, str) + assert isinstance(v, int) return v From c77615346e877ae702a6a80b608577a02a2ee77d Mon Sep 17 00:00:00 2001 From: "lisen.jin" Date: Fri, 8 Jul 2016 16:50:49 +0800 Subject: [PATCH 2/2] fix a wrong line feed --- thriftpy/parser/parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/thriftpy/parser/parser.py b/thriftpy/parser/parser.py index d62e5ae..db6131c 100644 --- a/thriftpy/parser/parser.py +++ b/thriftpy/parser/parser.py @@ -49,7 +49,7 @@ def p_include(p): if thrift.__thrift_file__ is None: raise ThriftParserError('Unexcepted include statement while loading' 'from file like object.') - replace_include_dirs = [os.path.dirname(thrift.__thrift_file__)] + replace_include_dirs = [os.path.dirname(thrift.__thrift_file__)] \ + include_dirs_ for include_dir in replace_include_dirs: path = os.path.join(include_dir, p[2])