From 8b74d8f85580d1f897ed4c1af769f463aeeccf72 Mon Sep 17 00:00:00 2001 From: rocky Date: Thu, 9 Jan 2020 19:55:22 -0500 Subject: [PATCH] Fix bug in handling 3.5- complex annotation return... Go over runtests.sh for 3.5 --- test/bytecode_3.4_run/04_def_annotate.pyc | Bin 10275 -> 10475 bytes test/bytecode_3.5_run/04_def_annotate.pyc | Bin 9407 -> 10474 bytes test/simple_source/bug31/04_def_annotate.py | 9 +++++++++ test/stdlib/runtests.sh | 4 ++-- uncompyle6/parsers/parse3.py | 2 +- uncompyle6/semantics/make_function3.py | 15 +++++++++------ 6 files changed, 21 insertions(+), 9 deletions(-) diff --git a/test/bytecode_3.4_run/04_def_annotate.pyc b/test/bytecode_3.4_run/04_def_annotate.pyc index c91d59ce29b40398d88bc2f4c3574273e9239ac0..636df9d51ebb2e4775cb672a7939b5f350f0399b 100644 GIT binary patch delta 395 zcmYk0F)Ra77{~wb-L<(iEusUpsHA!h5iAyxipkJY*C;ngs_$rNPV;&tho#s_-YBt{ zjAAlLjAAl&Wf6(h>b;7jU-JFl@B6-&FW>FzS3dO}jYXbb2DS=u;2m8Nk)Dy+m{B#`bU%$V0@nbmfdMRra}DfBQ!&IZ7lmPFZl=D2^E_4n(JtbUcj^B+Dwy* Qcs5IsjINO=nWh@~1z_h-00000 delta 216 zcmaDIxHv%N9S<+pITOj)Vj%{G#|%h-6UcS|;^J2<8&&vNIe>rAVz*QK@S0NL6RXvE%S+;+^b%GxP1v?94h3 zhWfmao&R?^}7A*KvrZd2v>ouTRhd~|z*#+__;{w84A?gKr45B8;Zje2Y1!El&Dk8pu zQ7=KV4`e^c0a!8N7U({sch4|RKn_C|_uCGGas=ckL!%7&5gIE(`Ws_UW>B65ImtGY zY*UXm=Rlrk=sZIWAZsBC5N+iBFMte#ya+3HvI#d)T%^ zOEpb)@n#4&L$n#L?P3|^JI7@U%otEpL*;&*(n{ryW$_xEOO$~S;zB~ec_bJQEdk=>MkOtI-p(K$Mmn(cVbZ2d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I>e>GS2NQdg^FF|OC=v-Y^tD^e+%U3fZ^uUCCnVy4eg~HrV`;DpBxRSKu-Qj_!IPABSw`hO2h|y0R5(>74mB@lRcKtmfy|bapL zP9Nc82Z={EmKN7^C!hK8Yks1dUyJZpXyX`)n-Li-14h>`&IQn6X1F9 diff --git a/test/simple_source/bug31/04_def_annotate.py b/test/simple_source/bug31/04_def_annotate.py index de80dd1a..8f3bc0f0 100644 --- a/test/simple_source/bug31/04_def_annotate.py +++ b/test/simple_source/bug31/04_def_annotate.py @@ -150,3 +150,12 @@ ann2(1) assert test12(1, 2, 3, name='hi') == (1, (2, 3)), "a, *args, name" assert test13(1, 2, 3, name='hi') == ((1, 2, 3), 'hi'), "*args, name" assert test16('localhost', loop=2, limit=3, a='b') == ('localhost', None, 2, 3, {'a': 'b'}) + +# From test 3.5 test_pydoc.py. +# Bug was in 3.5 and earlier handling of the return type, typing.Tuple[...] +try: + import typing + def foo() -> typing.Iterator[typing.Tuple[int, typing.Any]]: + ... +except: + pass diff --git a/test/stdlib/runtests.sh b/test/stdlib/runtests.sh index d2d4056c..4cd84846 100755 --- a/test/stdlib/runtests.sh +++ b/test/stdlib/runtests.sh @@ -290,7 +290,8 @@ case $PYVERSION in [test_pkgimport.py]=1 # long [test_poplib.py]=1 [test_print.py]=1 - [test_pwd.py]=1 # Takes too long + [test_pwd.py]=1 # Takes too long + [test_pydoc.py]=1 # test assertion: help text difference [test_queue.py]=1 # Possibly parameter differences - investigate [test_raise.py]=1 # Test assert error [test_range.py]=1 # doesn't terminate @@ -406,7 +407,6 @@ case $PYVERSION in [test_poll.py]=1 # Takes too long 11 seconds [test_poplib.py]=1 [test_pulldom.py]=1 - [test_pydoc.py]=1 # uncompyle6 error - Internal Error: n_build_list expects list, tuple, set, or unpack" Investigate [test_quopri.py]=1 # AssertionError: b'123=four' != '123=four' [test_range.py]=1 [test_robotparser.py]=1 diff --git a/uncompyle6/parsers/parse3.py b/uncompyle6/parsers/parse3.py index fab3eff4..b9980c02 100644 --- a/uncompyle6/parsers/parse3.py +++ b/uncompyle6/parsers/parse3.py @@ -1086,7 +1086,7 @@ class Python3Parser(PythonParser): load_op = "LOAD_CONST" if annotate_args > 0: - rule = "mkfunc_annotate ::= %s%s%sannotate_tuple load_closure %s %s %s" % ( + rule = "mkfunc_annotate ::= %s%s%sannotate_tuple load_closure %s %s" % ( "pos_arg " * args_pos, kwargs_str, "annotate_arg " * (annotate_args - 1), diff --git a/uncompyle6/semantics/make_function3.py b/uncompyle6/semantics/make_function3.py index 600681c1..3a6d6ecf 100644 --- a/uncompyle6/semantics/make_function3.py +++ b/uncompyle6/semantics/make_function3.py @@ -269,12 +269,15 @@ def make_function3_annotate( self.write("\n" + indent) line_number = self.line_number self.write(" -> ") - # value, string = annotate_args['return'] - # if string: - # self.write(' -> "%s"' % value) - # else: - # self.write(' -> %s' % value) - self.preorder(node[annotate_last - 1]) + if 'return' in annotate_dict: + self.write(annotate_dict['return']) + else: + # value, string = annotate_args['return'] + # if string: + # self.write(' -> "%s"' % value) + # else: + # self.write(' -> %s' % value) + self.preorder(node[annotate_last - 1]) self.println(":")