diff --git a/test/bytecode_3.1/04_call_function.pyc b/test/bytecode_3.1/04_call_function.pyc index ab1ceeb2..9fb34a44 100644 Binary files a/test/bytecode_3.1/04_call_function.pyc and b/test/bytecode_3.1/04_call_function.pyc differ diff --git a/test/bytecode_3.4_run/04_call_function.pyc b/test/bytecode_3.4_run/04_call_function.pyc index b62f3903..bc22314e 100644 Binary files a/test/bytecode_3.4_run/04_call_function.pyc and b/test/bytecode_3.4_run/04_call_function.pyc differ diff --git a/test/bytecode_3.5_run/04_call_function.pyc b/test/bytecode_3.5_run/04_call_function.pyc index 25f663e6..5e2ef8e8 100644 Binary files a/test/bytecode_3.5_run/04_call_function.pyc and b/test/bytecode_3.5_run/04_call_function.pyc differ diff --git a/test/bytecode_3.6_run/04_call_function.pyc b/test/bytecode_3.6_run/04_call_function.pyc index ccdc2666..ae64294d 100644 Binary files a/test/bytecode_3.6_run/04_call_function.pyc and b/test/bytecode_3.6_run/04_call_function.pyc differ diff --git a/test/simple_source/bug35/04_call_function.py b/test/simple_source/bug35/04_call_function.py index a4cf5101..9a41deef 100644 --- a/test/simple_source/bug35/04_call_function.py +++ b/test/simple_source/bug35/04_call_function.py @@ -1,5 +1,6 @@ # From sql/schema.py and 3.5 _strptime.py -# Note that kwargs comes before "positional" args +# Bug was code not knowing which Python versions +# have kwargs coming before positional args in code. # RUNNABLE! @@ -68,3 +69,13 @@ def assertRaisesConversion(self, *args): class BlockingIOError(IOError): def __init__(self, errno, strerror, characters_written=5): super().__init__(errno, strerror) + +# From urllib/parse.py +# Bug was using a subclass made from a call (to namedtuple) +from collections import namedtuple + +class ResultMixin(object): + pass + +class SplitResult(namedtuple('SplitResult', 'scheme netloc path query fragment'), ResultMixin): + pass diff --git a/uncompyle6/parsers/parse3.py b/uncompyle6/parsers/parse3.py index c9d4414c..2e54cc16 100644 --- a/uncompyle6/parsers/parse3.py +++ b/uncompyle6/parsers/parse3.py @@ -116,9 +116,14 @@ class Python3Parser(PythonParser): classdef ::= build_class store + # FIXME: we need to add these because don't detect this properly + # in custom rules. Specifically if one of the exprs is CALL_FUNCTION + # then we'll mistake that for the final CALL_FUNCTION. + # We can fix by triggering on the CALL_FUNCTION op # Python3 introduced LOAD_BUILD_CLASS # Other definitions are in a custom rule build_class ::= LOAD_BUILD_CLASS mkfunc expr call CALL_FUNCTION_3 + build_class ::= LOAD_BUILD_CLASS mkfunc expr call expr CALL_FUNCTION_4 stmt ::= classdefdeco classdefdeco ::= classdefdeco1 store @@ -423,7 +428,7 @@ class Python3Parser(PythonParser): LOAD_CONST CALL_FUNCTION_n build_class ::= LOAD_BUILD_CLASS mkfunc expr - call_function + call CALL_FUNCTION_3 ''' # FIXME: I bet this can be simplified diff --git a/uncompyle6/semantics/pysource.py b/uncompyle6/semantics/pysource.py index 4cd57076..51aae2ed 100644 --- a/uncompyle6/semantics/pysource.py +++ b/uncompyle6/semantics/pysource.py @@ -1409,12 +1409,13 @@ class SourceWalker(GenericASTTraversal, object): i = n - (len(kwargs)+1) j = 1 + n - node[n].attr else: - for i in range(n-2, 0, -1): - if not node[i].kind in ['expr', 'LOAD_CLASSNAME']: + start = n-2 + for i in range(start, 0, -1): + if not node[i].kind in ['expr', 'call', 'LOAD_CLASSNAME']: break pass - if i == n-2: + if i == start: return i += 2