[issue18539] Idle 2.7: Calltip wrong if def contains float default value

Terry J. Reedy report at bugs.python.org
Sat Jul 27 00:10:30 CEST 2013


Terry J. Reedy added the comment:

If you are the same 'ariel' as on SO, thank you for the detective work and the informative report here. Without it this 2.7-only bug would be low priority and might have sat open until we stopped patching 2.7.

The underlying issue is that a) 2.x had the 'feature' of allowing tuples of parameter names to signal automatic unpacking of tuples of arguments, and b) the unnamed tuple got a pseudoname of the form '.n' in the list of argument names, which calltips uses.

>>> def f((a,b), (c,d)): pass
>>> f.func_code.co_varnames
('.0', '.1', 'a', 'b', 'c', 'd')

Issue #791968 added the following line to change '.n' to '<tuple>'.
arg_text = "(%s)" % re.sub("\.\d+", "<tuple>", arg_text)
But this also changes float strings of form 'm.n' to 'm<tuple>'. The solution is to recognize the difference between the absence and presence of a preceding digit and not do the substitution in the latter case. Adding the negative lookbehind assertion (?<![0-9]) makes
  def f((a,b), c=0.0): 
produce (<tuple>, c=0.0). I am preparing a patch, including the test.

----------
assignee:  -> terry.reedy
nosy: +terry.reedy
stage:  -> test needed
title: Arguments tooltip wrong if def contains fractional default value -> Idle 2.7: Calltip wrong if def contains float default value

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18539>
_______________________________________


More information about the Python-bugs-list mailing list