From a0c090932ef4e1a258e138d5a91922ea53c2985d Mon Sep 17 00:00:00 2001 From: rocky Date: Sat, 4 Mar 2017 11:49:09 -0500 Subject: [PATCH] Bug found by hypothesis in creating function calls --- test/bytecode_3.2/01_named_and_kwargs.pyc | Bin 0 -> 1056 bytes test/bytecode_3.5/01_named_and_kwargs.pyc | Bin 0 -> 738 bytes test/simple_source/bug32/01_named_and_kwargs.py | 9 +++++++++ uncompyle6/parsers/parse3.py | 11 +++++++---- 4 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 test/bytecode_3.2/01_named_and_kwargs.pyc create mode 100644 test/bytecode_3.5/01_named_and_kwargs.pyc diff --git a/test/bytecode_3.2/01_named_and_kwargs.pyc b/test/bytecode_3.2/01_named_and_kwargs.pyc new file mode 100644 index 0000000000000000000000000000000000000000..73eefc84c95ff731efb52ce5499d325a5c74e8e3 GIT binary patch literal 1056 zcmcgrOK;Oa5FXcUUQOE463U%R#DP+fdf+8cNlqx2q!P+y<$5O7iuFTY4<%BMz4C|n zQ~U*H)`3#s)C0C>JUjb&_M3-Yf6!Zf|MoG3->!YJ--`H56v}fSFa{g~wg3+R+kg)M zJ3)7WHUN7-0yqHL1Uv-XhU>V!5O5!^0Tykrf*AnrzzOaG?!n2T10-SY0qz5J;44It zd_EgJloPq9$C9&|t*P=H$?|p3FL+Pvw8%2bYg1OVv|p$JJPLr9d?)~$JDZdF3)hl8 zUspD*c_=1jWxX;A^~UDrbK+Qn?aB_)GGSL6Pibw7oChJOkSPn7s3+YNPg`VLMERYH zcy&s-W+U}XN1|Y)0M-ppZpj@n*1FAsBFHbjZoyZQFpx!L(_ky1MGVofTEZf6om}|M{pf(B_ZG#a2u`xk`~|&;4a_;z&+3bByCXS+y^`W z)rRjN1SOqM9?ec&4^^%U-6&%>;>||9bmOcl3RO0;HfpKADe^zwh*$1Fm$@#L{Qt9y zY-4oREZm+d>SirD%1T|zuW7zg){Rgt(^cL`tFlH{rHge*dUchje9T(Z{1#cCOpu+B zS$6s&#q0-6`mSYFzDzp*QrV=7Bq^J9t&(Ay=hdYws~bVXISk)7oYiy~x(q!ARxyKH z*gUbisBqzQKH&PDix(x^*G9$t) zWKN5BHs3-_cqJdcvp$xq%K&NhqT`$7lwZjvrX{ZH?_lz zb9jr>cO`D0BM@cMi2hX!g`X8pJ@6SFi=F^i!63MgKe7f+}->KZI#!twX a)OlT0xXRUA-!+#IiGhD2F=`J&KK%t5=%U#G literal 0 HcmV?d00001 diff --git a/test/simple_source/bug32/01_named_and_kwargs.py b/test/simple_source/bug32/01_named_and_kwargs.py index 237dc38e..63cb3524 100644 --- a/test/simple_source/bug32/01_named_and_kwargs.py +++ b/test/simple_source/bug32/01_named_and_kwargs.py @@ -18,3 +18,12 @@ def __init__(self, defaults=None, dict_type=_default_dict, default_section=DEFAULTSECT, interpolation=_UNSET): pass + +# Bug found by hypothesis in creating function calls +# thanks to moagstar +def fn(a, b, d): + return (a, b, d) + +b = {'b': 1, + 'd': 2} +fn(a=0, **b) diff --git a/uncompyle6/parsers/parse3.py b/uncompyle6/parsers/parse3.py index e07e7958..9ac1c55c 100644 --- a/uncompyle6/parsers/parse3.py +++ b/uncompyle6/parsers/parse3.py @@ -469,19 +469,22 @@ class Python3Parser(PythonParser): ('pos_arg ' * args_pos) + ('kwarg ' * args_kw) + 'expr ' * nak + token.type) - self.add_unique_rule(rule, token.type, args_pos, customize) + + uniq_param = args_kw + args_pos + + self.add_unique_rule(rule, token.type, uniq_param, customize) if self.version >= 3.5: rule = ('async_call_function ::= expr ' + ('pos_arg ' * args_pos) + ('kwarg ' * args_kw) + 'expr ' * nak + token.type + ' GET_AWAITABLE LOAD_CONST YIELD_FROM') - self.add_unique_rule(rule, token.type, args_pos, customize) - self.add_unique_rule('expr ::= async_call_function', token.type, args_pos, customize) + self.add_unique_rule(rule, token.type, uniq_param, customize) + self.add_unique_rule('expr ::= async_call_function', token.type, uniq_param, customize) rule = ('classdefdeco2 ::= LOAD_BUILD_CLASS mkfunc %s%s_%d' % (('expr ' * (args_pos-1)), opname, args_pos)) - self.add_unique_rule(rule, token.type, args_pos, customize) + self.add_unique_rule(rule, token.type, uniq_param, customize) def add_make_function_rule(self, rule, opname, attr, customize): """Python 3.3 added a an addtional LOAD_CONST before MAKE_FUNCTION and