Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arguments tooltip wrong if def contains tuple #39095

Closed
tzot mannequin opened this issue Aug 20, 2003 · 9 comments
Closed

Arguments tooltip wrong if def contains tuple #39095

tzot mannequin opened this issue Aug 20, 2003 · 9 comments
Assignees

Comments

@tzot
Copy link
Mannequin

tzot mannequin commented Aug 20, 2003

BPO 791968
Nosy @terryjreedy, @kbkaiser, @ned-deily

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/kbkaiser'
closed_at = <Date 2013-07-26.20:47:04.875>
created_at = <Date 2003-08-20.15:16:18.000>
labels = ['expert-IDLE']
title = 'Arguments tooltip wrong if def contains tuple'
updated_at = <Date 2013-07-26.20:47:04.875>
user = 'https://bugs.python.org/tzot'

bugs.python.org fields:

activity = <Date 2013-07-26.20:47:04.875>
actor = 'terry.reedy'
assignee = 'kbk'
closed = True
closed_date = None
closer = None
components = ['IDLE']
creation = <Date 2003-08-20.15:16:18.000>
creator = 'tzot'
dependencies = []
files = []
hgrepos = []
issue_num = 791968
keywords = []
message_count = 9.0
messages = ['17853', '17854', '17855', '17856', '17857', '193597', '193617', '193629', '193744']
nosy_count = 5.0
nosy_names = ['terry.reedy', 'kbk', 'tzot', 'ned.deily', 'ariel_bruner']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue791968'
versions = ['Python 2.3']

@tzot
Copy link
Mannequin Author

tzot mannequin commented Aug 20, 2003

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)"""

@tzot tzot mannequin closed this as completed Aug 20, 2003
@tzot tzot mannequin assigned kbkaiser Aug 20, 2003
@tzot tzot mannequin added the topic-IDLE label Aug 20, 2003
@tzot tzot mannequin closed this as completed Aug 20, 2003
@tzot tzot mannequin assigned kbkaiser Aug 20, 2003
@tzot tzot mannequin added the topic-IDLE label Aug 20, 2003
@tzot
Copy link
Mannequin Author

tzot mannequin commented Aug 20, 2003

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

@tzot
Copy link
Mannequin Author

tzot mannequin commented Aug 20, 2003

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?

@kbkaiser
Copy link
Contributor

Logged In: YES
user_id=149084

Problem still exists in 2.5 as of Rev 50739.

@kbkaiser
Copy link
Contributor

kbkaiser commented Feb 5, 2007

Used your idea of displaying "<tuple>'

Rev 53641

@ArielBruner
Copy link
Mannequin

ArielBruner mannequin commented Jul 23, 2013

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>.

@ned-deily
Copy link
Member

Ariel, if you think there is a problem, please open a new issue with all the pertinent information. This issue was closed long ago.

@ArielBruner
Copy link
Mannequin

ArielBruner mannequin commented Jul 24, 2013

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.

@terryjreedy
Copy link
Member

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 bpo-18539.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants