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

Signature.from_builtin should raise a ValueError when no signature can be provided #64621

Closed
1st1 opened this issue Jan 28, 2014 · 6 comments
Closed
Labels
type-bug An unexpected behavior, bug, or error

Comments

@1st1
Copy link
Member

1st1 commented Jan 28, 2014

BPO 20422
Nosy @brettcannon, @ncoghlan, @larryhastings, @1st1
Files
  • from_builtin_errors_01.patch
  • 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 = None
    closed_at = <Date 2014-01-29.15:47:10.182>
    created_at = <Date 2014-01-28.17:00:19.862>
    labels = ['type-bug']
    title = 'Signature.from_builtin should raise a ValueError when no signature can be provided'
    updated_at = <Date 2014-01-29.15:49:12.815>
    user = 'https://github.com/1st1'

    bugs.python.org fields:

    activity = <Date 2014-01-29.15:49:12.815>
    actor = 'yselivanov'
    assignee = 'none'
    closed = True
    closed_date = <Date 2014-01-29.15:47:10.182>
    closer = 'yselivanov'
    components = []
    creation = <Date 2014-01-28.17:00:19.862>
    creator = 'yselivanov'
    dependencies = []
    files = ['33784']
    hgrepos = []
    issue_num = 20422
    keywords = ['patch', 'needs review']
    message_count = 6.0
    messages = ['209565', '209586', '209638', '209649', '209650', '209651']
    nosy_count = 5.0
    nosy_names = ['brett.cannon', 'ncoghlan', 'larry', 'python-dev', 'yselivanov']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'patch review'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue20422'
    versions = ['Python 3.4']

    @1st1
    Copy link
    Member Author

    1st1 commented Jan 28, 2014

    Right now it may return None if no signature can be returned for the given builtin. If we decide to implement bpo-17373 in 3.5, I'd like all three methods -- from_builtin, from_function, from_callable -- to either return a signature or to raise an exception.

    @1st1 1st1 added the type-bug An unexpected behavior, bug, or error label Jan 28, 2014
    @1st1
    Copy link
    Member Author

    1st1 commented Jan 28, 2014

    A patch is attached, please review.

    @ncoghlan
    Copy link
    Contributor

    This proposal and patch look good to me. The current behaviour definitely isn't desirable:

    >>> import inspect
    >>> inspect.Signature.from_function(1)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/home/ncoghlan/devel/py3k/Lib/inspect.py", line 1888, in from_function
        raise TypeError('{!r} is not a Python function'.format(func))
    TypeError: 1 is not a Python function
    >>> inspect.Signature.from_builtin(1)
    >>> 

    Signature.from_function() and Signature.from_builtin() should both also be documented, but we may want to wait for PEP-457 and bpo-17373 in Python 3.5 before sorting all that out.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Jan 29, 2014

    New changeset 9433b380ad33 by Yury Selivanov in branch 'default':
    inspect.Signature: Make from_builtin to raise an exception if no signature can
    http://hg.python.org/cpython/rev/9433b380ad33

    @1st1
    Copy link
    Member Author

    1st1 commented Jan 29, 2014

    Nick, thanks for the review. Committed.

    @1st1 1st1 closed this as completed Jan 29, 2014
    @1st1
    Copy link
    Member Author

    1st1 commented Jan 29, 2014

    Signature.from_function() and Signature.from_builtin() should both also be documented, but we may want to wait for PEP-457 and bpo-17373 in Python 3.5 before sorting all that out.

    I would like to wait till 3.5 too. Right now both of them are sort of "private" API, so we still have the liberty to adjust their behaviour in 3.5 if needed.

    @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
    type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants