Better 3.7 CALL_METHOD_KW handling

- Handles positional args now
This commit is contained in:
rocky
2021-11-23 04:50:08 -05:00
parent 3a63847d22
commit 211c74c240
3 changed files with 33 additions and 9 deletions

View File

@@ -1,10 +1,21 @@
"""This program is self-checking!"""
class C:
def sort(self, l, reverse, key_fn):
# PyPy example of CALL_METHOD_KW 2
# 2 keyword arguments and no positional arguments
return l.sort(reverse=reverse, key=key_fn)
def lcase(s):
return s.lower()
x = C()
l = ["xyz", "ABC"]
l.sort(key=lcase)
# Another PyPy example of CALL_METHOD_KW 2
# 2 keyword arguments and one positional argument
x.sort(l, reverse=False, key_fn=lcase)
assert l == ["ABC", "xyz"]