You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Track important changes to xdis
Annotation counts have changed. EXTENDED_ARGS adjustment in instructions have been corrected.
This commit is contained in:
@@ -16,12 +16,6 @@ class Python33Parser(Python32Parser):
|
||||
stmt ::= genexpr_func
|
||||
"""
|
||||
|
||||
def p_33_function_def(self, args):
|
||||
"""
|
||||
annotate_pair ::= LOAD_NAME LOAD_CONST
|
||||
|
||||
"""
|
||||
|
||||
def customize_grammar_rules(self, tokens, customize):
|
||||
self.remove_rules(
|
||||
"""
|
||||
|
@@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2015-2019, 2021-2023 by Rocky Bernstein
|
||||
# Copyright (c) 2015-2019, 2021-2024 by Rocky Bernstein
|
||||
# Copyright (c) 2005 by Dan Pascu <dan@windowmaker.org>
|
||||
# Copyright (c) 2000-2002 by hartmut Goebel <h.goebel@crazy-compilers.com>
|
||||
#
|
||||
@@ -482,7 +482,6 @@ class Scanner3(Scanner):
|
||||
|
||||
last_op_was_break = False
|
||||
new_tokens = []
|
||||
operand_value = 0
|
||||
|
||||
for i, inst in enumerate(self.insts):
|
||||
opname = inst.opname
|
||||
@@ -534,11 +533,9 @@ class Scanner3(Scanner):
|
||||
op = inst.opcode
|
||||
|
||||
if opname == "EXTENDED_ARG":
|
||||
if i + 1 < n:
|
||||
operand_value = argval << 16
|
||||
continue
|
||||
else:
|
||||
operand_value = 0
|
||||
# EXTEND_ARG adjustments to the operand value should have
|
||||
# already been accounted for in xdis instruction creation.
|
||||
continue
|
||||
|
||||
if inst.offset in jump_targets:
|
||||
jump_idx = 0
|
||||
@@ -645,7 +642,7 @@ class Scanner3(Scanner):
|
||||
attr = attr[:4] # remove last value: attr[5] == False
|
||||
else:
|
||||
pos_args, name_pair_args, annotate_args = parse_fn_counts_30_35(
|
||||
inst.argval + operand_value
|
||||
inst.argval
|
||||
)
|
||||
|
||||
pattr = f"{pos_args} positional, {name_pair_args} keyword only, {annotate_args} annotated"
|
||||
|
@@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2015-2021 by Rocky Bernstein
|
||||
# Copyright (c) 2015-2021, 2024 by Rocky Bernstein
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -16,18 +16,18 @@
|
||||
All the crazy things we have to do to handle Python functions in 3.0-3.5 or so.
|
||||
The saga of changes before and after is in other files.
|
||||
"""
|
||||
from xdis import iscode, code_has_star_arg, code_has_star_star_arg, CO_GENERATOR
|
||||
from uncompyle6.scanner import Code
|
||||
from uncompyle6.parsers.treenode import SyntaxTree
|
||||
from uncompyle6.semantics.parser_error import ParserError
|
||||
from xdis import CO_GENERATOR, code_has_star_arg, code_has_star_star_arg, iscode
|
||||
|
||||
from uncompyle6.parser import ParserError as ParserError2
|
||||
from uncompyle6.parsers.treenode import SyntaxTree
|
||||
from uncompyle6.scanner import Code
|
||||
from uncompyle6.semantics.helper import (
|
||||
print_docstring,
|
||||
find_all_globals,
|
||||
find_globals_and_nonlocals,
|
||||
find_none,
|
||||
print_docstring,
|
||||
)
|
||||
|
||||
from uncompyle6.semantics.parser_error import ParserError
|
||||
from uncompyle6.show import maybe_show_tree_param_default
|
||||
|
||||
# FIXME: DRY the below code...
|
||||
@@ -42,8 +42,8 @@ def make_function3_annotate(
|
||||
|
||||
def build_param(ast, name, default):
|
||||
"""build parameters:
|
||||
- handle defaults
|
||||
- handle format tuple parameters
|
||||
- handle defaults
|
||||
- handle format tuple parameters
|
||||
"""
|
||||
if default:
|
||||
value = self.traverse(default, indent="")
|
||||
@@ -300,7 +300,7 @@ def make_function3_annotate(
|
||||
|
||||
def make_function3(self, node, is_lambda, nested=1, code_node=None):
|
||||
"""Dump function definition, doc string, and function body in
|
||||
Python version 3.0 and above
|
||||
Python version 3.0 and above
|
||||
"""
|
||||
|
||||
# For Python 3.3, the evaluation stack in MAKE_FUNCTION is:
|
||||
@@ -333,8 +333,8 @@ def make_function3(self, node, is_lambda, nested=1, code_node=None):
|
||||
|
||||
def build_param(ast, name, default, annotation=None):
|
||||
"""build parameters:
|
||||
- handle defaults
|
||||
- handle format tuple parameters
|
||||
- handle defaults
|
||||
- handle format tuple parameters
|
||||
"""
|
||||
value = self.traverse(default, indent="")
|
||||
maybe_show_tree_param_default(self.showast, name, value)
|
||||
@@ -419,7 +419,6 @@ def make_function3(self, node, is_lambda, nested=1, code_node=None):
|
||||
pass
|
||||
|
||||
if len(node) > 2 and (have_kwargs or node[lc_index].kind != "load_closure"):
|
||||
|
||||
# Find the index in "node" where the first default
|
||||
# parameter value is located. Note this is in contrast to
|
||||
# key-word arguments, pairs of (name, value), which appear after "*".
|
||||
@@ -492,8 +491,6 @@ def make_function3(self, node, is_lambda, nested=1, code_node=None):
|
||||
self.ERROR = p
|
||||
return
|
||||
|
||||
kw_pairs = 0
|
||||
|
||||
i = len(paramnames) - len(defparams)
|
||||
|
||||
# build parameters
|
||||
|
Reference in New Issue
Block a user