]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #18539: Calltips now work for float default arguments.
authorTerry Jan Reedy <tjreedy@udel.edu>
Fri, 26 Jul 2013 22:21:32 +0000 (18:21 -0400)
committerTerry Jan Reedy <tjreedy@udel.edu>
Fri, 26 Jul 2013 22:21:32 +0000 (18:21 -0400)
Lib/idlelib/CallTips.py
Lib/idlelib/idle_test/test_calltips.py
Misc/NEWS

index 0fdef11c6991fd1189e6060e5b3b344af401ab5b..c29f89bc0dddc979bd5f9b2eb0ff2a22a163645c 100644 (file)
@@ -163,7 +163,7 @@ def get_arg_text(ob):
             if fob.func_code.co_flags & 0x8:
                 items.append("***")
             arg_text = ", ".join(items)
-            arg_text = "(%s)" % re.sub("\.\d+", "<tuple>", arg_text)
+            arg_text = "(%s)" % re.sub("(?<!\d)\.\d+", "<tuple>", arg_text)
         # See if we can use the docstring
         doc = getattr(ob, "__doc__", "")
         if doc:
index 1733d392b350d380d38a99e2a64fa3be73454add..e0f1665fa71feeeb0b305f0d506a899d9918246d 100644 (file)
@@ -10,5 +10,11 @@ class Test_get_entity(unittest.TestCase):
     def test_good_entity(self):
         self.assertIs(CTi.get_entity('int'), int)
 
+class Py2Test(unittest.TestCase):
+    def test_paramtuple_float(self):
+        # 18539: (a,b) becomes '.0' in code object; change that but not float
+        def f((a,b), c=0.0): pass
+        self.assertEqual(ct.get_arg_text(f), '(<tuple>, c=0.0)')
+
 if __name__ == '__main__':
     unittest.main(verbosity=2, exit=False)
index e02d23d91f6a061230e998d1a05d6cee31a1e82b..2519380288897936d64d4885b65940e789784818 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -104,6 +104,8 @@ IDLE
   changed when it has not been changed. This fix followed the addition of a
   test file originally written by Phil Webster (the issue's main goal).
 
+- Issue #18539: Calltips now work for float default arguments.
+
 - Issue #7136: In the Idle File menu, "New Window" is renamed "New File".
   Patch by Tal Einat, Roget Serwy, and Todd Rovito.