Skip to content

misleading setsockopt error message #107545

Closed

Description

@naweiss

Bug report

Running the following code works:

import socket

with socket.socket() as s:
    s.setsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF, 2)

But if someone accidently passes a big value like so:

import socket

with socket.socket() as s:
    s.setsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF, 2 ** 31)

He will get the follwing misleading error message: TypeError: a bytes-like object is required, not 'int'

Your environment

  • CPython versions tested on: 3.13.0a0
  • Operating system and architecture: x64 Ubuntu 20.04 LTS and Win10 x64 22H2

Linked PRs

Activity

  1. added
    type-bugAn unexpected behavior, bug, or error
    on Aug 1, 2023
  2. added 2 commits that reference this issue on Aug 1, 2023
  3. added
    stdlibStandard Library Python modules in the Lib/ directory
    on Nov 26, 2023
  4. added a commit that references this issue on Jun 23, 2025
  5. added a commit that references this issue on Aug 5, 2025
  6. added a commit that references this issue on Aug 5, 2025
  7. added a commit that references this issue on Aug 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions