[ python-Bugs-791968 ] Arguments tooltip wrong if def contains tuple

SourceForge.net noreply at sourceforge.net
Tue Feb 6 00:03:14 CET 2007


Bugs item #791968, was opened at 2003-08-20 11:16
Message generated for change (Comment added) made by kbk
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=791968&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: IDLE
Group: Python 2.3
>Status: Closed
>Resolution: Fixed
Priority: 5
Private: No
Submitted By: Christos Georgiou (tzot)
Assigned to: Kurt B. Kaiser (kbk)
Summary: Arguments tooltip wrong if def contains tuple

Initial Comment:
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)"""


----------------------------------------------------------------------

>Comment By: Kurt B. Kaiser (kbk)
Date: 2007-02-05 18:03

Message:
Logged In: YES 
user_id=149084
Originator: NO

Used your idea of displaying "<tuple>'

Rev 53641

----------------------------------------------------------------------

Comment By: Kurt B. Kaiser (kbk)
Date: 2006-07-22 17:56

Message:
Logged In: YES 
user_id=149084

Problem still exists in 2.5 as of Rev 50739.

----------------------------------------------------------------------

Comment By: Christos Georgiou (tzot)
Date: 2003-08-20 12:02

Message:
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 = &quot;(%s)&quot; % re.sub(&quot;\.\d+&quot;,
&quot;&lt;tuple&gt;&quot;, argText)

at line 144?

----------------------------------------------------------------------

Comment By: Christos Georgiou (tzot)
Date: 2003-08-20 11:44

Message:
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')

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=791968&group_id=5470


More information about the Python-bugs-list mailing list