Skip to content

CallTips.py _find_constructor does not work #52131

Closed

Description

@codeape2
mannequin
BPO 7883
Nosy @terryjreedy, @serwy, @codeape2
Dependencies
  • bpo-20122: Move CallTips tests to idle_tests
  • Files
  • test_idlelib.py
  • 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 = <Date 2014-01-21.21:01:46.907>
    created_at = <Date 2010-02-08.12:11:42.101>
    labels = ['expert-IDLE', 'type-bug']
    title = 'CallTips.py _find_constructor does not work'
    updated_at = <Date 2014-01-21.21:01:46.905>
    user = 'https://github.com/codeape2'

    bugs.python.org fields:

    activity = <Date 2014-01-21.21:01:46.905>
    actor = 'terry.reedy'
    assignee = 'terry.reedy'
    closed = True
    closed_date = <Date 2014-01-21.21:01:46.907>
    closer = 'terry.reedy'
    components = ['IDLE']
    creation = <Date 2010-02-08.12:11:42.101>
    creator = 'Bernt.R\xc3\xb8skar.Brenna'
    dependencies = ['20122']
    files = ['24075']
    hgrepos = []
    issue_num = 7883
    keywords = []
    message_count = 8.0
    messages = ['99043', '99048', '150047', '150079', '165151', '190383', '207821', '208705']
    nosy_count = 3.0
    nosy_names = ['terry.reedy', 'roger.serwy', 'Bernt.R\xc3\xb8skar.Brenna']
    pr_nums = []
    priority = 'normal'
    resolution = 'out of date'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue7883'
    versions = ['Python 2.7', 'Python 3.3', 'Python 3.4']

    Activity

    1. codeape2 commented on Feb 8, 2010

      codeape2mannequin
      MannequinAuthor

      Test case:

      In IDLE python shell:
      >>> from http.client import HTTPConnection
      >>> c = HTTPConnection(

      Notice that the call tip is an empty parenthesis.

      This patch works for me:

      [/tmp/py3k/Lib/idlelib]
      $ svn diff
      Index: CallTips.py
      ===================================================================

      --- 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)
    2. added
      type-bug
      on Feb 8, 2010
    3. briancurtin commented on Feb 8, 2010

      @briancurtin
      Member

      That change works for me.

    4. serwy commented on Dec 21, 2011

      serwymannequin
      Mannequin

      The patch works for me as well against 3.3a0.

      Are there any cases where "__init__.__func__" would work?

    5. codeape2 commented on Dec 22, 2011

      codeape2mannequin
      MannequinAuthor

      Attached is Lib/test/test_idlelib.py, containing a unit test for the issue.

    6. serwy commented on Jul 10, 2012

      serwymannequin
      Mannequin

      bpo-12510 fixes the issues listed here. I am leaving this issue open for discussing the test provided by Bernt.

    7. terryjreedy commented on May 30, 2013

      @terryjreedy
      Member

      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.

    8. terryjreedy commented on Jan 10, 2014

      @terryjreedy
      Member

      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.

    9. terryjreedy commented on Jan 21, 2014

      @terryjreedy
      Member

      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.

    10. self-assigned this
      on Jan 21, 2014
    11. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    Labels

    topic-IDLEtype-bug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions