Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

socket.CAN_RAW_ERR_FILTER is not defined in Python 3.11 and later #129719

Closed
Labels
extension-modulesC modules in the Modules dirtype-bugAn unexpected behavior, bug, or error
@jbogers

Description

@jbogers

Bug report

Bug description:

When trying to usesocket.CAN_RAW_ERR_FILTER on a Debian bookworm system, running Python 3.11, anAttributeError is raised. This is because the value is no longer defined insocket.py/_socket.

I have also tested in Python 3.13.1, and the issue is still present there.

Typical usage of the value:

importsocketsock=socket.socket(socket.AF_CAN,socket.SOCK_RAW|socket.SOCK_NONBLOCK,socket.CAN_RAW)sock.bind((interface_name,))sock.setsockopt(socket.SOL_CAN_RAW,socket.CAN_RAW_ERR_FILTER,socket.CAN_ERR_MASK)

Minimized reproduction:

importsocketprint(socket.CAN_RAW_ERR_FILTER)

Actual output:

Traceback (most recent call last):  File "<python-input-1>", line 1, in <module>    print(socket.CAN_RAW_ERR_FILTER)          ^^^^^^^^^^^^^^^^^^^^^^^^^AttributeError: module 'socket' has no attribute 'CAN_RAW_ERR_FILTER'. Did you mean: 'CAN_RAW_FILTER'?

Expected output (taken from Python 3.10.12):

2

Investigating the issue, it seems to have been introduced in Python 3.11 by the following PR:#30066
In this PR, adding theCAN_RAW_ERR_FILTER value tosocket was made conditional on definingCAN_RAW_ERR_FILTER during compilation. However, no change was made to actually define the value, thus it is never compiled for compatible systems.

Note that theCAN_RAW_ERR_FILTER value is coming fromlinux/can/raw.h where is it defined as anenum value. Thus it will not be used by the C/C++ preprocessor to evaluate the#ifdef CAN_RAW_ERR_FILTER inModules/socketmodule.c.

Excerpt of relevantraw.h file from Debian Bookworm:

/* for socket options affecting the socket (not the global system) */enum {CAN_RAW_FILTER=1,/* set 0 .. n can_filter(s)          */CAN_RAW_ERR_FILTER,/* set filter for error frames       */CAN_RAW_LOOPBACK,/* local loopback (default:on)       */CAN_RAW_RECV_OWN_MSGS,/* receive my own msgs (default:off) */CAN_RAW_FD_FRAMES,/* allow CAN FD frames (default:off) */CAN_RAW_JOIN_FILTERS,/* all filters must match to trigger */CAN_RAW_XL_FRAMES,/* allow CAN XL frames (default:off) */};

CPython versions tested on:

3.11, 3.13

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    extension-modulesC modules in the Modules dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp