Title: socket.CAN_RAW_ERR_FILTER is not defined in Python 3.11 and later · Issue #129719 · python/cpython · GitHub
Open Graph Title: socket.CAN_RAW_ERR_FILTER is not defined in Python 3.11 and later · Issue #129719 · python/cpython
X Title: socket.CAN_RAW_ERR_FILTER is not defined in Python 3.11 and later · Issue #129719 · python/cpython
Description: Bug report Bug description: When trying to use socket.CAN_RAW_ERR_FILTER on a Debian bookworm system, running Python 3.11, an AttributeError is raised. This is because the value is no longer defined in socket.py/_socket. I have also test...
Open Graph Description: Bug report Bug description: When trying to use socket.CAN_RAW_ERR_FILTER on a Debian bookworm system, running Python 3.11, an AttributeError is raised. This is because the value is no longer define...
X Description: Bug report Bug description: When trying to use socket.CAN_RAW_ERR_FILTER on a Debian bookworm system, running Python 3.11, an AttributeError is raised. This is because the value is no longer define...
Opengraph URL: https://github.com/python/cpython/issues/129719
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"socket.CAN_RAW_ERR_FILTER is not defined in Python 3.11 and later","articleBody":"# Bug report\n\n### Bug description:\n\nWhen trying to use `socket.CAN_RAW_ERR_FILTER` on a Debian bookworm system, running Python 3.11, an `AttributeError` is raised. This is because the value is no longer defined in `socket.py`/`_socket`.\n\nI have also tested in Python 3.13.1, and the issue is still present there.\n\nTypical usage of the value:\n```python\nimport socket\nsock = socket.socket(socket.AF_CAN, socket.SOCK_RAW | socket.SOCK_NONBLOCK, socket.CAN_RAW)\nsock.bind((interface_name,))\nsock.setsockopt(socket.SOL_CAN_RAW, socket.CAN_RAW_ERR_FILTER, socket.CAN_ERR_MASK)\n```\n\nMinimized reproduction:\n```python\nimport socket\nprint(socket.CAN_RAW_ERR_FILTER)\n```\n\nActual output:\n```\nTraceback (most recent call last):\n File \"\u003cpython-input-1\u003e\", line 1, in \u003cmodule\u003e\n print(socket.CAN_RAW_ERR_FILTER)\n ^^^^^^^^^^^^^^^^^^^^^^^^^\nAttributeError: module 'socket' has no attribute 'CAN_RAW_ERR_FILTER'. Did you mean: 'CAN_RAW_FILTER'?\n```\n\nExpected output (taken from Python 3.10.12):\n```\n2\n```\n\nInvestigating the issue, it seems to have been introduced in Python 3.11 by the following PR: https://github.com/python/cpython/pull/30066\nIn this PR, adding the `CAN_RAW_ERR_FILTER` value to `socket` was made conditional on defining `CAN_RAW_ERR_FILTER` during compilation. However, no change was made to actually define the value, thus it is never compiled for compatible systems.\n\nNote that the `CAN_RAW_ERR_FILTER` value is coming from `linux/can/raw.h` where is it defined as an `enum` value. Thus it will not be used by the C/C++ preprocessor to evaluate the `#ifdef CAN_RAW_ERR_FILTER` in `Modules/socketmodule.c`.\n\nExcerpt of relevant `raw.h` file from Debian Bookworm:\n```c\n/* for socket options affecting the socket (not the global system) */\n\nenum {\n\tCAN_RAW_FILTER = 1,\t/* set 0 .. n can_filter(s) */\n\tCAN_RAW_ERR_FILTER,\t/* set filter for error frames */\n\tCAN_RAW_LOOPBACK,\t/* local loopback (default:on) */\n\tCAN_RAW_RECV_OWN_MSGS,\t/* receive my own msgs (default:off) */\n\tCAN_RAW_FD_FRAMES,\t/* allow CAN FD frames (default:off) */\n\tCAN_RAW_JOIN_FILTERS,\t/* all filters must match to trigger */\n\tCAN_RAW_XL_FRAMES,\t/* allow CAN XL frames (default:off) */\n};\n```\n\n### CPython versions tested on:\n\n3.11, 3.13\n\n### Operating systems tested on:\n\nLinux\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-129721\n* gh-132702\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/jbogers","@type":"Person","name":"jbogers"},"datePublished":"2025-02-06T09:22:10.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/129719/cpython/issues/129719"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:06e313ca-3723-2682-0cbc-b49b31dba418 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 99B6:3463DE:67ED128:91BA4FB:6A504900 |
| html-safe-nonce | 24774a2b7ae27c43e2c627da62304d24a5d757c2ac0f80397c5839a45d91c715 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5OUI2OjM0NjNERTo2N0VEMTI4OjkxQkE0RkI6NkE1MDQ5MDAiLCJ2aXNpdG9yX2lkIjoiNzUxMzUxNjU0MTMwMTc3MDQ5NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 5473a061006bb6e8f31f9282e700c4aeaeba52372f182e2ab76cef98302479e4 |
| hovercard-subject-tag | issue:2834981373 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/129719/issue_layout |
| twitter:image | https://opengraph.githubassets.com/16a900fe1216859642005a2e4903b0e25f35f1d746766a15819c63f0727bf5a6/python/cpython/issues/129719 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/16a900fe1216859642005a2e4903b0e25f35f1d746766a15819c63f0727bf5a6/python/cpython/issues/129719 |
| og:image:alt | Bug report Bug description: When trying to use socket.CAN_RAW_ERR_FILTER on a Debian bookworm system, running Python 3.11, an AttributeError is raised. This is because the value is no longer define... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jbogers |
| hostname | github.com |
| expected-hostname | github.com |
| None | d6dc8294eb500fa36bbc57472d61fe87c522f9c3c1d64f70f4926f66a66a7efb |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 5741a45fe07e5f377d0d4c524a92e3056acc51bb |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width