From 254d0519bbae2dffbf2dcc130e02aebda221e8f1 Mon Sep 17 00:00:00 2001 From: rocky Date: Sun, 1 Apr 2018 11:26:46 -0400 Subject: [PATCH] More 3.6 CALL_FUNCTION argument parsing --- test/bytecode_3.6_run/10_argparse.pyc | Bin 1153 -> 864 bytes test/simple_source/bug36/10_argparse.py | 51 ++++++++---------------- uncompyle6/semantics/customize.py | 13 ++++-- 3 files changed, 25 insertions(+), 39 deletions(-) diff --git a/test/bytecode_3.6_run/10_argparse.pyc b/test/bytecode_3.6_run/10_argparse.pyc index 891345a826d877ef4ba4f33ac51f09dd21c8fa55..78be71d8e8cfa66d70f94775c668ffefa21e9b95 100644 GIT binary patch literal 864 zcmb7?&2G~`5Xbk+u3Kn;8xktAA|%IAL}`mSAc9&|Tz%o@i{)lFk!fOw-Hi~Txgf4^ zqdd zqeBs{-7Sdf!#_}0n0YDxNsVPz)c2A44xBfrn+MQ_8>GhZOa7U`_(j9|uwnI*WfwA2 z0aKsEEak(hO8Hr?=X<|_;nop7bhQado*I@b3bVEdN*q82`ygc`6+ z=<5_UOWXG;S{xW;`!Pi=SR?dnirS^;?wj7S-4j z16kNZ4Ab1|MtQBaVuVban2&0V7_-ynICWtaHLtH55PGJR zE6iKnE{_3Y72*iPBbvRDKh~YZS>&T&Nx=Nji}xk-Cu}_A{UK8cI}TwUi*d|eZohfX z%5ZAA4j6b@s6>@A&B}Orqucf3I8mO${Ne1z(4%xAC(_1T4Jn-*CPJ|!?I(b2jxcI9 z)j8;qo+dhP_j+6Gee6Z}fo=AB`AZ%gv#y3-T#jLme#Rw}DfW555$>{7@K`Z5B(0Bu z9#z@LDOHn>C7N^XE6unVSogLbfcX}5p)Oyh {name} <==' -assert args.test == False -assert args.v == False +def test_namespace_kwargs_and_starkwargs_notidentifier(self): + ns = argparse.Namespace(a=1, **{'"': 'quote'}) + string = """Namespace(a=1, **{'"': 'quote'})""" + assert ns == string + + +def test_namespace(self): + ns = argparse.Namespace(foo=42, bar='spam') + string = "Namespace(bar='spam', foo=42)" + assert ns == string diff --git a/uncompyle6/semantics/customize.py b/uncompyle6/semantics/customize.py index 2d987f17..88d431e2 100644 --- a/uncompyle6/semantics/customize.py +++ b/uncompyle6/semantics/customize.py @@ -408,9 +408,13 @@ def customize_for_version(self, is_pypy, version): # Value 100 is important; it is exactly # module/function precidence. - PRECEDENCE['call_kw'] = 100 - PRECEDENCE['call_kw36'] = 100 - PRECEDENCE['call_ex'] = 100 + PRECEDENCE['call_kw'] = 100 + PRECEDENCE['call_kw36'] = 100 + PRECEDENCE['call_ex'] = 100 + PRECEDENCE['call_ex_kw'] = 100 + PRECEDENCE['call_ex_kw2'] = 100 + PRECEDENCE['call_ex_kw3'] = 100 + PRECEDENCE['call_ex_kw4'] = 100 TABLE_DIRECT.update({ 'tryfinally36': ( '%|try:\n%+%c%-%|finally:\n%+%c%-\n\n', @@ -570,7 +574,8 @@ def customize_for_version(self, is_pypy, version): assert call_function_ex == 'CALL_FUNCTION_EX_KW' # FIXME: decide if the below test be on kwargs == 'dict' if (call_function_ex.attr & 1 and - (not isinstance(kwargs, Token) and kwargs != 'attribute')): + (not isinstance(kwargs, Token) and kwargs != 'attribute') + and not kwargs[0].kind.startswith('kvlist')): self.call36_dict(kwargs) else: self.write('**')