summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib/CallTips.py
diff options
context:
space:
mode:
authorTerry Jan Reedy <tjreedy@udel.edu>2014-06-10 00:02:18 (GMT)
committerTerry Jan Reedy <tjreedy@udel.edu>2014-06-10 00:02:18 (GMT)
commit1d6a0c47db70f56cee73932efe3e565b13488916 (patch)
treeae03e3dc1d15c60a5df0c1a06180e059ec8b60ac /Lib/idlelib/CallTips.py
parentdd35484662ee756e3aa092f49ff7d75051fee354 (diff)
downloadcpython-1d6a0c47db70f56cee73932efe3e565b13488916.zip
cpython-1d6a0c47db70f56cee73932efe3e565b13488916.tar.gz
cpython-1d6a0c47db70f56cee73932efe3e565b13488916.tar.bz2
Closes Issue 21659: Improve Idle calltips for *args, **kwargs in 2.7, where actual
names are not available. Initial patch by Serhiy Storchaka.
Diffstat (limited to 'Lib/idlelib/CallTips.py')
-rw-r--r--Lib/idlelib/CallTips.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/Lib/idlelib/CallTips.py b/Lib/idlelib/CallTips.py
index 0662880..3db2636 100644
--- a/Lib/idlelib/CallTips.py
+++ b/Lib/idlelib/CallTips.py
@@ -183,10 +183,16 @@ def get_arg_text(ob):
defaults = list(map(lambda name: "=%s" % repr(name), defaults))
defaults = [""] * (len(real_args) - len(defaults)) + defaults
items = map(lambda arg, dflt: arg + dflt, real_args, defaults)
- if fob.func_code.co_flags & 0x4:
- items.append("*args")
- if fob.func_code.co_flags & 0x8:
- items.append("**kwds")
+ for flag, pre, name in ((0x4, '*', 'args'), (0x8, '**', 'kwargs')):
+ if fob.func_code.co_flags & flag:
+ pre_name = pre + name
+ if name not in real_args:
+ items.append(pre_name)
+ else:
+ i = 1
+ while ((name+'%s') % i) in real_args:
+ i += 1
+ items.append((pre_name+'%s') % i)
argspec = ", ".join(items)
argspec = "(%s)" % re.sub("(?<!\d)\.\d+", "<tuple>", argspec)