1
- # Copyright (c) 2015-2021 by Rocky Bernstein
1
+ # Copyright (c) 2015-2021, 2024 by Rocky Bernstein
2
2
#
3
3
# This program is free software: you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
16
16
All the crazy things we have to do to handle Python functions in 3.0-3.5 or so.
17
17
The saga of changes before and after is in other files.
18
18
"""
19
- from xdis import iscode , code_has_star_arg , code_has_star_star_arg , CO_GENERATOR
20
- from uncompyle6 .scanner import Code
21
- from uncompyle6 .parsers .treenode import SyntaxTree
22
- from uncompyle6 .semantics .parser_error import ParserError
19
+ from xdis import CO_GENERATOR , code_has_star_arg , code_has_star_star_arg , iscode
20
+
23
21
from uncompyle6 .parser import ParserError as ParserError2
22
+ from uncompyle6 .parsers .treenode import SyntaxTree
23
+ from uncompyle6 .scanner import Code
24
24
from uncompyle6 .semantics .helper import (
25
- print_docstring ,
26
25
find_all_globals ,
27
26
find_globals_and_nonlocals ,
28
27
find_none ,
28
+ print_docstring ,
29
29
)
30
-
30
+ from uncompyle6 . semantics . parser_error import ParserError
31
31
from uncompyle6 .show import maybe_show_tree_param_default
32
32
33
33
# FIXME: DRY the below code...
@@ -42,8 +42,8 @@ def make_function3_annotate(
42
42
43
43
def build_param (ast , name , default ):
44
44
"""build parameters:
45
- - handle defaults
46
- - handle format tuple parameters
45
+ - handle defaults
46
+ - handle format tuple parameters
47
47
"""
48
48
if default :
49
49
value = self .traverse (default , indent = "" )
@@ -300,7 +300,7 @@ def build_param(ast, name, default):
300
300
301
301
def make_function3 (self , node , is_lambda , nested = 1 , code_node = None ):
302
302
"""Dump function definition, doc string, and function body in
303
- Python version 3.0 and above
303
+ Python version 3.0 and above
304
304
"""
305
305
306
306
# 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):
333
333
334
334
def build_param (ast , name , default , annotation = None ):
335
335
"""build parameters:
336
- - handle defaults
337
- - handle format tuple parameters
336
+ - handle defaults
337
+ - handle format tuple parameters
338
338
"""
339
339
value = self .traverse (default , indent = "" )
340
340
maybe_show_tree_param_default (self .showast , name , value )
@@ -419,7 +419,6 @@ def build_param(ast, name, default, annotation=None):
419
419
pass
420
420
421
421
if len (node ) > 2 and (have_kwargs or node [lc_index ].kind != "load_closure" ):
422
-
423
422
# Find the index in "node" where the first default
424
423
# parameter value is located. Note this is in contrast to
425
424
# key-word arguments, pairs of (name, value), which appear after "*".
@@ -492,8 +491,6 @@ def build_param(ast, name, default, annotation=None):
492
491
self .ERROR = p
493
492
return
494
493
495
- kw_pairs = 0
496
-
497
494
i = len (paramnames ) - len (defparams )
498
495
499
496
# build parameters
0 commit comments