From 3730946a1a9bb90b5d6e1109c63f69eac10a4cb0 Mon Sep 17 00:00:00 2001 From: rocky Date: Mon, 22 Apr 2019 21:18:17 -0400 Subject: [PATCH] Add semantic rule for 3.x "conditionalnot" --- test/bytecode_3.3_run/08_if_else.pyc | Bin 0 -> 460 bytes test/bytecode_3.6_run/08_if_else.pyc | Bin 0 -> 333 bytes test/simple_source/bug33/08_if_else.py | 10 ++++++++++ test/simple_source/bug36/08_comp_gen_for.py | 1 + uncompyle6/semantics/customize3.py | 18 ++++++++++-------- 5 files changed, 21 insertions(+), 8 deletions(-) create mode 100644 test/bytecode_3.3_run/08_if_else.pyc create mode 100644 test/bytecode_3.6_run/08_if_else.pyc create mode 100644 test/simple_source/bug33/08_if_else.py diff --git a/test/bytecode_3.3_run/08_if_else.pyc b/test/bytecode_3.3_run/08_if_else.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1a1b60be3a1704455927eba88954199943780fc6 GIT binary patch literal 460 zcmb7AJxc^J5PjL*^9%J_!9uLu$`h`!5K+W-8w){&1vl{s?rn}tQV3_``8)gp{s@1Y zGdW$gG%zodmznn_dE4CDc-J3yg#sGjKTsinc!mvIzY(r zl6aj#=gCw*I)H4dsVKme#7o*WsDLR9JI$U=Y5C(vFg?(VTOgD73PY& zrLjsFbLlaml>WHNFm*b%hGMbIspK6A;y!0&r?b}7K$|H*d4?IQg_+4+a6gVQ&VauLV34vO|kjz2gE1S|DuUS@Ee?Z%AOZ zHFmJlEfVgu_?OYQa1ZHdzLfZWlyJnYfKPDQK7NFa5a2Po`08Sr qF1F}mQoN;m!$l(;-Y}E%MP1!FSG)e&9>u6|aP`+|_Me`ZBm4y$h(#U% literal 0 HcmV?d00001 diff --git a/test/simple_source/bug33/08_if_else.py b/test/simple_source/bug33/08_if_else.py new file mode 100644 index 00000000..1e60bb94 --- /dev/null +++ b/test/simple_source/bug33/08_if_else.py @@ -0,0 +1,10 @@ +# From python 3.3.7 trace +# Bug was not having not having semantic rule for conditional not + +# RUNNABLE! +def init(modules=None): + mods = set() if not modules else set(modules) + return mods + +assert init() == set() +assert init([1, 2, 3]) == set([1, 2, 3]) diff --git a/test/simple_source/bug36/08_comp_gen_for.py b/test/simple_source/bug36/08_comp_gen_for.py index 496cc6ef..20c64bb9 100644 --- a/test/simple_source/bug36/08_comp_gen_for.py +++ b/test/simple_source/bug36/08_comp_gen_for.py @@ -1,6 +1,7 @@ # Bug in 3.3 weakset # Bug was not having a rule for 3.x "comp_for" +# RUNNABLE! class WeakSet: def __init__(self, data=None): self.data = set(data) diff --git a/uncompyle6/semantics/customize3.py b/uncompyle6/semantics/customize3.py index 791a4585..186e278a 100644 --- a/uncompyle6/semantics/customize3.py +++ b/uncompyle6/semantics/customize3.py @@ -27,15 +27,17 @@ from uncompyle6.semantics.customize38 import customize_for_version38 def customize_for_version3(self, version): TABLE_DIRECT.update({ - 'except_cond2': ( '%|except %c as %c:\n', 1, 5 ), - 'function_def_annotate': ( '\n\n%|def %c%c\n', -1, 0), - 'comp_for' : ( ' for %c in %c', + 'comp_for' : ( ' for %c in %c', (2, 'store') , (0, 'expr') ), - 'importmultiple': ( '%|import %c%c\n', 2, 3 ), - 'import_cont' : ( ', %c', 2 ), - 'store_locals': ( '%|# inspect.currentframe().f_locals = __locals__\n', ), - 'withstmt': ( '%|with %c:\n%+%c%-', 0, 3), - 'withasstmt': ( '%|with %c as (%c):\n%+%c%-', 0, 2, 3), + 'conditionalnot' : ( '%c if not %c else %c', + (2, 'expr') , (0, 'expr'), (4, 'expr') ), + 'except_cond2' : ( '%|except %c as %c:\n', 1, 5 ), + 'function_def_annotate': ( '\n\n%|def %c%c\n', -1, 0), + 'importmultiple' : ( '%|import %c%c\n', 2, 3 ), + 'import_cont' : ( ', %c', 2 ), + 'store_locals' : ( '%|# inspect.currentframe().f_locals = __locals__\n', ), + 'withstmt' : ( '%|with %c:\n%+%c%-', 0, 3), + 'withasstmt' : ( '%|with %c as (%c):\n%+%c%-', 0, 2, 3), }) assert version >= 3.0