You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Slightly Python 3.x handing of subclasses...
which are created via a call to create a subclass. Should be more general though.
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user