This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Unsupported provider

classification
Title: Arguments tooltip wrong if def contains tuple
Type: Stage:
Components: IDLE Versions: Python 2.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: kbk Nosy List: ariel_bruner, kbk, ned.deily, terry.reedy, tzot
Priority: normal Keywords:

Created on 2003-08-20 15:16 by tzot, last changed 2022-04-10 16:10 by admin. This issue is now closed.

Messages (9)
msg17853 - (view) Author: Χρήστος Γεωργίου (Christos Georgiou) (tzot) * Date: 2003-08-20 15:16
This happens in IDLE on Windows 2000, from 2.3 EXE 
installer.  Type the following:

>>> def f((a,b), c):
	print a, b, c

>>> f(

The tooltip shows up containing the following exact 
string (but the triple quotes):
"""(.0, c)"""
msg17854 - (view) Author: Χρήστος Γεωργίου (Christos Georgiou) (tzot) * Date: 2003-08-20 15:44
Logged In: YES 
user_id=539787

Quite fast, Neal! :)
It seems it's not exactly an IDLE bug; check ToolTip.py, line 
134 (vanilla 2.3); it's the f.func_code.co_varnames that 
returns this tuple:
('.0', 'c', 'a', 'b')
msg17855 - (view) Author: Χρήστος Γεωργίου (Christos Georgiou) (tzot) * Date: 2003-08-20 16:02
Logged In: YES 
user_id=539787

I tried this:

def f((a,b), c, (d,e)): pass

and f.func_code.co_varnames is

('.0', 'c', '.4', 'a', 'b', 'd', 'e')

That means .0 and .4 are dummy placeholders for the 
argument tuples.  I couldn't find a direct way to know the 
length of each tuple, though --unless one analyzes the first 
UNPACK_SEQUENCE bytecodes of fob.func_code.co_code, 
and then uses the tuple fob.func_code.co_varnames
[fob.func_code.co_argcount:] to recreate the tuples; should 
we get into this trouble, or just do a regular expression 
replace a la:

argText = "(%s)" % re.sub("\.\d+", "<tuple>", argText)

at line 144?
msg17856 - (view) Author: Kurt B. Kaiser (kbk) * (Python committer) Date: 2006-07-22 21:56
Logged In: YES 
user_id=149084

Problem still exists in 2.5 as of Rev 50739.
msg17857 - (view) Author: Kurt B. Kaiser (kbk) * (Python committer) Date: 2007-02-05 23:03
Used your idea of displaying "<tuple>'

Rev 53641
msg193597 - (view) Author: ariel brunner (ariel_bruner) Date: 2013-07-23 12:38
It seems like the solution has caused a different issue: now, when defining a function with factional default arguments, the <tuple> text replaces the correct values in the tooltip.

Here's an example -

>>> def f(a=0.5):
        pass
>>> f(

tooltip shows - "(a=0<tuple>)", i.e. replaces the ".5" with <tuple>.
msg193617 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2013-07-23 20:09
Ariel, if you think there is a problem, please open a new issue with all the pertinent information.  This issue was closed long ago.
msg193629 - (view) Author: ariel brunner (ariel_bruner) Date: 2013-07-24 08:40
I will, sorry. I thought it's possible reopen an issue. Since all the relevant information is already contained here, and since the problem is with the fix to the issue, I figured it's best to reopen this one.
msg193744 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2013-07-26 20:47
If someone pushes a patch and closes the issue and the buildbots break, reopening the issue is the appropriate response. Too much later and the pool of potentially interested people will have changed. Anyway, the new issue is #18539.
History
Date User Action Args
2022-04-10 16:10:44adminsetgithub: 39095
2013-07-26 20:47:04terry.reedysetnosy: + terry.reedy
messages: + msg193744
2013-07-24 08:40:17ariel_brunersetmessages: + msg193629
2013-07-23 20:09:13ned.deilysetnosy: + ned.deily
messages: + msg193617
2013-07-23 12:38:13ariel_brunersetnosy: + ariel_bruner
messages: + msg193597
2003-08-20 15:16:18tzotcreate