@@ -1022,16 +1022,45 @@ def byte_MAKE_CLOSURE(self, argc):
1022
1022
fn = Function (name , code , globs , defaults , closure , self )
1023
1023
self .push (fn )
1024
1024
1025
+ def byte_CALL_FUNCTION_EX (self , arg ):
1026
+ # Calls a function. The lowest bit of flags indicates whether the
1027
+ # var-keyword argument is placed at the top of the stack. Below
1028
+ # the var-keyword argument, the var-positional argument is on the
1029
+ # stack. Below the arguments, the function object to call is placed.
1030
+ # Pops all function arguments, and the function itself off the stack,
1031
+ # and pushes the return value.
1032
+ # Note that this opcode pops at most three items from the stack.
1033
+ #Var-positional and var-keyword arguments are packed by
1034
+ #BUILD_TUPLE_UNPACK_WITH_CALL and BUILD_MAP_UNPACK_WITH_CALL.
1035
+ # new in 3.6
1036
+ varkw = self .pop () if (arg & 0x1 ) else {}
1037
+ varpos = self .pop ()
1038
+ return self .call_function (0 , varpos , varkw )
1039
+
1025
1040
def byte_CALL_FUNCTION (self , arg ):
1041
+ # Calls a function. argc indicates the number of positional arguments.
1042
+ # The positional arguments are on the stack, with the right-most
1043
+ # argument on top. Below the arguments, the function object to call is
1044
+ # on the stack. Pops all function arguments, and the function itself
1045
+ # off the stack, and pushes the return value.
1046
+ # 3.6: Only used for calls with positional args
1026
1047
return self .call_function (arg , [], {})
1027
1048
1028
1049
def byte_CALL_FUNCTION_VAR (self , arg ):
1029
1050
args = self .pop ()
1030
1051
return self .call_function (arg , args , {})
1031
1052
1032
- def byte_CALL_FUNCTION_KW (self , arg ):
1033
- kwargs = self .pop ()
1034
- return self .call_function (arg , [], kwargs )
1053
+ def byte_CALL_FUNCTION_KW (self , argc ):
1054
+ if not (six .PY3 and sys .version_info .minor >= 6 ):
1055
+ kwargs = self .pop ()
1056
+ return self .call_function (arg , [], kwargs )
1057
+ # changed in 3.6: keyword arguments are packed in a tuple instead
1058
+ # of a dict. argc indicates total number of args.
1059
+ kwargnames = self .pop ()
1060
+ lkwargs = len (kwargnames )
1061
+ kwargs = self .popn (lkwargs )
1062
+ arg = argc - lkwargs
1063
+ return self .call_function (arg , [], dict (zip (kwargnames , kwargs )))
1035
1064
1036
1065
def byte_CALL_FUNCTION_VAR_KW (self , arg ):
1037
1066
args , kwargs = self .popn (2 )
0 commit comments