Issue #7830: Flatten nested functools.partial.

This commit is contained in:
Alexander Belopolsky 2015-03-01 15:08:17 -05:00
parent e2e178e081
commit e49af34151
4 changed files with 68 additions and 7 deletions

View file

@ -241,6 +241,14 @@ def partial(func, *args, **keywords):
"""New function with partial application of the given arguments
and keywords.
"""
if hasattr(func, 'func'):
args = func.args + args
tmpkw = func.keywords.copy()
tmpkw.update(keywords)
keywords = tmpkw
del tmpkw
func = func.func
def newfunc(*fargs, **fkeywords):
newkeywords = keywords.copy()
newkeywords.update(fkeywords)