You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CallTips.py _find_constructor does not work #52131
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/terryjreedy'closed_at=<Date2014-01-21.21:01:46.907>created_at=<Date2010-02-08.12:11:42.101>labels= ['expert-IDLE', 'type-bug']
title='CallTips.py _find_constructor does not work'updated_at=<Date2014-01-21.21:01:46.905>user='https://github.com/codeape2'
--- CallTips.py (revision 78103)+++ CallTips.py (working copy)@@ -116,7 +116,7 @@
def _find_constructor(class_ob):
"Find the nearest __init__() in the class tree."
try:
- return class_ob.__init__.__func__+ return class_ob.__init__
except AttributeError:
for base in class_ob.__bases__:
init = _find_constructor(base)
bpo-12520 deleted _find_constructor in 3.x as it works with, but only with old-style classes (gone in 3.x) and just uses getattr(ob, '__init__', None). I believe the tests in this patch duplicate existing tests at the bottom of CallTips.py (increased from 10 to 30 as part of bpo-12510). I will recheck when I move the existing tests into the new idle_test/test_calltips.py.
The 3.x changes will not affect 2.7, which currently still uses _find_constructor. I suspect the .__func__ is needed for old-style classes, but I will try to check.
THanks for reporting this. bpo-12520 tripled the number of tests in CallTips.py and bpo-20122 moved them to test_calltips.py. I think they cover this case and the tests proposed. bpo-16630 added a few more tests and patched CallTips.py to make them pass. If you find any other cases that fail with the current bugfix releases, report them on a new issue.
Activity
codeape2 commentedon Feb 8, 2010
Test case:
Notice that the call tip is an empty parenthesis.
This patch works for me:
[/tmp/py3k/Lib/idlelib]
$ svn diff
Index: CallTips.py
===================================================================
briancurtin commentedon Feb 8, 2010
That change works for me.
serwy commentedon Dec 21, 2011
The patch works for me as well against 3.3a0.
Are there any cases where "__init__.__func__" would work?
codeape2 commentedon Dec 22, 2011
Attached is Lib/test/test_idlelib.py, containing a unit test for the issue.
serwy commentedon Jul 10, 2012
bpo-12510 fixes the issues listed here. I am leaving this issue open for discussing the test provided by Bernt.
terryjreedy commentedon May 30, 2013
bpo-12520 deleted _find_constructor in 3.x as it works with, but only with old-style classes (gone in 3.x) and just uses getattr(ob, '__init__', None). I believe the tests in this patch duplicate existing tests at the bottom of CallTips.py (increased from 10 to 30 as part of bpo-12510). I will recheck when I move the existing tests into the new idle_test/test_calltips.py.
terryjreedy commentedon Jan 10, 2014
The 3.x changes will not affect 2.7, which currently still uses _find_constructor. I suspect the .__func__ is needed for old-style classes, but I will try to check.
terryjreedy commentedon Jan 21, 2014
THanks for reporting this. bpo-12520 tripled the number of tests in CallTips.py and bpo-20122 moved them to test_calltips.py. I think they cover this case and the tests proposed. bpo-16630 added a few more tests and patched CallTips.py to make them pass. If you find any other cases that fail with the current bugfix releases, report them on a new issue.