Closes Issue 21659: Improve Idle calltips for *args, **kwargs in 2.7, where actual
names are not available. Initial patch by Serhiy Storchaka.
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 @@
         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)