Skip to content

Commit

Permalink
Address MAKE_FUNCTION 3.4 bug
Browse files Browse the repository at this point in the history
  • Loading branch information
rocky committed Mar 28, 2024
1 parent ac3315c commit 93e3510
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
Binary file removed test/bytecode-3.5/test_call_ex_kw.pyc
Binary file not shown.
8 changes: 4 additions & 4 deletions test/examples/functions/test_call_ex_kw.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ def posonly_sum(pos_arg1, *arg, **kwarg):
# The stack order from least- to most-recent is:
# default, keyword, annotation, closure
# This changes in between Python 3.5 and 3.6.
def f(a, b: 1, c: 2, d, e: 3 = 4, f=5, *g: 6, h: 7, i=8, j: 9 = 10, **k: 11) -> 12:
pass
def f(a, b: int, c: int, d, e: int = 4, f=5, *g: int, h: int, i=int, j: int = 10, **k: dict) -> int:
return 12


assert f.__annotations__ == {
Expand All @@ -97,8 +97,8 @@ def f(a, b: 1, c: 2, d, e: 3 = 4, f=5, *g: 6, h: 7, i=8, j: 9 = 10, **k: 11) ->
"g": 6,
"h": 7,
"j": 9,
"k": 11,
"return": 12,
"k": {},
"return": int,
}

# From 3.6.9 test_keywordonly.py
Expand Down
10 changes: 8 additions & 2 deletions xpython/byteop/byteop34.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,14 @@ def MAKE_FUNCTION(self, argc: int):
annotate_names = self.vm.pop()
# annotate count includes +1 for the above names
annotate_objects = self.vm.popn(annotate_count - 1)
n = len(annotate_names)
assert n == len(annotate_objects)
n = len(annotate_objects)
# We can annotate a function return value, but
# that does is not a parameter object and not
# listed in annotate_objects
if annotate_names[-1] == "return":
assert n == len(annotate_names) - 1
else:
assert n == len(annotate_names)
annotations = {annotate_names[i]: annotate_objects[i] for i in range(n)}
else:
annotations = {}
Expand Down

0 comments on commit 93e3510

Please sign in to comment.