summaryrefslogtreecommitdiff
path: root/Lib/functools.py
diff options
context:
space:
mode:
authorAlexander Belopolsky <alexander.belopolsky@gmail.com>2015-03-01 15:08:17 -0500
committerAlexander Belopolsky <alexander.belopolsky@gmail.com>2015-03-01 15:08:17 -0500
commite49af341518ba22186fc523ec23ccff462ab439e (patch)
tree0c426b6e661d637c14c2d9c467a99580b985fb4a /Lib/functools.py
parente2e178e081a621d2c1fd8ceb65ce7735b3036def (diff)
downloadcpython-git-e49af341518ba22186fc523ec23ccff462ab439e.tar.gz
Issue #7830: Flatten nested functools.partial.
Diffstat (limited to 'Lib/functools.py')
-rw-r--r--Lib/functools.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/functools.py b/Lib/functools.py
index 20a26f9a2c..91e9685b98 100644
--- a/Lib/functools.py
+++ b/Lib/functools.py
@@ -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)