From f78a3fb92ea56b9ee0671ebd42af2fd7cfc6636b Mon Sep 17 00:00:00 2001 From: rocky Date: Sun, 3 Dec 2017 12:25:26 -0500 Subject: [PATCH] Parens around constant in method call .. again. Note what fails in 2.7 runtests --- test/stdlib/runtests.sh | 65 ++++++++++++++++++++++++++++---- uncompyle6/semantics/consts.py | 36 +++++++++--------- uncompyle6/semantics/pysource.py | 3 +- 3 files changed, 78 insertions(+), 26 deletions(-) diff --git a/test/stdlib/runtests.sh b/test/stdlib/runtests.sh index 577ec67a..a90bb2b1 100755 --- a/test/stdlib/runtests.sh +++ b/test/stdlib/runtests.sh @@ -11,23 +11,74 @@ typeset -i STOP_ONERROR=1 typeset -A SKIP_TESTS case $PYVERSION in 2.4) - SKIP_TESTS=( [test_binop.py]=1 # need to fix tryelse - [test_cgi.py]=1 # need to fix tryelse - [test_codecs.py]=1 # need to fix tryelse - [test_dis.py]=1 # We change line numbers - duh! - ) + SKIP_TESTS=( + [test_binop.py]=1 # need to fix tryelse + [test_cgi.py]=1 # need to fix tryelse + [test_codecs.py]=1 # need to fix tryelse + [test_decorators.py]=1 # Syntax error decorators? + [test_dis.py]=1 # We change line numbers - duh! + [test_extcall.py]=1 # TypeError: saboteur() takes no arguments (1 given) + [test_format.py]=1 # Control flow? + [test_grp.py]=1 # Long test - might work Control flow? + [test_import.py]=1 # Control flow? + [test_long_future.py]=1 # Control flow? + [test_math.py]=1 # Control flow? + [test_pwd.py]=1 # Long test - might work? Control flow? + [test_queue.py]=1 # Control flow? + [test_sax.py]=1 # Control flow? + # [test_threading.py]=1 # Long test - works + [test_types.py]=1 # Control flow? + ) + ;; + 2.5) + SKIP_TESTS=( + [test_cgi.py]=1 # need to fix tryelse + [test_codecs.py]=1 # need to fix tryelse + [test_decorators.py]=1 # Syntax error decorators? + [test_dis.py]=1 # We change line numbers - duh! + [test_extcall.py]=1 # TypeError: saboteur() takes no arguments (1 given) + [test_format.py]=1 # Control flow? + [test_grp.py]=1 # Long test - might work Control flow? + [test_long_future.py]=1 # Control flow? + [test_math.py]=1 # Control flow? + [test_pwd.py]=1 # Long test - might work? Control flow? + [test_queue.py]=1 # Control flow? + [test_sax.py]=1 # Control flow? + [test_types.py]=1 # Control flow? + ) ;; 2.6) - SKIP_TESTS=( [test_array.py]=1 [test_asyncore.py]=1) + SKIP_TESTS=( + [test_binop.py]=1 # need to fix tryelse + [test_cmath.py]=1 # Control flow? + [test_codecs.py]=1 # need to fix tryelse + [test_coercion.py]=1 # Control flow? + [test_cookielib.py]=1 # Control flow? + [test_contextlib.py]=1 # decorators + [test_decorators.py]=1 # decorators + [test_enumerate.py]=1 # Control flow? + [test_file.py]=1 # Control flow? + [test_format.py]=1 # Control flow? + [test_frozen.py]=1 # Control flow? + [test_ftplib.py]=1 # Control flow? + [test_funcattrs.py]=1 # Control flow? + [test_future4.py]=1 # Possible additional rule for future mechanism? + [test_grammar.py]=1 # Syntax error -- look at + [test_grp.py]=1 # Long test - might work Control flow? + [test_pwd.py]=1 # Long test - might work? Control flow? + [test_queue.py]=1 # Control flow? + ) ;; 2.7) SKIP_TESTS=( [test_builtin.py]=1 [test_contextlib.py]=1 # decorators [test_decorators.py]=1 # decorators - [test_decimal.py]=1 [test_descr.py]=1 # syntax error look at [test_dis.py]=1 # We change line numbers - duh! + [test_future4.py]=1 # Possible additional rule for future mechanism? + [test_grammar.py]=1 # Long test look at + [test_importlib.py]=1 # Control flow? ) ;; *) diff --git a/uncompyle6/semantics/consts.py b/uncompyle6/semantics/consts.py index 30e57f8b..bb59fc60 100644 --- a/uncompyle6/semantics/consts.py +++ b/uncompyle6/semantics/consts.py @@ -112,12 +112,12 @@ TABLE_DIRECT = { (0, 'expr' ), ), 'get_iter': ( 'iter(%c)', (0, 'expr'), ), - 'slice0': ( '%c[:]', + 'slice0': ( '%c[:]', (0, 'expr'), ), - 'slice1': ( '%c[%p:]', + 'slice1': ( '%c[%p:]', (0, 'expr'), (1, 100) ), - 'slice2': ( '%c[:%p]', + 'slice2': ( '%c[:%p]', (0, 'expr'), (1, 100) ), 'slice3': ( '%c[%p:%p]', @@ -126,16 +126,16 @@ TABLE_DIRECT = { 'IMPORT_FROM': ( '%{pattr}', ), 'load_attr': ( '%c.%[1]{pattr}', - (0, 'expr')), + (0, 'expr')), 'LOAD_FAST': ( '%{pattr}', ), 'LOAD_NAME': ( '%{pattr}', ), 'LOAD_CLASSNAME': ( '%{pattr}', ), - 'LOAD_GLOBAL': ( '%{pattr}', ), - 'LOAD_DEREF': ( '%{pattr}', ), - 'LOAD_LOCALS': ( 'locals()', ), + 'LOAD_GLOBAL': ( '%{pattr}', ), + 'LOAD_DEREF': ( '%{pattr}', ), + 'LOAD_LOCALS': ( 'locals()', ), 'LOAD_ASSERT': ( '%{pattr}', ), - 'DELETE_FAST': ( '%|del %{pattr}\n', ), - 'DELETE_NAME': ( '%|del %{pattr}\n', ), + 'DELETE_FAST': ( '%|del %{pattr}\n', ), + 'DELETE_NAME': ( '%|del %{pattr}\n', ), 'DELETE_GLOBAL': ( '%|del %{pattr}\n', ), 'delete_subscr': ( '%|del %c[%c]\n', 0, 1,), 'subscript': ( '%c[%p]', @@ -144,23 +144,23 @@ TABLE_DIRECT = { 'subscript2': ( '%c[%c]', (0, 'expr'), (1, 'expr') ), - 'store_subscr': ( '%c[%c]', 0, 1), - 'STORE_FAST': ( '%{pattr}', ), - 'STORE_NAME': ( '%{pattr}', ), - 'STORE_GLOBAL': ( '%{pattr}', ), - 'STORE_DEREF': ( '%{pattr}', ), - 'unpack': ( '%C%,', (1, maxint, ', ') ), + 'store_subscr': ( '%c[%c]', 0, 1), + 'STORE_FAST': ( '%{pattr}', ), + 'STORE_NAME': ( '%{pattr}', ), + 'STORE_GLOBAL': ( '%{pattr}', ), + 'STORE_DEREF': ( '%{pattr}', ), + 'unpack': ( '%C%,', (1, maxint, ', ') ), # This nonterminal we create on the fly in semantic routines 'unpack_w_parens': ( '(%C%,)', (1, maxint, ', ') ), # This nonterminal we create on the fly in semantic routines - 'load_attr': ( '(%c).%[1]{pattr}', + 'load_attr_w_parens': ( '(%c).%[1]{pattr}', (0, 'expr')), - 'unpack_list': ( '[%C]', + 'unpack_list': ( '[%C]', (1, maxint, ', ') ), - 'build_tuple2': ( '%P', + 'build_tuple2': ( '%P', (0, -1, ', ', 100) ), 'list_iter': ( '%c', 0 ), diff --git a/uncompyle6/semantics/pysource.py b/uncompyle6/semantics/pysource.py index cc24287b..e9d1e2c7 100644 --- a/uncompyle6/semantics/pysource.py +++ b/uncompyle6/semantics/pysource.py @@ -1879,7 +1879,8 @@ class SourceWalker(GenericASTTraversal, object): n_unpack_w_parens = n_unpack def n_load_attr(self, node): - if node[0] == 'LOAD_CONST': + if (node[0] == 'LOAD_CONST' or + node[0] == 'expr' and node[0][0] == 'LOAD_CONST'): node.kind = 'load_attr_w_parens' self.default(node)