mirror of
https://github.com/python/cpython.git
synced 2025-08-29 21:25:01 +00:00
Jiwon Seo's PEP 3102 implementation.
See SF#1549670. The compiler package has not yet been updated.
This commit is contained in:
parent
fc2a0a8e3c
commit
4f72a78684
31 changed files with 739 additions and 227 deletions
|
@ -378,6 +378,12 @@ class CodeGenerator:
|
|||
walk(node.code, gen)
|
||||
gen.finish()
|
||||
self.set_lineno(node)
|
||||
for keyword in node.kwonlyargs:
|
||||
default = keyword.expr
|
||||
if isinstance(default, ast.EmptyNode):
|
||||
continue
|
||||
self.emit('LOAD_CONST', keyword.name)
|
||||
self.visit(default)
|
||||
for default in node.defaults:
|
||||
self.visit(default)
|
||||
self._makeClosure(gen, len(node.defaults))
|
||||
|
@ -1320,7 +1326,9 @@ class AbstractFunctionCode:
|
|||
name = func.name
|
||||
|
||||
args, hasTupleArg = generateArgList(func.argnames)
|
||||
kwonlyargs = generateKwonlyArgList(func.kwonlyargs)
|
||||
self.graph = pyassem.PyFlowGraph(name, func.filename, args,
|
||||
kwonlyargs=kwonlyargs,
|
||||
optimized=1)
|
||||
self.isLambda = isLambda
|
||||
self.super_init()
|
||||
|
@ -1456,6 +1464,13 @@ def generateArgList(arglist):
|
|||
raise ValueError, "unexpect argument type:", elt
|
||||
return args + extra, count
|
||||
|
||||
def generateKwonlyArgList(keywordOnlyArgs):
|
||||
kwonlyargs = {}
|
||||
for elt in keywordOnlyArgs:
|
||||
assert isinstance(elt, ast.Keyword)
|
||||
kwonlyargs[elt.name] = elt.expr
|
||||
return kwonlyargs
|
||||
|
||||
def findOp(node):
|
||||
"""Find the op (DELETE, LOAD, STORE) in an AssTuple tree"""
|
||||
v = OpFinder()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue