Skip to content

socket.sendto raises incorrect exception when passed incorrect types #54378

Closed

Description

@exarkun
mannequin
BPO 10169
Nosy @pitrou, @giampaolo, @ezio-melotti
Files
  • issue10169.diff: Patch against 2.7.
  • issue10169-2.diff: Patch against 2.7 w/ tests.
  • 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/ezio-melotti'
    closed_at = <Date 2011-05-07.16:54:44.008>
    created_at = <Date 2010-10-21.17:22:06.335>
    labels = ['type-bug', 'library']
    title = 'socket.sendto raises incorrect exception when passed incorrect types'
    updated_at = <Date 2011-05-07.16:54:44.006>
    user = 'https://bugs.python.org/exarkun'

    bugs.python.org fields:

    activity = <Date 2011-05-07.16:54:44.006>
    actor = 'ezio.melotti'
    assignee = 'ezio.melotti'
    closed = True
    closed_date = <Date 2011-05-07.16:54:44.008>
    closer = 'ezio.melotti'
    components = ['Library (Lib)']
    creation = <Date 2010-10-21.17:22:06.335>
    creator = 'exarkun'
    dependencies = []
    files = ['21867', '21868']
    hgrepos = []
    issue_num = 10169
    keywords = ['patch', 'needs review']
    message_count = 5.0
    messages = ['119320', '135020', '135022', '135477', '135481']
    nosy_count = 6.0
    nosy_names = ['exarkun', 'pitrou', 'falsetru', 'giampaolo.rodola', 'ezio.melotti', 'python-dev']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue10169'
    versions = ['Python 2.7']

    Activity

    1. exarkun commented on Oct 21, 2010

      exarkunmannequin
      MannequinAuthor
      >>> s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
      >>> s.bind(('', 0))
      >>> s.sendto(u'hellé', s.getsockname())
      Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
      TypeError: sendto() takes exactly 3 arguments (2 given)
      >>> s.sendto(3, s.getsockname())
      Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
      TypeError: sendto() takes exactly 3 arguments (2 given)
      >>> s.sendto('hello', s.getsockname())
      5

      The TypeError gives the wrong explanation for what's wrong.

    2. added
      stdlib
      type-bug
      on Oct 21, 2010
    3. ezio-melotti commented on May 3, 2011

      @ezio-melotti
      Member

      The original code was trying to call PyArg_ParseTuple assuming 2 args and in case of failure (any failure) was starting over assuming 3 args.
      The attached patch makes PyArg_ParseTuple accept 2 or 3 args and re-arranges the last two if 'flags' is passed.
      The tests pass, but a few more tests should be added.

    4. self-assigned this
      on May 3, 2011
    5. ezio-melotti commented on May 3, 2011

      @ezio-melotti
      Member

      Added tests and fixed all the problems they found.

    6. python-dev commented on May 7, 2011

      python-devmannequin
      Mannequin

      New changeset 7c3a20b5943a by Ezio Melotti in branch '2.7':
      bpo-10169: Fix argument parsing in socket.sendto() to avoid error masking.
      http://hg.python.org/cpython/rev/7c3a20b5943a

    7. ezio-melotti commented on May 7, 2011

      @ezio-melotti
      Member

      This turned out to be a duplicate of bpo-5421 already fixed in 3.x, so I backported the patch and added the tests to 3.x too.

    8. 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

    stdlibtype-bug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions