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

Don't refer to getsockaddrarg in error messages #74018

Closed
serhiy-storchaka opened this issue Mar 17, 2017 · 5 comments
Closed

Don't refer to getsockaddrarg in error messages #74018

serhiy-storchaka opened this issue Mar 17, 2017 · 5 comments
Labels
3.7 (EOL) end of life extension-modules C modules in the Modules dir type-feature A feature request or enhancement

Comments

@serhiy-storchaka
Copy link
Member

BPO 29832
Nosy @benjaminp, @serhiy-storchaka, @orenmn
PRs
  • replace getsockaddrarg with getnameinfo in an error message in socket_getnameinfo #687
  • bpo-29832: remove "getsockaddrarg" from error messages #3163
  • Files
  • testPatches.py: a dirty script to test PR 3163
  • 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 2018-09-11.16:51:32.723>
    created_at = <Date 2017-03-17.06:43:17.378>
    labels = ['extension-modules', 'type-feature', '3.7']
    title = "Don't refer to getsockaddrarg in error messages"
    updated_at = <Date 2018-09-11.16:51:32.721>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2018-09-11.16:51:32.721>
    actor = 'benjamin.peterson'
    assignee = 'none'
    closed = True
    closed_date = <Date 2018-09-11.16:51:32.723>
    closer = 'benjamin.peterson'
    components = ['Extension Modules']
    creation = <Date 2017-03-17.06:43:17.378>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = ['47093']
    hgrepos = []
    issue_num = 29832
    keywords = []
    message_count = 5.0
    messages = ['289745', '289784', '300608', '303541', '325028']
    nosy_count = 3.0
    nosy_names = ['benjamin.peterson', 'serhiy.storchaka', 'Oren Milman']
    pr_nums = ['687', '3163']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue29832'
    versions = ['Python 3.7']

    @serhiy-storchaka
    Copy link
    Member Author

    getsockaddrarg() is an internal C function in the socket module implementation used in a number of socket methods (bind(), connect(), connect_ex(), sendto(), sendmsg()) for creating C structure sock_addr_t from Python tuple. Error messages raised when pass incorrect socket address argument to these function contain the name "getsockaddrarg" despite the fact that it is not directly exposed at Python level, nor the name of standard C function.

    >>> import socket
    >>> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    >>> s.bind(42)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: getsockaddrarg: AF_INET address must be tuple, not int
    >>> s.bind(())
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: getsockaddrarg() takes exactly 2 arguments (0 given)

    I think that error messages shouldn't refer to non-existing function "getsockaddrarg()".

    This issue is a part of more general bpo-28261.

    @serhiy-storchaka serhiy-storchaka added 3.7 (EOL) end of life extension-modules C modules in the Modules dir type-feature A feature request or enhancement labels Mar 17, 2017
    @orenmn
    Copy link
    Mannequin

    orenmn mannequin commented Mar 17, 2017

    note that bpo-15988 also left 3 changes for this issue to fix, as can be
    seen by searching for '29832' in the comments of PR 668.

    for example, this issue should also fix the following inconsistent
    error messages:
    >>> socket.socket(family=socket.AF_INET6).bind(('::1', -1))
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    OverflowError: getsockaddrarg: port must be 0-65535.
    >>> socket.socket(family=socket.AF_INET6).bind(('::1', -1 << 1000))
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    OverflowError: Python int too large to convert to C long

    @orenmn
    Copy link
    Mannequin

    orenmn mannequin commented Aug 20, 2017

    here is a dirty script to test my PR.

    the script contains tests to anything I managed to test using my
    Windows 10 and Ubuntu 16.04 VM, i.e. all of the changes, except for
    the 'unsupported CAN protocol' message, and the changes of the code
    that handles the PF_SYSTEM family.

    @orenmn
    Copy link
    Mannequin

    orenmn mannequin commented Oct 2, 2017

    Should i remove the code that i wasn't able to test from the PR, and
    leave such changes to someone that is able to test it?

    (of course, if there is some way i can do it using a VM, please point
    that out, and i would try to set up this VM.)

    @benjaminp
    Copy link
    Contributor

    New changeset 735171e by Benjamin Peterson (Oren Milman) in branch 'master':
    closes bpo-29832: Remove "getsockaddrarg" from error messages. (GH-3163)
    735171e

    @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
    3.7 (EOL) end of life extension-modules C modules in the Modules dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants