From 59780483a889031f40d9122c48bc3328b1835ee6 Mon Sep 17 00:00:00 2001 From: rocky Date: Mon, 20 Jun 2016 17:14:46 -0400 Subject: [PATCH] Python 3.x class bug using subclass fns --- test/bytecode_3.4/07_classderef.pyc-notyet | Bin 0 -> 453 bytes test/bytecode_3.4/11_classbug_subclass_fn.pyc | Bin 0 -> 343 bytes test/simple_source/def/07_classderef.py | 7 +++++++ test/simple_source/def/11_classbug_subclass_fn.py | 5 +++++ uncompyle6/parsers/parse3.py | 6 ++++-- 5 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 test/bytecode_3.4/07_classderef.pyc-notyet create mode 100644 test/bytecode_3.4/11_classbug_subclass_fn.pyc create mode 100644 test/simple_source/def/07_classderef.py create mode 100644 test/simple_source/def/11_classbug_subclass_fn.py diff --git a/test/bytecode_3.4/07_classderef.pyc-notyet b/test/bytecode_3.4/07_classderef.pyc-notyet new file mode 100644 index 0000000000000000000000000000000000000000..f054281e3948f7da35b297f3ee22cdd90948478f GIT binary patch literal 453 zcmY*V!AiqG5S>kGO+yQw1i?e`mP_l+ODRIJ-lEWo*vk?(8?B^G-AxV^Jt_JF{)7jA zC|B=(fG6LiwCJ$&W_I?y8D_tmE&puq_VSa6zTg{kkR8MA4j{%6^g=X2;?O8?l|Y$| zc{R8Tw{5`b8&M*d59Vvd&xxL0dJ^;~SQ{$PHnwhLcTv(90U^+#cc9CCMuGFt9tJEUqIC5#@nvLg zatN&apg@$~`f7NKp94FcEg-X5VU+I1I_VxBNtH&{#@gtlvsjj`e}lImv-}H9VYU&_ zvz}ewX_W_#;m4|4bq~aetBAE<<0Z?#&#(y{Cpi-%r3 literal 0 HcmV?d00001 diff --git a/test/bytecode_3.4/11_classbug_subclass_fn.pyc b/test/bytecode_3.4/11_classbug_subclass_fn.pyc new file mode 100644 index 0000000000000000000000000000000000000000..429842bc53f80042af04c20c36e3600f871b2e19 GIT binary patch literal 343 zcmYLDu};G<5Ix5!4N)rb8>vvM?g({b>rx~nGo0Mm1*D`kb}ZDnd;&kgFL_~LV&Mar zI6I=8e9zDJd(Zb>P0Ek^$GbNG_@qA7h}e?aO$ih&1}(ttjmkiAc%=&tnt{&X$l%C9 za8Nm{>(LkKp=Nkb03Az_)j8@p`Uao2$3dEi4G-4j>7iUd>FxrJYZsL61Ti^8F>LmF8ZD0j?Lvb|>cO4^BT*-a`j0R0y literal 0 HcmV?d00001 diff --git a/test/simple_source/def/07_classderef.py b/test/simple_source/def/07_classderef.py new file mode 100644 index 00000000..73881f6c --- /dev/null +++ b/test/simple_source/def/07_classderef.py @@ -0,0 +1,7 @@ +# From 3.4 ctypes/__init__.py +# For opcode LOAD_CLASSDEREF + +def CFUNCTYPE(argtypes): + class CFunctionType(object): + _argtypes_ = argtypes + return CFunctionType diff --git a/test/simple_source/def/11_classbug_subclass_fn.py b/test/simple_source/def/11_classbug_subclass_fn.py new file mode 100644 index 00000000..05415a67 --- /dev/null +++ b/test/simple_source/def/11_classbug_subclass_fn.py @@ -0,0 +1,5 @@ +# From python 3.4 endian.py +# Bug was having two CALL_FUNCTION ops in bytecode. +from ctypes import * +class _swapped_meta(type(Structure)): + pass diff --git a/uncompyle6/parsers/parse3.py b/uncompyle6/parsers/parse3.py index 08838e90..9cc35b7a 100644 --- a/uncompyle6/parsers/parse3.py +++ b/uncompyle6/parsers/parse3.py @@ -400,9 +400,11 @@ class Python3Parser(PythonParser): call_function)) self.add_unique_rule(rule, opname, token.attr, customize) - # Can the above build_class rule be folded into this rule? + # FIXME: What's the deal with the two rules? Different Python versions? + # Different situations? Note that the above rule is based on the CALL_FUNCTION + # token found, while this one doesn't. rule = ("build_class ::= LOAD_BUILD_CLASS mkfunc expr call_function " - "CALL_FUNCTION_" + str(args_pos+1)) + "CALL_FUNCTION_3") self.add_unique_rule(rule, opname, token.attr, customize) return