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

Argument Clinic: functions with valid sig but no docstring have no __text_signature__ #64785

Closed
zware opened this issue Feb 10, 2014 · 8 comments
Assignees
Labels
topic-argument-clinic type-bug An unexpected behavior, bug, or error

Comments

@zware
Copy link
Member

zware commented Feb 10, 2014

BPO 20586
Nosy @larryhastings, @zware
Files
  • issue20586.diff: Rietveld-friendly patch.
  • issue20586.v2.diff
  • issue20586.v3.diff
  • 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/zware'
    closed_at = <Date 2015-04-13.23:24:09.608>
    created_at = <Date 2014-02-10.20:28:26.115>
    labels = ['type-bug', 'expert-argument-clinic']
    title = 'Argument Clinic: functions with valid sig but no docstring have no __text_signature__'
    updated_at = <Date 2015-04-13.23:24:09.606>
    user = 'https://github.com/zware'

    bugs.python.org fields:

    activity = <Date 2015-04-13.23:24:09.606>
    actor = 'zach.ware'
    assignee = 'zach.ware'
    closed = True
    closed_date = <Date 2015-04-13.23:24:09.608>
    closer = 'zach.ware'
    components = ['Demos and Tools', 'Argument Clinic']
    creation = <Date 2014-02-10.20:28:26.115>
    creator = 'zach.ware'
    dependencies = []
    files = ['36143', '36275', '38969']
    hgrepos = []
    issue_num = 20586
    keywords = ['patch']
    message_count = 8.0
    messages = ['210864', '210869', '224777', '224881', '240784', '240802', '240805', '240806']
    nosy_count = 3.0
    nosy_names = ['larry', 'python-dev', 'zach.ware']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue20586'
    versions = ['Python 3.5']

    @zware
    Copy link
    Member Author

    zware commented Feb 10, 2014

    Builtins with a valid signature embedded in the docstring, but with no other docstring content are not picked up by the __text_signature__ getter because the docstring ends with ")\n--" rather than ")\n--\n\n". The attached patch adjusts clinic.CLanguage.docstring_for_c_string to make sure that the rendered docstring ends in "--\n\n" rather than "--".

    The result is a correct __text_signature__ and a __doc__ of ''.

    @zware zware added the type-bug An unexpected behavior, bug, or error label Feb 10, 2014
    @zware
    Copy link
    Member Author

    zware commented Feb 10, 2014

    Forgot to mention, there are no current examples of this checked in. winreg.HKEYType has a couple of methods with no docstring (enter and __exit__), and _winapi has several docstring-less functions, though.

    @larryhastings
    Copy link
    Contributor

    This looks reasonable to me. However I'd also change _PyType_GetDocFromInternalDoc() so that it also returns None if the first byte of the doc is \0.

    @zware
    Copy link
    Member Author

    zware commented Aug 5, 2014

    Something about like this? Note that this does change the behavior in the case where the whole docstring is empty but provided (such as when WITH_DOC_STRINGS == 0; see the changed line in test_capi).

    @zware
    Copy link
    Member Author

    zware commented Apr 13, 2015

    Here's an updated patch for clean application. Larry, could you give this a look?

    @larryhastings
    Copy link
    Contributor

    LGTM

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Apr 13, 2015

    New changeset e75fd221a53e by Zachary Ware in branch 'default':
    Issue bpo-20586: Argument Clinic now ensures signatures on functions without docstrings.
    https://hg.python.org/cpython/rev/e75fd221a53e

    @zware
    Copy link
    Member Author

    zware commented Apr 13, 2015

    Thanks Larry

    @zware zware closed this as completed Apr 13, 2015
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    topic-argument-clinic type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants